Skip to main content

No project description provided

Project description

strictTyping

Decorator to enforce the correct types for method invocation and definition.


The decorator will help you to validate if the input parameters have a valid type.

With enforce=True (default) it will also enforce that the function has a return type and all parameters have types defined.

Help

Works for builtins (int, floats, str, bool), classes, Union, Optional...

Currently only supports toplevel types. Not supported are nested types like "list[str]"

Only the definition of the function results type is checked, not the actual result type.

Installation

Install using pip install -U strictTyping

Examples

from strictTyping import strictTyping

# full valid function
@strictTyping()
def myFunction(argument: int) -> str:
	return str(argument)
	
myFunction(5) # succeeds
myFunction(5.0) # ValueError

# not enforcing typing
@strictTyping(enforce = False)
def myFunction(argument, argument2: float):
	return str(argument), str(argument2)
	
myFunction(5, 5.0) # succeeds
myFunction(5.0, 5) # ValueError

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

strictTyping-0.1.4.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

strictTyping-0.1.4-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file strictTyping-0.1.4.tar.gz.

File metadata

  • Download URL: strictTyping-0.1.4.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for strictTyping-0.1.4.tar.gz
Algorithm Hash digest
SHA256 919e344c1b15b66411b04b7ec37e8dcc1c8e521080036107b15732ea6e34ac96
MD5 f421a7722f1d97fce6264aa1c10b7148
BLAKE2b-256 a51ebc5192cd3b69cc1006f69a4c6cae06039a2972bcffa1333fc82ef1055f0a

See more details on using hashes here.

File details

Details for the file strictTyping-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: strictTyping-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for strictTyping-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0dfaab3a7e14da4b72a32258df551583382f58bb08e2de379a631affc07ab4c5
MD5 e884b36b78df7e1dce875fbb5d888033
BLAKE2b-256 4c07f12249efef5048c58a4427297b9fc2732bf05a92770f27923ff09da3d53e

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