numpy-typing-compat
Static typing compatibility layer for older versions of NumPy
Decision gist · record as of 2026-08-14
Yes, if you are a library author supporting multiple NumPy versions and need static type-checkers to understand version-specific type differences. Use modern package managers (uv, pixi) to avoid manual version management. Not necessary for applications using a single NumPy version or if you rely on optype for higher-level typing utilities.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.12 or later.
- The installed version of numpy-typing-compat must match your NumPy version—modern package managers handle this automatically, but pip requires manual version alignment.
- Low install friction with a single runtime dependency on numpy.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause permissive license allows use in most projects without significant restrictions.
last release 2026-06-02 (73 days) · last repo commit 2026-08-14 · 6 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,920,133 downloads/mo, #2,452 on PyPI
Alternatives
Verify before relying
pip install numpy-typing-compat
from numpy_typing_compat import NUMPY_GE_2_1, StringDType
if NUMPY_GE_2_1:
dtype = StringDType()
else:
dtype = None- How well mypy and pyright actually support Literal-based version conditions in practice beyond the documented 'limited support'
- Whether the package is actively used by optype or other production libraries beyond its intended helper role
What it is and what it does
numpy-typing-compat is a compatibility layer that lets you write NumPy type annotations that adapt to the installed NumPy version. It provides version-specific boolean constants (like NUMPY_GE_2_1) and type aliases (StringDType, ABCPolyBase, LiteralTrue, LiteralFalse) that static type-checkers can understand, similar to how you'd use sys.version_info for Python version checks. This is particularly useful for library authors who need to support multiple NumPy versions while maintaining accurate type hints.
The package is tightly coupled to NumPy versions—each release targets a specific NumPy minor version range (e.g., 20260602.2.5 targets numpy >=2.4,<2.5). Modern package managers like uv and pixi automatically install the correct version, but pip users must manually ensure alignment. The package is actively maintained and designed as a helper for the optype library, though it can be used directly when you need fine-grained version-aware typing.
Use it for
- Library authors supporting multiple NumPy versions who need type-checkers to understand version-specific APIs without runtime overhead
- Conditional type annotations for NumPy 2.0+ features like StringDType that weren't available in earlier versions
- Handling NumPy 2.1+ generic type changes (ABCPolyBase) while maintaining backward compatibility with older versions
- Type-safe use of NumPy 2.2+ bool scalar generics (LiteralTrue, LiteralFalse) across version boundaries
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are a library author supporting multiple NumPy versions and need static type-checkers to understand version-specific type differences.
Use modern package managers (uv, pixi) to avoid manual version management. Not necessary for applications using a single NumPy version or if you rely on optype for higher-level typing utilities.
Install
numpy-typing-compat on PyPI
Before you install
Low install friction with a single runtime dependency on numpy. Actively maintained as of 2026-08-14 with recent releases. Requires Python 3.12 or later and is designed to work with modern package managers like uv and pixi that respect version constraints; pip users must manually ensure version compatibility.
Requires Python 3.12 or later. The installed version of numpy-typing-compat must match your NumPy version—modern package managers handle this automatically, but pip requires manual version alignment.
License in practice
BSD-3-Clause permissive license allows use in most projects without significant restrictions.
Quickstart
pip install numpy-typing-compat
from numpy_typing_compat import NUMPY_GE_2_1, StringDType
if NUMPY_GE_2_1:
dtype = StringDType()
else:
dtype = None
Verify before relying
- How well mypy and pyright actually support Literal-based version conditions in practice beyond the documented 'limited support'
- Whether the package is actively used by optype or other production libraries beyond its intended helper role
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.12 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagenumpy |
| Maintenance | Actively maintained 73 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,920,133 / month, #2,452 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Typing :: Typed |
Evidence: numpy_typing_compat-20260602.2.5-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “numpy version-specific type annotations”
- numpy-typing-compatProvides version-specific type annotations for NumPy code, allowing…
- pyversPyvers provides dynamic dispatch for Python functions based on…
- jaxtypingProvides type annotations and runtime type-checking for array shape…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also scipy-stubs · typing · types-shapely · typing-aliases · types-colorama · optype · types-cffi · django-nine · types-Pygments · types-geopandas