Final classes for Python 3
Project description
final_class
Final classes for python3.6+
.
Features
- No metaclass conflicts
- No runtime overhead
- No dependencies
- Type hints included, PEP-561 and PEP-591 compatible
- Designed to be as simple as possible
Why?
In languages like java
we have a nice way
to restrict subclassing any class by making it final
:
public final class SomeClass {
// ...
}
In python
we don't have such feature out of the box.
That's where final_class
library comes in!
This package works perfectly with @final
from typing
.
So, with final_class
you will have both type-checking and runtime checks.
Installation
pip install final_class
Usage
from final_class import final
@final
class Example(object): # You won't be able to subclass it!
...
class Error(Example): # Raises `TypeError`
...
More?
Do you want more? Check out:
License
MIT.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
final-class-0.2.0.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for final_class-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8029b75b96e8b50ae5d80a6b2b9683fabea94182861101ee185298d13292a322 |
|
MD5 | 1cc4b896d54dad29d2f742d261911919 |
|
BLAKE2b-256 | 474fd80eec39dba3f9f0d90d275d073de3907492f599e735075ee9fafbe7d77b |