Name | typing-utilities JSON |
Version |
0.0.6
JSON |
| download |
home_page | None |
Summary | Runtime reflection and validation of types and generics. |
upload_time | 2025-07-30 08:56:43 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
windows
linux
generics
typing
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
[](https://github.com/apmadsen/typing-utilities/actions/workflows/python-test.yml)
[](https://github.com/apmadsen/typing-utilities/actions/workflows/python-test-coverage.yml)
[](https://github.com/apmadsen/typing-utilities/releases)


[](https://pepy.tech/projects/typing-utilities)
# typing-utilities: Runtime reflection and validation of types and generics.
typing-utilities extends Python with the ability to check instances and types of generic types and unions introduced in the `typing` module.
Following is a small example of two of the most usable functions `issubclass_typing` and `isinstance_typing`, but a lot more is to be found in the API section further down...
## Example:
```python
from typing import Generic, TypeVar
from typingutils import issubclass_typing, isinstance_typing
T = TypeVar('T')
class Class1(Generic[T]):
pass
class_type1 = Class1[str]
class_type2 = Class1[int]
issubclass_typing(class_type1, class_type2) # => False
# next line will fail
issubclass(class_type1, class_type2) # => TypeErrorr: Subscripted generics cannot be used with class and instance checks
class_inst1 = class_type1()
class_inst2 = class_type2()
isinstance_typing(class_inst1, class_type1) # => True
isinstance_typing(class_inst1, class_type2) # => False
isinstance_typing(class_inst2, class_type2) # => True
isinstance_typing(class_inst2, class_type1) # => False
# next line will fail
isinstance(class_inst1, class_type1) # => TypeError: Subscripted generics cannot be used with class and instance checks
```
## Conventions
This project differs from Python and other projects in some aspects:
- Generic subscripted types like `list[str]` are always a subclass of its base type `list` whereas the opposite is not true.
- Any type is a subclass of `type[Any]`.
- `type[Any]` is not an instance of `type[Any]`.
- Builtin types and `typing` types are interchangeable, i.e. `list[T]` is interchangeable with `typing.List[T]` etc.
## What's not included
### Generic types
It's not the goal of this project to deliver generic types such as generically enforced lists and dicts.
## Full documentation
[Go to documentation](https://github.com/apmadsen/typing-utilities/blob/main/docs/documentation.md)
## Other similar projects
There are other similar projects out there like [typing-utils](https://pypi.org/project/typing-utils/) and [runtype](https://pypi.org/project/runtype/), and while typing-utils is outdated and pretty basic, runtype is very similar to `typing-utilities` when it comes to validation.
Raw data
{
"_id": null,
"home_page": null,
"name": "typing-utilities",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "windows, linux, generics, typing",
"author": null,
"author_email": "Anders Madsen <anders.madsen@alphavue.com>",
"download_url": "https://files.pythonhosted.org/packages/aa/5b/540486537b448fcc0277f6be05c7cbc9cf98fe15eb08802fa72a9b29dd9e/typing_utilities-0.0.6.tar.gz",
"platform": null,
"description": "[](https://github.com/apmadsen/typing-utilities/actions/workflows/python-test.yml)\n[](https://github.com/apmadsen/typing-utilities/actions/workflows/python-test-coverage.yml)\n[](https://github.com/apmadsen/typing-utilities/releases)\n\n\n[](https://pepy.tech/projects/typing-utilities)\n\n# typing-utilities: Runtime reflection and validation of types and generics.\n\ntyping-utilities extends Python with the ability to check instances and types of generic types and unions introduced in the `typing` module.\n\nFollowing is a small example of two of the most usable functions `issubclass_typing` and `isinstance_typing`, but a lot more is to be found in the API section further down...\n\n## Example:\n\n```python\nfrom typing import Generic, TypeVar\nfrom typingutils import issubclass_typing, isinstance_typing\n\nT = TypeVar('T')\n\nclass Class1(Generic[T]):\n pass\n\nclass_type1 = Class1[str]\nclass_type2 = Class1[int]\n\nissubclass_typing(class_type1, class_type2) # => False\n\n# next line will fail\nissubclass(class_type1, class_type2) # => TypeErrorr: Subscripted generics cannot be used with class and instance checks\n\nclass_inst1 = class_type1()\nclass_inst2 = class_type2()\n\nisinstance_typing(class_inst1, class_type1) # => True\nisinstance_typing(class_inst1, class_type2) # => False\nisinstance_typing(class_inst2, class_type2) # => True\nisinstance_typing(class_inst2, class_type1) # => False\n\n# next line will fail\nisinstance(class_inst1, class_type1) # => TypeError: Subscripted generics cannot be used with class and instance checks\n```\n\n## Conventions\n\nThis project differs from Python and other projects in some aspects:\n\n- Generic subscripted types like `list[str]` are always a subclass of its base type `list` whereas the opposite is not true.\n- Any type is a subclass of `type[Any]`.\n- `type[Any]` is not an instance of `type[Any]`.\n- Builtin types and `typing` types are interchangeable, i.e. `list[T]` is interchangeable with `typing.List[T]` etc.\n\n## What's not included\n\n### Generic types\n\nIt's not the goal of this project to deliver generic types such as generically enforced lists and dicts.\n\n## Full documentation\n\n[Go to documentation](https://github.com/apmadsen/typing-utilities/blob/main/docs/documentation.md)\n\n## Other similar projects\n\nThere are other similar projects out there like [typing-utils](https://pypi.org/project/typing-utils/) and [runtype](https://pypi.org/project/runtype/), and while typing-utils is outdated and pretty basic, runtype is very similar to `typing-utilities` when it comes to validation.\n",
"bugtrack_url": null,
"license": null,
"summary": "Runtime reflection and validation of types and generics.",
"version": "0.0.6",
"project_urls": {
"repository": "https://github.com/apmadsen/typing-utilities"
},
"split_keywords": [
"windows",
" linux",
" generics",
" typing"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "2494d671062d80b300e3e8dde3219af42c99271772e7c9bd888968a8d3ceedb4",
"md5": "de7e98b5057a345d604bf79ba5523eb8",
"sha256": "68fd63d61d063f5d2df6a549574a15a2df7a1360b0865bf6d0486be50c07233b"
},
"downloads": -1,
"filename": "typing_utilities-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "de7e98b5057a345d604bf79ba5523eb8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 13192,
"upload_time": "2025-07-30T08:56:41",
"upload_time_iso_8601": "2025-07-30T08:56:41.909360Z",
"url": "https://files.pythonhosted.org/packages/24/94/d671062d80b300e3e8dde3219af42c99271772e7c9bd888968a8d3ceedb4/typing_utilities-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "aa5b540486537b448fcc0277f6be05c7cbc9cf98fe15eb08802fa72a9b29dd9e",
"md5": "01474e7f816db1177fcb26bc59e6921b",
"sha256": "89ca2f4911c0618b4347abd9bf04ea1365fc6f0f3d8d97eba804a7302919d388"
},
"downloads": -1,
"filename": "typing_utilities-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "01474e7f816db1177fcb26bc59e6921b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 16517,
"upload_time": "2025-07-30T08:56:43",
"upload_time_iso_8601": "2025-07-30T08:56:43.385255Z",
"url": "https://files.pythonhosted.org/packages/aa/5b/540486537b448fcc0277f6be05c7cbc9cf98fe15eb08802fa72a9b29dd9e/typing_utilities-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-30 08:56:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "apmadsen",
"github_project": "typing-utilities",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"tox": true,
"lcname": "typing-utilities"
}