Skip to main content

## 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.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pystrict-1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pystrict-1.0.tar.gz.

File metadata

  • Download URL: pystrict-1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.21.0

File hashes

Hashes for pystrict-1.0.tar.gz
Algorithm Hash digest
SHA256 99001c22b6ed8925691b90d836656b938b11f24462f719eae73722b2a560ddfa
MD5 e3a18e585f7dec7bc0419d990fa093d3
BLAKE2b-256 251b1e49a8a370a8fef1e45c0e8c5e3baaf7239cea171c807e0d48c2bbdbc7ed

See more details on using hashes here.

File details

Details for the file pystrict-1.0-py3-none-any.whl.

File metadata

  • Download URL: pystrict-1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.21.0

File hashes

Hashes for pystrict-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e3565153ac469e8307fc431378bd0ec0acfcaee9cca6b006bf81e4b605174ab
MD5 c7abdce8782c53b1dbb64dc61316813f
BLAKE2b-256 d9bc880c557a6bcfdd6ff0cccb31c7199d8260a4fea3ef696c41202b2a19fbc3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page