classicle
Provides immutable constant namespaces with dataclass-like ergonomics. See the Python discussion thread for context, motivation, and alternative approaches.
Example:
from classicle import FrozenSpace
class Config(FrozenSpace):
HOST = "localhost"
PORT: int = 8080 # add type hints only when you want them
DEBUG = True
print(Config.HOST) # "localhost"; Type checker knows this is a str
print(Config.PORT) # 8080
config_dict = dict(Config)
# {'HOST': 'localhost', 'PORT': 8080, 'DEBUG': True}
# Iterate over attributes
for name, value in Config.items():
print(f"{name} = {value}")
Features
- Type checker friendly
- No instantiation needed: The class itself is the namespace (cannot be instantiated)
- Immutable: Attributes cannot be modified (at the top level) or deleted after creation
- Mapping protocol: Supports
dict(),len(),in, iteration,.items(),.keys(),.values()
Immutability
class Constants(FrozenSpace):
PI = 3.14159
E = 2.71828
# This will raise an AttributeError
try:
Constants.PI = 3.14
except AttributeError as e:
print(e) # "Cannot modify attribute 'PI' on frozen namespace"
# This will also raise an AttributeError
try:
del Constants.E
except AttributeError as e:
print(e) # "Cannot delete attribute 'E' on frozen namespace"
# Cannot instantiate FrozenSpace classes
try:
instance = Constants()
except TypeError as e:
print(e) # "Cannot instantiate Constants..."
Installation
Install classicle: We're on pypi, so uv add classicle. If working directly on this repo, consider using the simplest-possible virtual environment.
Metadata
Release files for classicle 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| classicle-0.2.2.tar.gz | 21.9 kB | Without provenance | Details for classicle-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| classicle-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for classicle-0.2.2-py3-none-any.whl |
Total release size: 27.5 kB
Release files / classicle-0.2.2.tar.gz
| Download URL | classicle-0.2.2.tar.gz |
|---|---|
| Size | 21.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e439164c8a644871c129cac5d2eaaddc4690fcf76a0ec54b48361dfee87db77
|
|
BLAKE2b-256 checksum How to use checksums |
98017d22a824036fa26f740a63c5b2af2337d9985de8e7fd6a30343c855acecd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.3
|
Release files / classicle-0.2.2-py3-none-any.whl
| Download URL | classicle-0.2.2-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8685bf857d03a455df72f8ddbc482c5ee2dcf2b2e0b1eaeb89336a862f8fabad
|
|
BLAKE2b-256 checksum How to use checksums |
77994885bf560088cf36493ce8676bf71146e179d92f41ecbf48dc76f50a430b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.3
|
Security for classicle 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.