Declare final Python classes and methods at runtime.
Project description
runtime-final
Declare final Python classes and methods at runtime.
This module provides a decorator based interface to declare final
classes and methods. 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 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 User:
@final
def edit(self):
...
class AnotherUser(User):
def edit(self): # Raises RuntimeError
...
Documentation
For more details, see the documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file runtime_final-1.2.0-py3-none-any.whl.
File metadata
- Download URL: runtime_final-1.2.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a0688f9c95937133059c5349a7cfa274d8b5b90b9c45aa619cd4ab180d9516a
|
|
| MD5 |
06521235b68822a0307dce3fcb0eafff
|
|
| BLAKE2b-256 |
f842dab1472af7985d1c4d9a689d2fb8be433d7b8c5a829f357ca9c836896191
|