## strict
Project description
strict
Python strict tag
pip install pystrict
Using @strict on classes can prevent serious errors by raising an exception when an instance has a variable created outside of init. Unfortunately, linters don't (cannot) always catch this. I can't express how much time this has saved me recently.
Using @strict on functions currently only checks type specifiers.
TODO:
@strict(runtime=True)
will check types at runtime and raise ValueError if a bad type is passed
Example: from pystrict import strict
# not allowed, missing type specifier
@strict
def foo(x: int, y):
...
# not allowed, missing type specifier in __init__
@strict
class Foo():
def __init__(self, x: int, y):
...
# not allowed, object modified outside of init
@strict
class Foo():
def __init__(self, x: int):
self.x = 1
z=[Foo(1)]
# oops...
z[0].y = 4
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
pystrict-1.1.tar.gz
(9.5 kB
view hashes)
Built Distribution
pystrict-1.1-py3-none-any.whl
(4.4 kB
view hashes)