Static typing compatibility layer for older versions of NumPy
Actively maintained. Last release 6 months ago, commits in 19 of the last 26 weeks. A safe choice.
pip install numpy-typing-compatnumpy-typing-compat
Overview
This package provides version-specific boolean constants that allow library authors to
write NumPy-version-dependent static type annotations. Similar to how you might use
if sys.version_info >= (3, 12): for Python version checks, numpy-typing-compat
enables static type-checkers to understand which NumPy version is being used and apply
appropriate type annotations.
[!TIP]
numpy-typing-compatis intended as a helper package for theoptypelibrary, which provides high-level typing utilities for annotating NumPy operations. In most situations, it is recommended to useoptypeinstead ofnumpy-typing-compat. See theoptype.numpydocumentation for more details.
Installation and Versioning
The numpy-typing-compat packages are available on PyPI and conda-forge.
Modern package managers such as uv and
pixi will automatically install the
appropriate version of numpy-typing-compat that matches your installed NumPy version,
in order to satisfy the numpy dependency restrictions of numpy-typing-compat.
[!WARNING] Legacy package managers such as
pipdon't always respect dependency restrictions. Running will automatically upgrade to the correct version. If for some reason you need to use , then be sure to manually install the correct version of that matches your installed NumPy version. Running will tell you whether the installed and versions are compatible.