No project description provided
Project description
Validation Decorators
Simple and fast type-checking and parameter validation.
Do you want to remove visual clutter in your python function? Do you want to check types fast without a lot of boilerplate?
Then this package is right for you.
Not convinced? Check out the following:
# classic
def foo(bar: int, message: str, some_additional_info: dict):
if not isinstance(bar, int):
raise TypeError(...)
if not isinstance(message, str):
raise TypeError(...)
if not isinstance(some_additional_info, dict):
raise TypeError(...)
# now begin to code...
# now
@validate_types(bar=(int,), message=(str,), some_additional_info=(dict,))
def foo(bar: int, message: str, , some_additional_info: dict):
# begin to code
If of course also supports multiple types:
from pathlib import Path
@validate_types(path=(str, Path), message=(str,))
def foo(path: str | Path, message: str):
# begin to code
Do you want to convert your input-types fast and without clutter?
def from_dict(dict_: dict):
return (dict_.get('bar'), dict_.get('message'), dict_.get('some_additional_info')), {}
@convert_with(from_dict)
def foo(bar: int, message:str, some_additional_info: dict):
...
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
Close
Hashes for decorator_validation-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc0be75c450ff71f2157b7d89a64b1f32cf395a6b08ac573958f6d5dc31b8b0a |
|
MD5 | 3669da6fddce3acea6324b36eee85fb9 |
|
BLAKE2b-256 | cbe965f0766c04ccaa76dadf309532110eea2db6e4fcad64e5ec951c16c2dae2 |
Close
Hashes for decorator_validation-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b79221dd8196447b5ee857dd8dc3a967581055a6fc6ffd55949627ff4a32001 |
|
MD5 | 4cf82d10938c72ccd4bdf0fdbca78a14 |
|
BLAKE2b-256 | fce275a28a9b431e5e9ed9b740c38ca81de199745f69c1d537a44b188c672be8 |