pytypeutil
Summary
A python library for variable type checker/validator/converter at run time.
Usage
Type Check
>>> from pytypeutil.type import Integer
>>> Integer(1).is_type()
True
>>> Integer(1.1).is_type()
False
Type Validation
>>> from pytypeutil.type import Integer
>>> Integer(1).validate()
>>> try:
... Integer(1.1).validate()
... except TypeError as e:
... print(e)
...
invalid value type: expected=INTEGER, actual=<type 'float'>
Type Conversion
convert
>>> from pytypeutil.type import Integer
>>> from pytypeutil import TypeConversionError
>>> Integer("1").convert()
1
>>> try:
... Integer(1.1).convert()
... except TypeConversionError as e:
... print(e)
...
failed to convert from float to INTEGER
try_convert
>>> from pytypeutil.type import Integer
>>> Integer("1").try_convert()
1
>>> print(Integer(1.1).try_convert())
None
force_convert
>>> from pytypeutil.type import Integer
>>> Integer("1").force_convert()
1
>>> Integer(1.1).force_convert()
1
For more information
More examples are available at http://pytypeutil.rtfd.io/en/latest/pages/reference/index.html
Features
Supported types are as follows:
bool
datetime
dict
int
- float
Real number
Infinite
Not a number
None
- str
null string
Type check/validate/convert results will be decided according to strict_level which can be passed to constructors. API reference can be found at the document.
Installation
pip install pytypeutil
Dependencies
Python 2.7+ or 3.3+
Test dependencies
Documentation
Metadata
Release files for pytypeutil 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytypeutil-0.0.1.tar.gz | 17.6 kB | Without provenance | Details for pytypeutil-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytypeutil-0.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for pytypeutil-0.0.1-py2.py3-none-any.whl |
Total release size: 44.2 kB
Release files / pytypeutil-0.0.1.tar.gz
| Download URL | pytypeutil-0.0.1.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb802a976d1601a1031d1c2ef085fa8b67022c384f650d8a90de0cf407dec373
|
|
BLAKE2b-256 checksum How to use checksums |
15026529770f8aec77bf424cbdf6ab1fe65d1db515a1c53ca020a73bbeee50bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pytypeutil-0.0.1-py2.py3-none-any.whl
| Download URL | pytypeutil-0.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 26.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
fbee0bc8a6494f9869fc4fd55611654a224d493f0960a3ca9cdd1ffeb2d530c0
|
|
BLAKE2b-256 checksum How to use checksums |
aec9d0fb1491a0beef768e6d8b4a4558ec640d1afb5ef2e05a9d764f283d9917
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pytypeutil 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.