enforce-with
This library makes it possible to enforce the usage of with keyword
Installation
pip install enforce-with
Usage
@enforce_with.enforce_with
Decorate your class with this decorator and it will no longer be possible to access the members of its instances unless you access them inside a with block. Example:
@enforce_with.enforce_with
class MyClass:
def __init__(self):
self.var = 10
def func(self):
pass
def __enter__(self):
print("entering")
return self
def __exit__(self, exc_type, exc_value, traceback):
print("exiting")
with MyClass() as obj:
obj.var # Ok
obj.func() # Ok
MyClass().var # Error
MyClass().func() # Error
Metadata
Release files for enforce-with 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| enforce_with-1.1.0.tar.gz | 1.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| enforce_with-1.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 3.4 kB
Release files / enforce_with-1.1.0.tar.gz
| Download URL | enforce_with-1.1.0.tar.gz |
|---|---|
| Size | 1.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5810777dc9d56aca503bb9391dcfe47a9a32274348f82747452deaf90f15ca3a
|
|
BLAKE2b-256 checksum How to use checksums |
8b0d899ef47a9dc8a532f2d5daf8f8e3d2ac29390d287c5c62169fa09455a1ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Release files / enforce_with-1.1.0-py2.py3-none-any.whl
| Download URL | enforce_with-1.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 2.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
80ecc5d58d4fb5e92daed42c4d3ccff9a060cd630a6a682f357bc8d59c4f4be5
|
|
BLAKE2b-256 checksum How to use checksums |
69d5b657338fcfc35b68191edeb05055ee0678d367afa2b47c5a1b8c6f574577
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|