Skip to main content

enforce python type hints

Project description

Type Enforcer

add as a decorator to any python function to enforce type hints, turning python functions from dynamically to statically typed in the runtime.

Enforces python type hints. Parameters and returns that do not have explicit hints will be assumed to have types of typing.Any Supports basic type hinting operations, like Type[], Union[], and GenericAlias objects like dict[] and list[]

Supports recursive type checking in runtime! If you want to check that the contents in a deep nested datastructure match type hints, just enable recursive type checking with "recursive=True". Note that this significantly increases the computation necessary to run functions so it is advisable to only run this during the debugging phase of development. Note that as of now this only works with lists, tuples, sets, and dicts

Overall, best used with debugging

Install

  1. pip install TypeEnforcer
  2. from TypeEnforcer.TypeEnforcement.type_enforcer import TypeEnforcer
  3. @TypeEnforcer.enforcer

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

TypeEnforcer-1.4.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

TypeEnforcer-1.4.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file TypeEnforcer-1.4.0.tar.gz.

File metadata

  • Download URL: TypeEnforcer-1.4.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for TypeEnforcer-1.4.0.tar.gz
Algorithm Hash digest
SHA256 9553e08cc7f99c92b100da81950500a257b88edbaf75f4a7234cf278a57182bf
MD5 039021848c2aedc350d628c66f22ed9e
BLAKE2b-256 2cf47a9a4a774c71f4260f936066a0165ee9bf74e7e32e08e73a4371566c8348

See more details on using hashes here.

File details

Details for the file TypeEnforcer-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: TypeEnforcer-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for TypeEnforcer-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe7d2ccd37740d6b15bca0dc9867c437bd0c57c7c31849a9758042056334e74a
MD5 c4249ea86fbfc855cfd59521e1c6e812
BLAKE2b-256 6ef37fc195a27690ca8833c6e4a322b1e248d3d1a1f4da148740c0ee1421616a

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