readonlydict 1.0.0__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.
- readonlydict-1.0.0/.devcontainer/devcontainer.json +32 -0
- readonlydict-1.0.0/.github/CODE_OF_CONDUCT.md +128 -0
- readonlydict-1.0.0/.github/workflows/docs.yaml +25 -0
- readonlydict-1.0.0/.github/workflows/pypi.yaml +19 -0
- readonlydict-1.0.0/.github/workflows/tests.yaml +35 -0
- readonlydict-1.0.0/.gitignore +208 -0
- readonlydict-1.0.0/CITATION.cff +32 -0
- readonlydict-1.0.0/LICENSE +21 -0
- readonlydict-1.0.0/PKG-INFO +148 -0
- readonlydict-1.0.0/README.md +106 -0
- readonlydict-1.0.0/docs/_static/switcher.json +12 -0
- readonlydict-1.0.0/docs/build +8 -0
- readonlydict-1.0.0/docs/conf.py +42 -0
- readonlydict-1.0.0/docs/index.md +11 -0
- readonlydict-1.0.0/pyproject.toml +59 -0
- readonlydict-1.0.0/readonlydict/__init__.py +135 -0
- readonlydict-1.0.0/readonlydict/py.typed +0 -0
- readonlydict-1.0.0/tests/test_customdict.py +127 -0
- readonlydict-1.0.0/tests/test_readonlydict.py +92 -0
- readonlydict-1.0.0/uv.lock +1274 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "readonlydict",
|
|
3
|
+
"image": "ghcr.io/astral-sh/uv:python3.12-bookworm",
|
|
4
|
+
"runArgs": [
|
|
5
|
+
"--name=readonlydict"
|
|
6
|
+
],
|
|
7
|
+
"containerEnv": {
|
|
8
|
+
"UV_PROJECT_ENVIRONMENT": "/usr/local"
|
|
9
|
+
},
|
|
10
|
+
"postCreateCommand": "uv sync --frozen",
|
|
11
|
+
"customizations": {
|
|
12
|
+
"vscode": {
|
|
13
|
+
"extensions": [
|
|
14
|
+
"ms-python.black-formatter",
|
|
15
|
+
"ms-python.python",
|
|
16
|
+
"streetsidesoftware.code-spell-checker",
|
|
17
|
+
"tamasfe.even-better-toml"
|
|
18
|
+
],
|
|
19
|
+
"settings": {
|
|
20
|
+
"black-formatter.importStrategy": "fromEnvironment",
|
|
21
|
+
"files.insertFinalNewline": true,
|
|
22
|
+
"files.trimTrailingWhitespace": true,
|
|
23
|
+
"python.analysis.autoImportCompletions": true,
|
|
24
|
+
"python.languageServer": "Pylance",
|
|
25
|
+
"[python]": {
|
|
26
|
+
"editor.defaultFormatter": "ms-python.black-formatter",
|
|
27
|
+
"editor.formatOnSave": true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
+
overall community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
+
advances of any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
a-taniguchi@mail.kitami-it.ac.jp.
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
|
86
|
+
of actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
|
93
|
+
permanent ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
+
the community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.0, available at
|
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
+
|
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
|
125
|
+
|
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
+
https://www.contributor-covenant.org/translations.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types:
|
|
6
|
+
- created
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
job:
|
|
10
|
+
name: Docs
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
container: ghcr.io/astral-sh/uv:python3.12-bookworm
|
|
13
|
+
env:
|
|
14
|
+
UV_PROJECT_ENVIRONMENT: /usr/local
|
|
15
|
+
permissions:
|
|
16
|
+
contents: write
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- run: uv sync --frozen
|
|
20
|
+
- run: docs/build
|
|
21
|
+
- uses: peaceiris/actions-gh-pages@v4
|
|
22
|
+
with:
|
|
23
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
24
|
+
publish_dir: ./docs/_build
|
|
25
|
+
keep_files: true
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types:
|
|
6
|
+
- created
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
job:
|
|
10
|
+
name: PyPI
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
container: ghcr.io/astral-sh/uv:python3.12-bookworm
|
|
13
|
+
env:
|
|
14
|
+
UV_PROJECT_ENVIRONMENT: /usr/local
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- run: uv build && uv publish
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
job:
|
|
13
|
+
name: Test (${{ matrix.env }})
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
container: ghcr.io/astral-sh/uv:${{ matrix.env }}
|
|
16
|
+
env:
|
|
17
|
+
PYTHON_DIRS: docs readonlydict tests
|
|
18
|
+
UV_PROJECT_ENVIRONMENT: /usr/local
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
env:
|
|
23
|
+
- python3.10-bookworm
|
|
24
|
+
- python3.11-bookworm
|
|
25
|
+
- python3.12-bookworm
|
|
26
|
+
- python3.13-bookworm
|
|
27
|
+
- python3.14-bookworm
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
- run: uv sync --frozen
|
|
31
|
+
- run: black --check ${PYTHON_DIRS}
|
|
32
|
+
- run: mypy ${PYTHON_DIRS}
|
|
33
|
+
- run: pyright ${PYTHON_DIRS}
|
|
34
|
+
- run: pytest -v tests
|
|
35
|
+
- run: docs/build
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_apidoc/
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
#Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# UV
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
#uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
#poetry.lock
|
|
110
|
+
#poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
#pdm.lock
|
|
117
|
+
#pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
#pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi
|
|
127
|
+
|
|
128
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
129
|
+
__pypackages__/
|
|
130
|
+
|
|
131
|
+
# Celery stuff
|
|
132
|
+
celerybeat-schedule
|
|
133
|
+
celerybeat.pid
|
|
134
|
+
|
|
135
|
+
# SageMath parsed files
|
|
136
|
+
*.sage.py
|
|
137
|
+
|
|
138
|
+
# Environments
|
|
139
|
+
.env
|
|
140
|
+
.envrc
|
|
141
|
+
.venv
|
|
142
|
+
env/
|
|
143
|
+
venv/
|
|
144
|
+
ENV/
|
|
145
|
+
env.bak/
|
|
146
|
+
venv.bak/
|
|
147
|
+
|
|
148
|
+
# Spyder project settings
|
|
149
|
+
.spyderproject
|
|
150
|
+
.spyproject
|
|
151
|
+
|
|
152
|
+
# Rope project settings
|
|
153
|
+
.ropeproject
|
|
154
|
+
|
|
155
|
+
# mkdocs documentation
|
|
156
|
+
/site
|
|
157
|
+
|
|
158
|
+
# mypy
|
|
159
|
+
.mypy_cache/
|
|
160
|
+
.dmypy.json
|
|
161
|
+
dmypy.json
|
|
162
|
+
|
|
163
|
+
# Pyre type checker
|
|
164
|
+
.pyre/
|
|
165
|
+
|
|
166
|
+
# pytype static type analyzer
|
|
167
|
+
.pytype/
|
|
168
|
+
|
|
169
|
+
# Cython debug symbols
|
|
170
|
+
cython_debug/
|
|
171
|
+
|
|
172
|
+
# PyCharm
|
|
173
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
174
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
175
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
176
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
177
|
+
#.idea/
|
|
178
|
+
|
|
179
|
+
# Abstra
|
|
180
|
+
# Abstra is an AI-powered process automation framework.
|
|
181
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
182
|
+
# Learn more at https://abstra.io/docs
|
|
183
|
+
.abstra/
|
|
184
|
+
|
|
185
|
+
# Visual Studio Code
|
|
186
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
187
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
188
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
189
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
190
|
+
# .vscode/
|
|
191
|
+
|
|
192
|
+
# Ruff stuff:
|
|
193
|
+
.ruff_cache/
|
|
194
|
+
|
|
195
|
+
# PyPI configuration file
|
|
196
|
+
.pypirc
|
|
197
|
+
|
|
198
|
+
# Cursor
|
|
199
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
200
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
201
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
202
|
+
.cursorignore
|
|
203
|
+
.cursorindexingignore
|
|
204
|
+
|
|
205
|
+
# Marimo
|
|
206
|
+
marimo/_static/
|
|
207
|
+
marimo/_lsp/
|
|
208
|
+
__marimo__/
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# This CITATION.cff file was generated with cffinit.
|
|
2
|
+
# Visit https://bit.ly/cffinit to generate yours today!
|
|
3
|
+
|
|
4
|
+
cff-version: 1.2.0
|
|
5
|
+
title: ReadonlyDict
|
|
6
|
+
message: >-
|
|
7
|
+
If you use this software, please cite it using the
|
|
8
|
+
metadata from this file.
|
|
9
|
+
type: software
|
|
10
|
+
authors:
|
|
11
|
+
- given-names: Akio
|
|
12
|
+
family-names: Taniguchi
|
|
13
|
+
email: a-taniguchi@mail.kitami-it.ac.jp
|
|
14
|
+
affiliation: Kitami Institute of Technology
|
|
15
|
+
orcid: 'https://orcid.org/0000-0002-9695-6183'
|
|
16
|
+
identifiers:
|
|
17
|
+
- type: doi
|
|
18
|
+
value: 10.5281/zenodo.19187089
|
|
19
|
+
repository-code: 'https://github.com/astropenguin/readonlydict'
|
|
20
|
+
url: 'https://astropenguin.github.io/readonlydict'
|
|
21
|
+
abstract: Read-only dictionary with 100% typing and runtime compatibility
|
|
22
|
+
keywords:
|
|
23
|
+
- dictionary
|
|
24
|
+
- hashable
|
|
25
|
+
- immutable
|
|
26
|
+
- mapping
|
|
27
|
+
- python
|
|
28
|
+
- read-only
|
|
29
|
+
- typing
|
|
30
|
+
license: MIT
|
|
31
|
+
version: 1.0.0
|
|
32
|
+
date-released: '2026-03-24'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Akio Taniguchi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: readonlydict
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Drop-in read-only dictionary with 100% typing and runtime compatibility
|
|
5
|
+
Project-URL: homepage, https://astropenguin.github.io/readonlydict
|
|
6
|
+
Project-URL: repository, https://github.com/astropenguin/readonlydict
|
|
7
|
+
Author-email: Akio Taniguchi <a-taniguchi@mail.kitami-it.ac.jp>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 Akio Taniguchi
|
|
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
|
+
Keywords: dictionary,hashable,immutable,mapping,python,read-only,typing
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
39
|
+
Requires-Python: <4.0,>=3.10
|
|
40
|
+
Requires-Dist: typing-extensions<5,>=4
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
|
|
43
|
+
# ReadonlyDict
|
|
44
|
+
|
|
45
|
+
[](https://pypi.org/project/readonlydict/)
|
|
46
|
+
[](https://pypi.org/project/readonlydict/)
|
|
47
|
+
[](https://pepy.tech/project/readonlydict)
|
|
48
|
+
[](https://doi.org/10.5281/zenodo.19187089)
|
|
49
|
+
[](https://github.com/astropenguin/readonlydict/actions)
|
|
50
|
+
|
|
51
|
+
Drop-in read-only dictionary with 100% typing and runtime compatibility
|
|
52
|
+
|
|
53
|
+
## Overview: Why ReadonlyDict?
|
|
54
|
+
|
|
55
|
+
This package is built strictly on the following formula: ``ReadonlyDict = (Built-in dictionary) - (In-place features) + (Read-only features)``.
|
|
56
|
+
|
|
57
|
+
- **100% compatibility and zero custom API:** Our goal is to achieve flawless compatibility with Python's built-in dictionary in both static type checking (e.g., [mypy], [Pyright]) and runtime behavior. We simply removed in-place methods (e.g., ``pop()``, ``update()``). We do not introduce any custom methods.
|
|
58
|
+
- **True immutable semantics:** The only additions are those strictly required for a read-only data structure: it is fully hashable (only if all values are hashable), and shallow copies (i.e., ``self.copy()``, ``copy.copy(self)``) simply return itself to save memory.
|
|
59
|
+
- **When to use this package:** If you want extended read-only features, existing packages like [frozendict], [immutabledict], or [immutables] are better choices. However, if your priority is pure compatibility and perfect static type inference, ReadonlyDict should be the optimal choice.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install readonlydict
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Basic Usage
|
|
68
|
+
|
|
69
|
+
It works exactly like a built-in dictionary, but raises an error if you try to modify it.
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from readonlydict import ReadonlyDict
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# Initialization works just like the built-in dictionary:
|
|
76
|
+
>>> ro = ReadonlyDict(a=0, b=1)
|
|
77
|
+
>>> ro
|
|
78
|
+
ReadonlyDict({'a': 0, 'b': 1})
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# It is fully hashable (can be used as a dictionary key or in a set):
|
|
82
|
+
>>> hash(ro)
|
|
83
|
+
-5925576189957013898
|
|
84
|
+
>>> {ro, ro}
|
|
85
|
+
{ReadonlyDict({'a': 0, 'b': 1})}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# Mutation is strictly prohibited (static type checkers will also warn you):
|
|
89
|
+
>>> ro["c"] = 2
|
|
90
|
+
TypeError: 'ReadonlyDict' object does not support item assignment
|
|
91
|
+
>>> ro.update(c=2)
|
|
92
|
+
AttributeError: 'ReadonlyDict' object has no attribute 'update'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Advanced Usage: Subclassing with Type Hints
|
|
96
|
+
|
|
97
|
+
If you want to create your own custom read-only dictionary by subclassing ``ReadonlyDict``, you can maintain static type inference by utilizing ``TYPE_CHECKING`` and ``@overload``.
|
|
98
|
+
Here is the best-practice template for subclassing:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
# standard library
|
|
102
|
+
from collections.abc import Iterable, Mapping
|
|
103
|
+
from typing import TYPE_CHECKING, Any, TypeVar, overload
|
|
104
|
+
|
|
105
|
+
# dependencies
|
|
106
|
+
from readonlydict import ReadonlyDict
|
|
107
|
+
|
|
108
|
+
# type variables
|
|
109
|
+
K = TypeVar("K")
|
|
110
|
+
K2 = TypeVar("K2")
|
|
111
|
+
V = TypeVar("V")
|
|
112
|
+
V2 = TypeVar("V2")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class CustomDict(ReadonlyDict[K, V]):
|
|
116
|
+
# Modify the return types to guarantee type inference:
|
|
117
|
+
if TYPE_CHECKING:
|
|
118
|
+
|
|
119
|
+
@overload
|
|
120
|
+
def __new__(cls, **kwargs: V) -> "CustomDict[str, V]": ...
|
|
121
|
+
@overload
|
|
122
|
+
def __new__(cls, mapping: Mapping[K, V], /, **kwargs: V2) -> "CustomDict[K | str, V | V2]": ...
|
|
123
|
+
@overload
|
|
124
|
+
def __new__(cls, iterable: Iterable[tuple[K, V]], /, **kwargs: V2) -> "CustomDict[K | str, V | V2]": ...
|
|
125
|
+
def __new__(cls, *args: Any, **kwargs: Any) -> Any: ... # type: ignore[misc]
|
|
126
|
+
|
|
127
|
+
@overload
|
|
128
|
+
@classmethod
|
|
129
|
+
def fromkeys(cls, iterable: Iterable[K2], /) -> "CustomDict[K2, None]": ...
|
|
130
|
+
@overload
|
|
131
|
+
@classmethod
|
|
132
|
+
def fromkeys(cls, iterable: Iterable[K2], value: V2, /) -> "CustomDict[K2, V2]": ...
|
|
133
|
+
@classmethod
|
|
134
|
+
def fromkeys(cls, *args: Any, **kwargs: Any) -> Any: ...
|
|
135
|
+
|
|
136
|
+
def __or__(self, other: Mapping[K2, V2], /) -> "CustomDict[K | K2, V | V2]": ...
|
|
137
|
+
|
|
138
|
+
# Then add your custom properties or methods:
|
|
139
|
+
@property
|
|
140
|
+
def first(self) -> tuple[K, V]:
|
|
141
|
+
return next(iter(self.items()))
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
[frozendict]: https://github.com/Marco-Sulla/python-frozendict
|
|
145
|
+
[immutabledict]: https://immutabledict.corenting.fr
|
|
146
|
+
[immutables]: https://github.com/MagicStack/immutables
|
|
147
|
+
[mypy]: https://www.mypy-lang.org
|
|
148
|
+
[Pyright]: https://microsoft.github.io/pyright
|