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.5.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

TypeEnforcer-1.5.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: TypeEnforcer-1.5.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.5.0.tar.gz
Algorithm Hash digest
SHA256 aeaa24dee13982345945411a9fa1e8a66a2e0d218cf4e8fb9ebc4e544bfa3cdf
MD5 62c20f9b07992c20b4c2e2e791a4b9cf
BLAKE2b-256 cc0b1f2d8eac4683419d8ab89f0ebe0d105ec1b9f0b271dcee214bd08a703886

See more details on using hashes here.

File details

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

File metadata

  • Download URL: TypeEnforcer-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8fe7d379f2eca81556f2f18ca9c6efea7a0732976e25f9c11b0d9d76510ba920
MD5 5df6b4011ae24247ed9a8936d79043bc
BLAKE2b-256 ddcbabb048cddbfb27cc775a01256c60b9016b34784b879f8f6c06e5e8d368d1

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