| Name | simtypes JSON |
| Version |
0.0.2
JSON |
| download |
| home_page | None |
| Summary | Type checking in runtime without stupid games |
| upload_time | 2025-10-14 10:36:11 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.8 |
| license | None |
| keywords |
type
check
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|

[](https://pepy.tech/project/simtypes)
[](https://pepy.tech/project/simtypes)
[](https://coveralls.io/github/pomponchik/simtypes?branch=main)
[](https://github.com/boyter/scc/)
[](https://hitsofcode.com/github/pomponchik/simtypes/view?branch=main)
[](https://github.com/pomponchik/simtypes/actions/workflows/tests_and_coverage.yml)
[](https://pypi.python.org/pypi/simtypes)
[](https://badge.fury.io/py/simtypes)
[](http://mypy-lang.org/)
[](https://github.com/astral-sh/ruff)
[](https://deepwiki.com/pomponchik/simtypes)
Python type checking tools are usually very complex. In this case, we have thrown out almost all the places where there is a lot of complexity, and left only the most obvious and necessary things for runtime.
## Table of contents
- [**Why?**](#why)
- [**Installation**](#installation)
- [**Usage**](#usage)
## Why?
It's been a long time since static type checking tools like [`mypy`](https://github.com/python/mypy) for `Python` have been available, and they've become very complex. The typing system has also become noticeably more complicated, providing us with more and more new types of annotations, new syntax and other tools. It seems that `Python` devs procrastinate endlessly, postponing all the really important [`CPyhton`](https://github.com/python/cpython) improvements in order to add more garbage to [`typing`](https://docs.python.org/3/library/typing.html).
A separate difficulty arises for those who try to use type annotations in runtime. Many data types make sense only in the context of static validation, and there is no way to verify these aspects in runtime. And some checks, although theoretically possible, would be extremely expensive. For example, to verify the validity of annotation `List[int]` in relation to a list, you would need to go through all its objects linearly to make sure that none of them violates the contract from the annotation.
So, why do we need this package? There is only one function where you can pass a type or a type annotation + a specific value, and you will find out if one corresponds to the other. That's it! You can use this feature as a support when creating runtime type checking tools, however, we do not offer these tools here. You decide for yourself whether to wrap this function in syntactic sugar like decorators with automatic type checking.
Also, we are not trying to cover the whole chasm of semantics that, for example, `mypy` can track. Our approach is to make type checking as stupid as possible. This is the only way to avoid the stupid typing games that complex tools impose on us.
What exactly does this library support:
- The basis of everything is the simplest type checking via [`isinstance`](https://docs.python.org/3/library/functions.html#isinstance). If you don't use any special types from [`typing`](https://docs.python.org/3/library/typing.html), expect direct type matching.
- [`Union`](https://docs.python.org/3/library/typing.html#typing.Union) support. You can combine the two types through a logical OR.
- Checking the [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional) type and `None` as an annotation.
- Using [`Any`](https://docs.python.org/3/library/typing.html#typing.Any) annotation.
And that's what's not here:
- Supports types with complex semantics from the [`typing`](https://docs.python.org/3/library/typing.html) module.
- Checking the contents of collections. Collections are checked only for the base type.
- Support for string annotations.
If you need more complex semantics, use static validation tools. If you need strange and expensive runtime checks that try to confuse static semantics by adding thousands of exceptions, use other runtime tools. Use this library if you need a MINIMUM.
## Installation
You can install [`simtypes`](https://pypi.python.org/pypi/simtypes) using pip:
```bash
pip install simtypes
```
You can also quickly try out this and other packages without having to install using [instld](https://github.com/pomponchik/instld).
## Usage
Import the `check` function:
```python
from simtypes import check
```
And pass there 2 arguments, a type or type annotation + value:
```python
print(check(int, 1))
#> True
print(check(str, 1))
#> False
print(check(Any, 1))
#> True
print(check(Any, 'kek'))
#> True
print(check(List, 1))
#> False
print(check(List, [1]))
#> True
print(check(List[int], [1]))
#> True
print(check(List[int], ['kek'])) # Attention! The tool does not check the contents of the list in runtime.
#> True
print(check(Optional[int], 1))
#> True
print(check(Optional[int], None))
#> True
print(check(Optional[str], 1))
#> False
print(check(None, 1))
#> False
print(check(None, None))
#> True
```
> ↑ As you can see, the function returns `True` or `False`, depending on whether the value matches its annotation.
Raw data
{
"_id": null,
"home_page": null,
"name": "simtypes",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "type check",
"author": null,
"author_email": "Evgeniy Blinov <zheni-b@yandex.ru>",
"download_url": "https://files.pythonhosted.org/packages/7b/c6/109762c0226b05f004e3a53137f8de2936b2282862e28760968a713b73fd/simtypes-0.0.2.tar.gz",
"platform": null,
"description": "\n\n[](https://pepy.tech/project/simtypes)\n[](https://pepy.tech/project/simtypes)\n[](https://coveralls.io/github/pomponchik/simtypes?branch=main)\n[](https://github.com/boyter/scc/)\n[](https://hitsofcode.com/github/pomponchik/simtypes/view?branch=main)\n[](https://github.com/pomponchik/simtypes/actions/workflows/tests_and_coverage.yml)\n[](https://pypi.python.org/pypi/simtypes)\n[](https://badge.fury.io/py/simtypes)\n[](http://mypy-lang.org/)\n[](https://github.com/astral-sh/ruff)\n[](https://deepwiki.com/pomponchik/simtypes)\n\n\nPython type checking tools are usually very complex. In this case, we have thrown out almost all the places where there is a lot of complexity, and left only the most obvious and necessary things for runtime.\n\n\n## Table of contents\n\n- [**Why?**](#why)\n- [**Installation**](#installation)\n- [**Usage**](#usage)\n\n\n## Why?\n\nIt's been a long time since static type checking tools like [`mypy`](https://github.com/python/mypy) for `Python` have been available, and they've become very complex. The typing system has also become noticeably more complicated, providing us with more and more new types of annotations, new syntax and other tools. It seems that `Python` devs procrastinate endlessly, postponing all the really important [`CPyhton`](https://github.com/python/cpython) improvements in order to add more garbage to [`typing`](https://docs.python.org/3/library/typing.html).\n\nA separate difficulty arises for those who try to use type annotations in runtime. Many data types make sense only in the context of static validation, and there is no way to verify these aspects in runtime. And some checks, although theoretically possible, would be extremely expensive. For example, to verify the validity of annotation `List[int]` in relation to a list, you would need to go through all its objects linearly to make sure that none of them violates the contract from the annotation.\n\nSo, why do we need this package? There is only one function where you can pass a type or a type annotation + a specific value, and you will find out if one corresponds to the other. That's it! You can use this feature as a support when creating runtime type checking tools, however, we do not offer these tools here. You decide for yourself whether to wrap this function in syntactic sugar like decorators with automatic type checking.\n\nAlso, we are not trying to cover the whole chasm of semantics that, for example, `mypy` can track. Our approach is to make type checking as stupid as possible. This is the only way to avoid the stupid typing games that complex tools impose on us.\n\nWhat exactly does this library support:\n\n- The basis of everything is the simplest type checking via [`isinstance`](https://docs.python.org/3/library/functions.html#isinstance). If you don't use any special types from [`typing`](https://docs.python.org/3/library/typing.html), expect direct type matching.\n- [`Union`](https://docs.python.org/3/library/typing.html#typing.Union) support. You can combine the two types through a logical OR.\n- Checking the [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional) type and `None` as an annotation.\n- Using [`Any`](https://docs.python.org/3/library/typing.html#typing.Any) annotation.\n\nAnd that's what's not here:\n\n- Supports types with complex semantics from the [`typing`](https://docs.python.org/3/library/typing.html) module.\n- Checking the contents of collections. Collections are checked only for the base type.\n- Support for string annotations.\n\nIf you need more complex semantics, use static validation tools. If you need strange and expensive runtime checks that try to confuse static semantics by adding thousands of exceptions, use other runtime tools. Use this library if you need a MINIMUM.\n\n\n## Installation\n\nYou can install [`simtypes`](https://pypi.python.org/pypi/simtypes) using pip:\n\n```bash\npip install simtypes\n```\n\nYou can also quickly try out this and other packages without having to install using [instld](https://github.com/pomponchik/instld).\n\n\n## Usage\n\nImport the `check` function:\n\n```python\nfrom simtypes import check\n```\n\nAnd pass there 2 arguments, a type or type annotation + value:\n\n```python\nprint(check(int, 1))\n#> True\nprint(check(str, 1))\n#> False\nprint(check(Any, 1))\n#> True\nprint(check(Any, 'kek'))\n#> True\nprint(check(List, 1))\n#> False\nprint(check(List, [1]))\n#> True\nprint(check(List[int], [1]))\n#> True\nprint(check(List[int], ['kek'])) # Attention! The tool does not check the contents of the list in runtime.\n#> True\nprint(check(Optional[int], 1))\n#> True\nprint(check(Optional[int], None))\n#> True\nprint(check(Optional[str], 1))\n#> False\nprint(check(None, 1))\n#> False\nprint(check(None, None))\n#> True\n```\n\n> \u2191 As you can see, the function returns `True` or `False`, depending on whether the value matches its annotation.\n",
"bugtrack_url": null,
"license": null,
"summary": "Type checking in runtime without stupid games",
"version": "0.0.2",
"project_urls": {
"Source": "https://github.com/pomponchik/simtypes",
"Tracker": "https://github.com/pomponchik/simtypes/issues"
},
"split_keywords": [
"type",
"check"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "488fd7e6a9c90f1876c8efcb2009b10c36bdb5ac49fbb3a4c7f6fd74d0ad543d",
"md5": "0fddf851510392ba3ae1cf56b3a4910d",
"sha256": "26304892841d5d8712302122b4addcd74bfa981f119c534b8d74c017ffb48611"
},
"downloads": -1,
"filename": "simtypes-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0fddf851510392ba3ae1cf56b3a4910d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 5120,
"upload_time": "2025-10-14T10:36:10",
"upload_time_iso_8601": "2025-10-14T10:36:10.414403Z",
"url": "https://files.pythonhosted.org/packages/48/8f/d7e6a9c90f1876c8efcb2009b10c36bdb5ac49fbb3a4c7f6fd74d0ad543d/simtypes-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7bc6109762c0226b05f004e3a53137f8de2936b2282862e28760968a713b73fd",
"md5": "b7c8800864f6ad17398eaf31a8b8aa69",
"sha256": "488b3ca2b56654f5deddf5c81048c043afa57adf0ec3c7bc404ecc50b03e21be"
},
"downloads": -1,
"filename": "simtypes-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "b7c8800864f6ad17398eaf31a8b8aa69",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6922,
"upload_time": "2025-10-14T10:36:11",
"upload_time_iso_8601": "2025-10-14T10:36:11.566327Z",
"url": "https://files.pythonhosted.org/packages/7b/c6/109762c0226b05f004e3a53137f8de2936b2282862e28760968a713b73fd/simtypes-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-14 10:36:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pomponchik",
"github_project": "simtypes",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "simtypes"
}