{"id":594,"library":"typing-inspect","title":"Typing Inspect","description":"typing-inspect is a Python library providing runtime inspection utilities for types defined in the standard `typing` module. It is currently at version 0.9.0, is actively maintained, and compatible with Python 3.6 and later. It offers an easy-to-use API for advanced introspection of type hints.","status":"active","version":"0.9.0","language":"python","source_language":"en","source_url":"https://github.com/ilevkivskyi/typing_inspect","tags":["typing","introspection","runtime","type hints","static analysis"],"install":[{"cmd":"pip install typing-inspect","lang":"bash","label":"Latest stable version"}],"dependencies":[{"reason":"Required for extended type functionality.","package":"mypy-extensions","optional":false},{"reason":"Required for backporting new typing features to older Python versions.","package":"typing-extensions","optional":false},{"reason":"Required for core typing module functionality; specifically, this library works with typing version 3.7.4 and later.","package":"typing","optional":false}],"imports":[{"symbol":"is_generic_type","correct":"from typing_inspect import is_generic_type"},{"symbol":"get_args","correct":"from typing_inspect import get_args"},{"symbol":"get_origin","correct":"from typing_inspect import get_origin"},{"symbol":"is_union_type","correct":"from typing_inspect import is_union_type"},{"symbol":"is_optional_type","correct":"from typing_inspect import is_optional_type"}],"quickstart":{"code":"from typing import List, Union, Optional, TypeVar\nfrom typing_inspect import is_generic_type, get_args, get_origin, is_optional_type\n\nT = TypeVar('T')\n\nclass MyGeneric(List[T]):\n    pass\n\n# Example 1: Check if a type is generic\nassert is_generic_type(MyGeneric[int]) # This should be True\nassert not is_generic_type(int) # This should be False\n\n# Example 2: Get arguments of a type\nargs = get_args(List[str])\nassert args == (str,)\n\nunion_type = Union[int, str]\nunion_args = get_args(union_type)\nassert set(union_args) == {int, str}\n\n# Example 3: Get the origin of a type\norigin = get_origin(List[int])\nassert origin is list\n\n# Example 4: Check for optional types\nassert is_optional_type(Optional[int])\nassert not is_optional_type(int)\n\nprint(\"All quickstart assertions passed!\")\n","lang":"python","description":"This quickstart demonstrates basic usage of `typing-inspect` to check for generic types, retrieve type arguments and origins, and identify optional types. It covers `is_generic_type`, `get_args`, `get_origin`, and `is_optional_type`."},"warnings":[{"fix":"Always pin the `typing-inspect` version in your `requirements.txt` or `pyproject.toml` to ensure consistent behavior across deployments.","message":"The API of `typing-inspect` is still considered experimental. While generally stable, breaking changes might occur in future versions. Users should consult the changelog for specific updates.","severity":"breaking","affected_versions":"All versions"},{"fix":"Double-check your `pip install` command (`pip install typing-inspect`) and import statements (`import typing_inspect` or `from typing_inspect import ...`) to ensure you are using the correct package.","message":"There exists another, distinct library named `typing-inspection` (used by Pydantic) which provides similar runtime typing introspection tools. Ensure you are importing from `typing_inspect` (underscore) for this library, not `typing_inspection` (hyphen).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Avoid using `get_args(tp, evaluate=True)` in performance-critical paths unless strictly necessary. The default `evaluate=False` reports results as nested tuples and is generally more performant.","message":"The `get_args` function, when called with `evaluate=True`, can be computationally expensive in terms of both time and memory. This option performs all type parameter substitutions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your project's `typing` and `typing-extensions` dependencies are up-to-date or meet the minimum versions specified by `typing-inspect` (currently `typing>=3.7.4` and `typing-extensions>=3.7.4`).","message":"`typing-inspect` is designed to work with the latest versions of the Python `typing` module and `typing-extensions`. Older or specific versions of these dependencies might lead to unexpected behavior or unsupported types.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.9.0':27 '3.6':35 'activ':29 'advanc':47 'analysi':58 'api':45 'compat':32 'current':24 'defin':16 'easi':42 'easy-to-us':41 'hint':51,56 'inspect':2,5,12 'introspect':48,53 'later':37 'librari':9 'maintain':30 'modul':21 'offer':39 'provid':10 'python':8,34 'runtim':11,54 'standard':19 'static':57 'type':1,4,15,20,50,52,55 'typing-inspect':3 'use':44 'util':13 'version':26","created_at":"2026-03-28T15:20:34.580905+00:00","updated_at":"2026-03-28T15:20:34.580905+00:00","problems":[],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"0.9.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/ilevkivskyi/typing_inspect","docs":null,"changelog":null,"pypi":"https://pypi.org/project/typing-inspect/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}