RecursiveNamespaceV2 0.0.1__tar.gz → 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {recursivenamespacev2-0.0.1 → recursivenamespacev2-0.0.3}/.gitignore +5 -9
  2. recursivenamespacev2-0.0.3/PKG-INFO +157 -0
  3. recursivenamespacev2-0.0.3/README.md +114 -0
  4. {recursivenamespacev2-0.0.1 → recursivenamespacev2-0.0.3}/pyproject.toml +32 -15
  5. recursivenamespacev2-0.0.3/src/recursivenamespace/__init__.py +23 -0
  6. recursivenamespacev2-0.0.3/src/recursivenamespace/errors.py +27 -0
  7. recursivenamespacev2-0.0.3/src/recursivenamespace/main.py +895 -0
  8. {recursivenamespacev2-0.0.1 → recursivenamespacev2-0.0.3}/src/recursivenamespace/utils.py +31 -21
  9. recursivenamespacev2-0.0.1/.env.sample +0 -1
  10. recursivenamespacev2-0.0.1/.gitattributes +0 -2
  11. recursivenamespacev2-0.0.1/.github/workflows/publish.yml +0 -70
  12. recursivenamespacev2-0.0.1/.vscode/launch.json +0 -15
  13. recursivenamespacev2-0.0.1/PKG-INFO +0 -173
  14. recursivenamespacev2-0.0.1/README.md +0 -158
  15. recursivenamespacev2-0.0.1/examples/basic_usage.py +0 -51
  16. recursivenamespacev2-0.0.1/examples/basic_usage_2.py +0 -42
  17. recursivenamespacev2-0.0.1/examples/click_package.py +0 -101
  18. recursivenamespacev2-0.0.1/examples/keys_vs_attributes.py +0 -13
  19. recursivenamespacev2-0.0.1/examples/nested_namespace.py +0 -14
  20. recursivenamespacev2-0.0.1/requirements.txt +0 -9
  21. recursivenamespacev2-0.0.1/setup.py +0 -16
  22. recursivenamespacev2-0.0.1/src/recursivenamespace/__init__.py +0 -9
  23. recursivenamespacev2-0.0.1/src/recursivenamespace/_version.py +0 -729
  24. recursivenamespacev2-0.0.1/src/recursivenamespace/main.py +0 -501
  25. recursivenamespacev2-0.0.1/tests/test_recursive_namespace.py +0 -57
  26. recursivenamespacev2-0.0.1/tests/test_rns_v2.py +0 -138
  27. recursivenamespacev2-0.0.1/tests/test_utils.py +0 -87
  28. {recursivenamespacev2-0.0.1 → recursivenamespacev2-0.0.3}/LICENSE +0 -0
  29. /recursivenamespacev2-0.0.1/tests/__init__.py → /recursivenamespacev2-0.0.3/src/recursivenamespace/py.typed +0 -0
@@ -50,6 +50,7 @@ coverage.xml
50
50
  .hypothesis/
51
51
  .pytest_cache/
52
52
  cover/
53
+ coverage*/
53
54
 
54
55
  # Translations
55
56
  *.mo
@@ -107,15 +108,10 @@ ipython_config.py
107
108
  # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
109
  #poetry.lock
109
110
 
110
- # pdm
111
- # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
- #pdm.lock
113
- # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
- # in version control.
115
- # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
- .pdm.toml
117
- .pdm-python
118
- .pdm-build/
111
+ # uv
112
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
113
+ # This ensures reproducibility in CI and development environments.
114
+ uv.lock
119
115
 
120
116
  # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
117
  __pypackages__/
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: RecursiveNamespaceV2
3
+ Version: 0.0.3
4
+ Summary: Recursive Namespace. An extension of SimpleNamespace. Enhance get/set and parse from JSON
5
+ Project-URL: homepage, https://github.com/pasxd245/RecursiveNamespaceV2
6
+ Project-URL: repository, https://github.com/pasxd245/RecursiveNamespaceV2
7
+ Author-email: VienPQ <pasxd245@gmail.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) Jan.2025 VienPQ
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Operating System :: OS Independent
32
+ Classifier: Programming Language :: Python :: 3
33
+ Requires-Python: >=3.8
34
+ Provides-Extra: dev
35
+ Requires-Dist: pre-commit>=3.0; extra == 'dev'
36
+ Provides-Extra: docs
37
+ Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'docs'
38
+ Requires-Dist: sphinx>=7.0; extra == 'docs'
39
+ Provides-Extra: test
40
+ Requires-Dist: coverage>=7.0; extra == 'test'
41
+ Requires-Dist: pytest>=6.0; extra == 'test'
42
+ Description-Content-Type: text/markdown
43
+
44
+ # RecursiveNamespaceV2
45
+
46
+ [![CI](https://github.com/pasxd245/RecursiveNamespaceV2/workflows/CI/badge.svg)](https://github.com/pasxd245/RecursiveNamespaceV2/actions/workflows/ci.yml)
47
+ [![Type Check](https://github.com/pasxd245/RecursiveNamespaceV2/workflows/Type%20Check/badge.svg)](https://github.com/pasxd245/RecursiveNamespaceV2/actions/workflows/type-check.yml)
48
+ [![codecov](https://codecov.io/gh/pasxd245/RecursiveNamespaceV2/branch/main/graph/badge.svg)](https://codecov.io/gh/pasxd245/RecursiveNamespaceV2)
49
+ [![Python Version](https://img.shields.io/pypi/pyversions/RecursiveNamespaceV2)](https://pypi.org/project/RecursiveNamespaceV2/)
50
+ [![PyPI version](https://badge.fury.io/py/RecursiveNamespaceV2.svg)](https://badge.fury.io/py/RecursiveNamespaceV2)
51
+ [![License](https://img.shields.io/github/license/pasxd245/RecursiveNamespaceV2)](https://github.com/pasxd245/RecursiveNamespaceV2/blob/main/LICENSE)
52
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
53
+
54
+ ## Description
55
+
56
+ **RecursiveNamespaceV2** extends Python's **SimpleNamespace** to make nested dicts easy to work with using attribute access, dict access, and chain-keys.
57
+
58
+ Full documentation: [https://recursivenamespacev2.readthedocs.io/](https://recursivenamespacev2.readthedocs.io/)
59
+
60
+ Key features:
61
+
62
+ - Recursive conversion of nested dicts/lists
63
+ - Attribute and dict access (`rn.a` and `rn["a"]`)
64
+ - Chain-key access (`rn.val_get("a.b.c")`)
65
+ - Array indexing and append syntax (`items[].0`, `items[].#`)
66
+ - Typed, zero-dependency, pure Python
67
+
68
+ ## Installation
69
+
70
+ ```bash
71
+ pip install RecursiveNamespaceV2
72
+ ```
73
+
74
+ Or with [uv](https://docs.astral.sh/uv/):
75
+
76
+ ```bash
77
+ uv add RecursiveNamespaceV2
78
+ ```
79
+
80
+ For development from source:
81
+
82
+ ```bash
83
+ git clone https://github.com/pasxd245/RecursiveNamespaceV2.git
84
+ cd RecursiveNamespaceV2
85
+ uv venv
86
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
87
+ uv pip install -e ".[test]"
88
+ ```
89
+
90
+ ## Quick Start
91
+
92
+ ```python
93
+ from recursivenamespace import RNS # or RecursiveNamespace
94
+
95
+ data = {
96
+ 'name': 'John',
97
+ 'age': 30,
98
+ 'address': {
99
+ 'street': '123 Main St',
100
+ 'city': 'Anytown'
101
+ },
102
+ 'friends': ['Jane', 'Tom']
103
+ }
104
+
105
+ rn = RNS(data)
106
+ print(rn.address.city) # Anytown
107
+ print(rn["friends"][1]) # Tom
108
+
109
+ # Chain-key access
110
+ rn.val_set("address.zip", "12345")
111
+ print(rn.val_get("address.zip")) # 12345
112
+
113
+ # Convert back to dict
114
+ data2 = rn.to_dict()
115
+ print(data2["address"]["city"]) # Anytown
116
+ ```
117
+
118
+ ## Examples
119
+
120
+ See the `examples/` directory for 15 runnable examples organized by difficulty (basic, intermediate, advanced, real-world).
121
+
122
+ ## Testing
123
+
124
+ To run tests, navigate to the project's root directory and execute:
125
+
126
+ ```bash
127
+ uv run pytest -s
128
+ # or with coverage:
129
+ uv run coverage run -m pytest
130
+ # to generate html report:
131
+ uv run coverage html
132
+ ```
133
+
134
+ ## Release
135
+
136
+ Versions are derived automatically from **git tags** (via [hatch-vcs](https://github.com/ofek/hatch-vcs)):
137
+
138
+ ```bash
139
+ git tag -a v1.2.3 -m "v1.2.3"
140
+ git push --tags
141
+ ```
142
+
143
+ CI automatically builds, publishes to PyPI (OIDC trusted publishing), and creates a GitHub Release with auto-generated notes.
144
+
145
+ ## Contributing
146
+
147
+ Contributions to the **RecursiveNamespace** project are welcome! Please ensure that any pull requests include tests covering new features or fixes. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
148
+
149
+ ## License
150
+
151
+ This project is licensed under the MIT License - see the `LICENSE` file for details.
152
+
153
+ ---
154
+
155
+ ## Transparency
156
+
157
+ AI-assisted development (e.g., Claude Code, Copilot) was used for scaffolding and iteration.
@@ -0,0 +1,114 @@
1
+ # RecursiveNamespaceV2
2
+
3
+ [![CI](https://github.com/pasxd245/RecursiveNamespaceV2/workflows/CI/badge.svg)](https://github.com/pasxd245/RecursiveNamespaceV2/actions/workflows/ci.yml)
4
+ [![Type Check](https://github.com/pasxd245/RecursiveNamespaceV2/workflows/Type%20Check/badge.svg)](https://github.com/pasxd245/RecursiveNamespaceV2/actions/workflows/type-check.yml)
5
+ [![codecov](https://codecov.io/gh/pasxd245/RecursiveNamespaceV2/branch/main/graph/badge.svg)](https://codecov.io/gh/pasxd245/RecursiveNamespaceV2)
6
+ [![Python Version](https://img.shields.io/pypi/pyversions/RecursiveNamespaceV2)](https://pypi.org/project/RecursiveNamespaceV2/)
7
+ [![PyPI version](https://badge.fury.io/py/RecursiveNamespaceV2.svg)](https://badge.fury.io/py/RecursiveNamespaceV2)
8
+ [![License](https://img.shields.io/github/license/pasxd245/RecursiveNamespaceV2)](https://github.com/pasxd245/RecursiveNamespaceV2/blob/main/LICENSE)
9
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
10
+
11
+ ## Description
12
+
13
+ **RecursiveNamespaceV2** extends Python's **SimpleNamespace** to make nested dicts easy to work with using attribute access, dict access, and chain-keys.
14
+
15
+ Full documentation: [https://recursivenamespacev2.readthedocs.io/](https://recursivenamespacev2.readthedocs.io/)
16
+
17
+ Key features:
18
+
19
+ - Recursive conversion of nested dicts/lists
20
+ - Attribute and dict access (`rn.a` and `rn["a"]`)
21
+ - Chain-key access (`rn.val_get("a.b.c")`)
22
+ - Array indexing and append syntax (`items[].0`, `items[].#`)
23
+ - Typed, zero-dependency, pure Python
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install RecursiveNamespaceV2
29
+ ```
30
+
31
+ Or with [uv](https://docs.astral.sh/uv/):
32
+
33
+ ```bash
34
+ uv add RecursiveNamespaceV2
35
+ ```
36
+
37
+ For development from source:
38
+
39
+ ```bash
40
+ git clone https://github.com/pasxd245/RecursiveNamespaceV2.git
41
+ cd RecursiveNamespaceV2
42
+ uv venv
43
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
44
+ uv pip install -e ".[test]"
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ ```python
50
+ from recursivenamespace import RNS # or RecursiveNamespace
51
+
52
+ data = {
53
+ 'name': 'John',
54
+ 'age': 30,
55
+ 'address': {
56
+ 'street': '123 Main St',
57
+ 'city': 'Anytown'
58
+ },
59
+ 'friends': ['Jane', 'Tom']
60
+ }
61
+
62
+ rn = RNS(data)
63
+ print(rn.address.city) # Anytown
64
+ print(rn["friends"][1]) # Tom
65
+
66
+ # Chain-key access
67
+ rn.val_set("address.zip", "12345")
68
+ print(rn.val_get("address.zip")) # 12345
69
+
70
+ # Convert back to dict
71
+ data2 = rn.to_dict()
72
+ print(data2["address"]["city"]) # Anytown
73
+ ```
74
+
75
+ ## Examples
76
+
77
+ See the `examples/` directory for 15 runnable examples organized by difficulty (basic, intermediate, advanced, real-world).
78
+
79
+ ## Testing
80
+
81
+ To run tests, navigate to the project's root directory and execute:
82
+
83
+ ```bash
84
+ uv run pytest -s
85
+ # or with coverage:
86
+ uv run coverage run -m pytest
87
+ # to generate html report:
88
+ uv run coverage html
89
+ ```
90
+
91
+ ## Release
92
+
93
+ Versions are derived automatically from **git tags** (via [hatch-vcs](https://github.com/ofek/hatch-vcs)):
94
+
95
+ ```bash
96
+ git tag -a v1.2.3 -m "v1.2.3"
97
+ git push --tags
98
+ ```
99
+
100
+ CI automatically builds, publishes to PyPI (OIDC trusted publishing), and creates a GitHub Release with auto-generated notes.
101
+
102
+ ## Contributing
103
+
104
+ Contributions to the **RecursiveNamespace** project are welcome! Please ensure that any pull requests include tests covering new features or fixes. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
105
+
106
+ ## License
107
+
108
+ This project is licensed under the MIT License - see the `LICENSE` file for details.
109
+
110
+ ---
111
+
112
+ ## Transparency
113
+
114
+ AI-assisted development (e.g., Claude Code, Copilot) was used for scaffolding and iteration.
@@ -1,7 +1,6 @@
1
1
  [build-system]
2
- # Minimum requirements for the build system to execute.
3
- requires = ["flit_core >=3.2,<4", "versioneer[toml]"]
4
- build-backend = "flit_core.buildapi"
2
+ requires = ["hatchling", "hatch-vcs"]
3
+ build-backend = "hatchling.build"
5
4
 
6
5
  [project]
7
6
  name = 'RecursiveNamespaceV2'
@@ -19,24 +18,26 @@ classifiers = [
19
18
  ]
20
19
 
21
20
  [project.urls]
21
+ homepage = 'https://github.com/pasxd245/RecursiveNamespaceV2'
22
22
  repository = 'https://github.com/pasxd245/RecursiveNamespaceV2'
23
23
 
24
24
  [project.optional-dependencies]
25
+ dev = ['pre-commit>=3.0']
25
26
  test = ['pytest>=6.0', 'coverage>=7.0']
27
+ docs = ['sphinx>=7.0', 'sphinx-rtd-theme>=2.0']
26
28
 
27
- # See the docstring in versioneer.py for instructions. Note that you must
28
- # re-run 'versioneer.py setup' after changing this section, and commit the
29
- # resulting files.
30
- [tool.versioneer]
31
- VCS = "git"
32
- style = "pep440"
33
- tag_prefix = "v"
34
- parentdir_prefix = "recursivenamespacev2-"
35
- versionfile_source = "src/recursivenamespace/_version.py"
36
- versionfile_build = "recursivenamespace/_version.py"
29
+ [tool.hatch.version]
30
+ source = "vcs"
37
31
 
38
- [tool.flit.module]
39
- name = "recursivenamespace"
32
+ [tool.hatch.version.raw-options]
33
+ version_scheme = "guess-next-dev"
34
+ local_scheme = "no-local-version"
35
+
36
+ [tool.hatch.build.targets.sdist]
37
+ include = ["src/recursivenamespace"]
38
+
39
+ [tool.hatch.build.targets.wheel]
40
+ packages = ["src/recursivenamespace"]
40
41
 
41
42
  [tool.ruff]
42
43
  line-length = 80
@@ -77,3 +78,19 @@ directory = "coverage_html_report"
77
78
  [tool.codespell]
78
79
  ignore-words-list = "rns"
79
80
  ignore-regex = 'https://([\w/\.])+'
81
+
82
+ [tool.mypy]
83
+ python_version = "3.9"
84
+ warn_return_any = true
85
+ warn_unused_configs = true
86
+ disallow_untyped_defs = true
87
+ disallow_incomplete_defs = true
88
+ check_untyped_defs = true
89
+ disallow_untyped_decorators = false
90
+ no_implicit_optional = true
91
+ warn_redundant_casts = true
92
+ warn_unused_ignores = true
93
+ warn_no_return = true
94
+ follow_imports = "normal"
95
+ strict_equality = true
96
+ strict = true
@@ -0,0 +1,23 @@
1
+ from __future__ import annotations
2
+
3
+ from .main import recursivenamespace
4
+ from .main import recursivenamespace as RecursiveNamespace
5
+ from .main import recursivenamespace as RNS
6
+ from . import main as rns
7
+ from .errors import GetChainKeyError, SerializationError, SetChainKeyError
8
+
9
+ from importlib.metadata import version as _get_version
10
+
11
+ __version__: str = _get_version("RecursiveNamespaceV2")
12
+ del _get_version
13
+
14
+ __all__ = [
15
+ "recursivenamespace",
16
+ "RecursiveNamespace",
17
+ "RNS",
18
+ "rns",
19
+ "GetChainKeyError",
20
+ "SerializationError",
21
+ "SetChainKeyError",
22
+ "__version__",
23
+ ]
@@ -0,0 +1,27 @@
1
+ """Custom exception classes for RecursiveNamespaceV2."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+
8
+ class SetChainKeyError(KeyError):
9
+ def __init__(self, obj: Any, key: str, sub_key: str) -> None:
10
+ super().__init__(
11
+ f"The object '{key}' typeof({type(obj)}) does not support"
12
+ f" set[] operator on chain-key '{sub_key}'."
13
+ )
14
+
15
+
16
+ class GetChainKeyError(KeyError):
17
+ def __init__(self, obj: Any, key: str, sub_key: str) -> None:
18
+ super().__init__(
19
+ f"The object '{key}' typeof({type(obj)}) does not support"
20
+ f" get[] operator on chain-key '{sub_key}'."
21
+ )
22
+
23
+
24
+ class SerializationError(Exception):
25
+ """Raised when serialization or deserialization fails."""
26
+
27
+ pass