{"id":13725413,"url":"https://github.com/ilevkivskyi/typing_inspect","last_synced_at":"2025-04-11T06:21:55.526Z","repository":{"id":37431749,"uuid":"89795544","full_name":"ilevkivskyi/typing_inspect","owner":"ilevkivskyi","description":"Runtime inspection utilities for Python typing module","archived":false,"fork":false,"pushed_at":"2024-08-13T21:13:00.000Z","size":78,"stargazers_count":356,"open_issues_count":25,"forks_count":36,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-31T15:34:51.437Z","etag":null,"topics":["introspection","python","python3","type-hints","typing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ilevkivskyi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-29T15:49:25.000Z","updated_at":"2025-03-29T06:16:02.000Z","dependencies_parsed_at":"2024-09-17T23:50:58.948Z","dependency_job_id":"3bcd23b8-c345-4860-bdb7-2a193c5164d2","html_url":"https://github.com/ilevkivskyi/typing_inspect","commit_stats":{"total_commits":77,"total_committers":18,"mean_commits":4.277777777777778,"dds":"0.36363636363636365","last_synced_commit":"fb640c7134facf22c118597af7a165ae8e27144a"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilevkivskyi%2Ftyping_inspect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilevkivskyi%2Ftyping_inspect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilevkivskyi%2Ftyping_inspect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilevkivskyi%2Ftyping_inspect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ilevkivskyi","download_url":"https://codeload.github.com/ilevkivskyi/typing_inspect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248352459,"owners_count":21089452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["introspection","python","python3","type-hints","typing"],"created_at":"2024-08-03T01:02:22.398Z","updated_at":"2025-04-11T06:21:55.508Z","avatar_url":"https://github.com/ilevkivskyi.png","language":"Python","readme":"Typing Inspect\n==============\n\n[![Build Status](https://travis-ci.org/ilevkivskyi/typing_inspect.svg)](https://travis-ci.org/ilevkivskyi/typing_inspect)\n\nThe ``typing_inspect`` module defines experimental API for runtime\ninspection of types defined in the Python standard ``typing`` module.\nWorks with ``typing`` version ``3.7.4`` and later. Example usage:\n\n```python\nfrom typing import Generic, TypeVar, Iterable, Mapping, Union\nfrom typing_inspect import is_generic_type\n\nT = TypeVar('T')\n\nclass MyCollection(Generic[T]):\n    content: T\n\nassert is_generic_type(Mapping)\nassert is_generic_type(Iterable[int])\nassert is_generic_type(MyCollection[T])\n\nassert not is_generic_type(int)\nassert not is_generic_type(Union[int, T])\n```\n\n**Note**: The API is still experimental, if you have ideas/suggestions please\nopen an issue on [tracker](https://github.com/ilevkivskyi/typing_inspect/issues).\nCurrently ``typing_inspect`` only supports latest version of ``typing``. This\nlimitation may be lifted if such requests will appear frequently.\n\nCurrently provided functions (see functions docstrings for examples of usage):\n* ``is_generic_type(tp)``:\n  Test if ``tp`` is a generic type. This includes ``Generic`` itself,\n  but excludes special typing constructs such as ``Union``, ``Tuple``,\n  ``Callable``, ``ClassVar``.\n* ``is_callable_type(tp)``:\n  Test ``tp`` is a generic callable type, including subclasses\n  excluding non-generic types and callables.\n* ``is_tuple_type(tp)``:\n  Test if ``tp`` is a generic tuple type, including subclasses excluding\n  non-generic classes.\n* ``is_union_type(tp)``:\n  Test if ``tp`` is a union type.\n* ``is_optional_type(tp)``:\n  Test if ``tp`` is an optional type (either ``type(None)`` or a direct union to it such as in ``Optional[int]``). Nesting and ``TypeVar``s are not unfolded/inspected in this process.\n* ``is_literal_type(tp)``:\n  Test if ``tp`` is a literal type.\n* ``is_final_type(tp)``:\n  Test if ``tp`` is a final type.\n* ``is_typevar(tp)``:\n  Test if ``tp`` represents a type variable.\n* ``is_new_type(tp)``:\n  Test if ``tp`` represents a distinct type.\n* ``is_classvar(tp)``:\n  Test if ``tp`` represents a class variable.\n* ``get_origin(tp)``:\n  Get the unsubscripted version of ``tp``. Supports generic types, ``Union``,\n  ``Callable``, and ``Tuple``. Returns ``None`` for unsupported types.\n* ``get_last_origin(tp)``:\n  Get the last base of (multiply) subscripted type ``tp``. Supports generic\n  types, ``Union``, ``Callable``, and ``Tuple``. Returns ``None`` for\n  unsupported types.\n* ``get_parameters(tp)``:\n  Return type parameters of a parameterizable type ``tp`` as a tuple\n  in lexicographic order. Parameterizable types are generic types,\n  unions, tuple types and callable types.\n* ``get_args(tp, evaluate=False)``:\n  Get type arguments of ``tp`` with all substitutions performed. For unions,\n  basic simplifications used by ``Union`` constructor are performed.\n  If ``evaluate`` is ``False`` (default), report result as nested tuple,\n  this matches the internal representation of types. If ``evaluate`` is\n  ``True``, then all type parameters are applied (this could be time and\n  memory expensive).\n* ``get_last_args(tp)``:\n  Get last arguments of (multiply) subscripted type ``tp``.\n  Parameters for ``Callable`` are flattened.\n* ``get_generic_type(obj)``:\n  Get the generic type of ``obj`` if possible, or its runtime class otherwise.\n* ``get_generic_bases(tp)``:\n  Get generic base types of ``tp`` or empty tuple if not possible.\n* ``typed_dict_keys(td)``:\n  Get ``TypedDict`` keys and their types, or None if ``td`` is not a typed dict.\n","funding_links":[],"categories":["Python","Code Inspection","Tools"],"sub_categories":["Working with types"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filevkivskyi%2Ftyping_inspect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filevkivskyi%2Ftyping_inspect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filevkivskyi%2Ftyping_inspect/lists"}