{"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,"last_verified":"2026-05-12T16:24:19.434Z","next_check":"2026-06-26T00:00:00.000Z","problems":[],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"0.9.0","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.8,"disk_size":"18.2M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.8,"disk_size":"18.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0.02,"mem_mb":1.8,"disk_size":"19M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":1.8,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":2,"disk_size":"20.1M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2,"disk_size":"20.1M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0.05,"mem_mb":2,"disk_size":"21M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":2,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":1.9,"disk_size":"11.9M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":1.9,"disk_size":"11.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0.05,"mem_mb":1.9,"disk_size":"12M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":1.9,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":2.2,"disk_size":"11.7M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":2.2,"disk_size":"11.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0.05,"mem_mb":2,"disk_size":"12M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":2,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":1.7,"disk_size":"17.7M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.7,"disk_size":"17.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.8,"import_time_s":0.02,"mem_mb":1.7,"disk_size":"18M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":1.7,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}