amulet-runtime-final
Declare final Python classes and methods at runtime.
This module provides a decorator based interface to declare final classes and methods that are enforced at runtime.
This module is inspired by and is compatible with typing.final.
See PEP-591 for more details on this topic.
Installation
Python 3.6 or higher is required.
You can simply install this module from pip.
python -m pip install amulet-runtime-final
Usage
The main component of this module is the final decorator that
can be used to decorate classes and methods inside a class. As
such:
- Classes decorated with @final cannot be subclassed.
- Methods decorated with @final cannot be overriden in subclasses.
For example with classes:
from runtime_final import final
@final
class Foo:
...
class Bar(Foo): # Raises RuntimeError
...
And with methods:
from runtime_final import final
class Foo:
@final
def foo(self):
...
class Bar(Foo):
def foo(self): # Raises RuntimeError
...
And with other decorators:
from runtime_final import final
class Foo:
@final
@property
def foo(self):
...
@final
@staticmethod
def bar():
...
@final
@classmethod
def baz(cls):
...
class Bar(Foo):
@property
def foo(self): # Raises RuntimeError
...
@staticmethod
def bar(): # Raises RuntimeError
...
@classmethod
def baz(cls): # Raises RuntimeError
...
With property setters:
from runtime_final import final
class Foo:
@property
def foo(self):
...
# Note that the `final` decorator must only be applied to the last definition.
@final
@foo.setter
def foo(self, foo):
...
Metadata
Release files for amulet-runtime-final 1.1.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 |
|---|---|---|---|---|
| amulet-runtime-final-1.1.2.tar.gz | 6.0 kB | Without provenance | Details for amulet-runtime-final-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| amulet_runtime_final-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for amulet_runtime_final-1.1.2-py3-none-any.whl |
Total release size: 11.4 kB
Release files / amulet-runtime-final-1.1.2.tar.gz
| Download URL | amulet-runtime-final-1.1.2.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a20d063a5c1b438e36290753ecf04e76d18843be04205c3b9cba35eb2d1b3cce
|
|
BLAKE2b-256 checksum How to use checksums |
8f3ff75a35328e1b396fab6e6995b53ed2007dc6e70c9eeda4eec95a0d7be82f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Release files / amulet_runtime_final-1.1.2-py3-none-any.whl
| Download URL | amulet_runtime_final-1.1.2-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1739f32ce399e30cf63c223d3e1cdc9dcd2c52bdde36fb9879e2f88714aac7f6
|
|
BLAKE2b-256 checksum How to use checksums |
ceea5172c8003d2f22dc7f43718d18ef89f23dbba8308228857d10867cbb6316
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Security for amulet-runtime-final 1.1.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.