constattr
Enforce your class constants in python.
The only constant in life is change
Heraclitus
Not anymore!
Didacus I. Granatensis
Usage
Decorate your class with constclassattrs and when a class attribute that is uppercase
is re-assigned the exception ConstantAssignmentError will be raised.
Example
from constattr import constclassattrs
@constclassattrs
class Example1:
MY_CONST1 = '1'
MY_CONST2 = '2'
# This will raise the ConstAssignmentError exception
Example1.MY_CONST1 = 'new value for the constant'
Limitations
If your class has a metaclass defined, it will work, but in case of conflict the MRO in the metaclass will choose the ConstantEnforcerMeta class first.
Dependencies
This package has no dependencies.
License
MIT license, but if you need any other contact me.
Metadata
Release files for constattr 0.0.8
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 |
|---|---|---|---|---|
| constattr-0.0.8.tar.gz | 4.2 kB | Without provenance | Details for constattr-0.0.8.tar.gz |
Release files / constattr-0.0.8.tar.gz
| Download URL | constattr-0.0.8.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b9350b6d34c4f64d5bd4d265dc537ec46137cb691643e0a0de6369a4f59d6c2
|
|
BLAKE2b-256 checksum How to use checksums |
689fe51a1ed8f0e41fd5b35ca8a73def0b85d2e80c655d03ce1dc6622ebdf127
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Security for constattr 0.0.8
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.