Decorator which checks whether the function is called with the correct type of parameters
Project description
Strong Typing
Decorator which checks whether the function is called with the correct type of parameters.
And raises TypeMisMatch if the used parameters in a function call where invalid.
See _test_typing.py_ for more informations.
But why??
I really love python and his freedom but with the new option of adding type hints I wanted to get rid of writing
if isinstance(value, whatever)
in my programs.In a bigger project it happened that some developers used a really tiny IDE and others a more advanced one which highlighted typing issues. And there the trouble began, we had a bug and after a longer debugging session we found out that the issue was a wrong type of an argument, it doesn't crashed the program but the output was totally not what we expected.
And this is the reason why I created this package.
Getting Started
As normal decorator
@match_typing
def foo_bar(a: str, b: int, c: list):
...
as class method decorator
class Foo:
...
@match_typing
def foo_bar(self, a: int):
...
Tested for Versions
- 3.6, 3.7, 3.8
Prerequisites
- pytest
Installing
- python setup.py install
- pip install git+https://github.com/FelixTheC/strongtyping.git
Running the tests
- python test_typing.py
Versioning
- For the versions available, see the tags on this repository.
Authors
- Felix Eisenmenger - Initial work
License
- This project is licensed under the MIT License - see the LICENSE.md file for details
Special thanks
- Thanks to Ruud van der Ham for helping me improve my code
- And all how gave me Feedback in the Pythonista Cafe
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
File details
Details for the file strongtyping-1.1.5.tar.gz
.
File metadata
- Download URL: strongtyping-1.1.5.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6903e620657c3e28df82fbf3618ef4762347605d10fc4b96caf3ca4e8954050 |
|
MD5 | 88b4240668b7e5f7c54214d58cc5aafb |
|
BLAKE2b-256 | f9b2bc879a7d51c604aae1a45f7442cbaa8b254463a66f78b38ddad7876e480c |
File details
Details for the file strongtyping-1.1.5-py3-none-any.whl
.
File metadata
- Download URL: strongtyping-1.1.5-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a0199d4fd4bdae2c6db0b0c177eb202b97d614c8a3e962a0055cd34fba78254 |
|
MD5 | 8a67db751e0fd6ac8b8ada109e357ea4 |
|
BLAKE2b-256 | d8faab95e93cc53af97e8f278331787239879cad3bb2a222f59ff2e4d6681d9b |