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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
919e344c1b15b66411b04b7ec37e8dcc1c8e521080036107b15732ea6e34ac96
|
|
| MD5 |
f421a7722f1d97fce6264aa1c10b7148
|
|
| BLAKE2b-256 |
a51ebc5192cd3b69cc1006f69a4c6cae06039a2972bcffa1333fc82ef1055f0a
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dfaab3a7e14da4b72a32258df551583382f58bb08e2de379a631affc07ab4c5
|
|
| MD5 |
e884b36b78df7e1dce875fbb5d888033
|
|
| BLAKE2b-256 |
4c07f12249efef5048c58a4427297b9fc2732bf05a92770f27923ff09da3d53e
|