Typish is a Python library that extends Python's native `typing` module, offering advanced functionality for thorough type checks, instance checks considering generics, and typesafe duck-typing. It provides utilities for introspection of type hints, such as retrieving origins and arguments of generic types, and determining optionality. Currently at version 1.9.3, it maintains a regular release cadence with a focus on bug fixes and compatibility improvements across Python versions.
pip install typishVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates `typish.instance_of` for type-safe checks with generics, `typish.get_origin` for inspecting generic types, and `typish.is_optional_type` for identifying optional type hints. It also shows `typish.Literal` for broad compatibility of literal types.
Upgrade to `typish` version 1.9.2 or newer to ensure correct behavior with modern Python type hints. Alternatively, avoid using `get_origin` with directly parameterized built-in collections on affected Python versions.
Upgrade to `typish` version 1.8.0 or newer for robust `instance_of` checks with `Literal`.
Update to `typish` version 1.8.0 or later to resolve issues with `get_origin` and shadowed class names.
Be mindful of your target Python versions when using complex type hints. When backporting or ensuring broad compatibility, use `from typish import Literal` and similar constructs, as `typish` often provides backward-compatible wrappers for newer `typing` features. Refer to Python's `typing` module documentation for version-specific syntax.