A lightweight decorator for enforcing type hints at runtime.
Project description
Enforcer
Enforcer is a lightweight Python decorator for enforcing type hints at runtime. It ensures that function arguments match their specified types, providing a simple and intuitive solution for runtime type validation.
Features
- Enforce type hints at runtime for functions.
- Lightweight and dependency-free.
- Compatible with Python 3.7 and later.
Installation
You can install Enforcer via pip (coming soon):
from enforcer import enforce_types
@enforce_types
def greet(name: str, age: int):
print(f"{name} is {age} years old!")
# Valid call
greet("Alice", 25)
# Invalid call
greet("Alice", "twenty-five") # Raises TypeError
Contributing
Contributions are welcome! Please check the issues for tasks that need help.
Project details
Release history Release notifications | RSS feed
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 static_type_enforcer-0.1.0.tar.gz.
File metadata
- Download URL: static_type_enforcer-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9f96c1cf5c0fc08571629564e6f4e2bdf7a60fdbf11f61102e96346650b2365
|
|
| MD5 |
d6d00ea7a22c238831f90a6d85717e2e
|
|
| BLAKE2b-256 |
33d66461ab67f26cd19c4571d85d63b0e41384c950ac2aa826be2bb77b247b71
|
File details
Details for the file static_type_enforcer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: static_type_enforcer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2307a6e1d7f98af1790d023b0512f4171688a510c2b3855b1f00c096de84d3d5
|
|
| MD5 |
3d499e2ae00b5070883587bb9a921b08
|
|
| BLAKE2b-256 |
d10bab8576fb88551a2b9e1877beee27ed732ba8584c92d515338d4a54f948cc
|