Type check Python types with support for nested lists and dictionaries.
[](https://gitlab.com/robjampar/type-checker/commits/master)
[](https://gitlab.com/robjampar/type-checker/commits/master)
## Installation
Type Checker is a Python package, and is compatible with `Python 3` only (for now). It can be installed through `pip`.
##### Pip
```
pip install type-checker
```
## Run the Unit Tests
To run the tests.
```
pip install pipenv
pipenv install --dev
pipenv run python -m pytest tests --cov=type_checker
```
## Docs
The documentation is public, and is generated using Sphinx.
[Type Checker Documentation](https://robjampar.gitlab.io/type-checker)
##### Build documentation
To build a local static HTML version of the documentation.
```
pip install pipenv
pipenv install sphinx
pipenv run sphinx-build docs ./public -b html
```
## Type Checking Example
``` python
from typing import Union
from type_checker import type_check
# the type defintion to check a value against
type_def = {
"hello": {
"world": int
},
"a_key": str,
"a_list": [
float
],
int: bool,
float: Union[bool, int]
}
# a valid test value
test_value = {
"hello": {
"world": 1
},
"a_key": "this_is_a_string",
"a_list": [
3.2,
4.7
5.9
],
5: True,
5.2: False,
5.7: 10
}
# use validate from the type_checker package to validate the value
is_valid = type_check(test_value, type_def)
print(f"is valid: {is_valid}")
```
``` text
$ python example.py
>>> is valid: True
```
Metadata
Release files for type-checker 1.0.2
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 |
|---|---|---|---|---|
| type-checker-1.0.2.tar.gz | 5.7 kB | Without provenance | Details for type-checker-1.0.2.tar.gz |
Release files / type-checker-1.0.2.tar.gz
| Download URL | type-checker-1.0.2.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31479d1a51ee4dde8b17a634e2329162a8586dc452723fe484651157747d119b
|
|
BLAKE2b-256 checksum How to use checksums |
3a4794e7f81589953ad1a2a33f8e4fb0f0987144ad7b395ddbc7f8dc61ca1415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.10
|
Security for type-checker 1.0.2
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.