Skip to main content

## strict

Project description

Build Status

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 only checks type specifiers.

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

# mypy and pytest won't check this
def evil():
    return list({'a':Foo(1)}.values())

z = evil()
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.3.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

pystrict-1.3-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pystrict-1.3.tar.gz
Algorithm Hash digest
SHA256 09d1c236850667510684e259416445309ae68bbf7ac99570efa80fcef750481a
MD5 856914a3a84b01ce57691242fc40931f
BLAKE2b-256 1430405f438e8438192bd25660d1869b08af22faa260a8aeadab37be6c1e7d45

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pystrict-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 548c6fb417753f15933f628633fc808f01795ca8048623aae064f5c7eaa0ac42
MD5 98acdb657f819875def0eadbdf8cba2e
BLAKE2b-256 9fc609a4294888d43cbe76e115cd0992fe9f84298c76b146e7864e0ff002b20c

See more details on using hashes here.

Supported by

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