optype
Building Blocks for Precise & Flexible Type Hints
Decision gist · record as of 2026-08-14
Yes. optype is actively maintained, has zero external dependencies beyond typing-extensions, carries no known vulnerabilities, and is BSD-3-Clause licensed. It solves a real problem—expressing exact operator requirements in type hints—that most projects encounter when writing generic or mathematical code. Install it if you write code that needs to accept objects based on what operations they support rather than their concrete type.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.12 or later
- Low install friction; pure Python wheel with only typing-extensions as a runtime dependency.
- Actively maintained with recent releases and a live repository.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause is permissive; you can use, modify, and distribute optype freely in commercial and open-source projects with minimal restrictions.
last release 2026-06-07 (68 days) · last repo commit 2026-08-13 · 94 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,867,980 downloads/mo, #2,472 on PyPI
Alternatives
Verify before relying
pip install optype
from optype import SupportsAdd
def add_numbers(x: SupportsAdd, y: SupportsAdd) -> SupportsAdd:
return x + y- Whether optional NumPy support requires additional setup or is automatically available
- Specific type checker versions known to work best with optype
What it is and what it does
optype is a library for building precise type hints using single-method protocols and exact operator types. It lets you define what operations your code actually accepts—like SupportsAdd for anything that implements __add__—rather than forcing broad type categories. This bridges the gap between what your code needs and what type checkers can verify, working with mypy, pyright, and basedpyright.
The package is designed for developers who want type safety without fighting their type checker. It includes optional NumPy support and is built on typing-extensions, so it works across modern Python versions. The library is actively maintained, battle-tested, and carries no external dependencies beyond typing-extensions.
Use it for
- Define generic numeric operations that accept anything supporting __add__, __mul__, etc., without forcing a specific numeric type
- Write library code that accepts operator-compatible objects while rejecting incompatible subtypes
- Build precise function signatures for scientific or mathematical code that needs exact protocol matching
- Create type stubs or annotations for NumPy-adjacent code with proper operator typing
- Improve type checker cooperation in codebases using mypy or pyright by expressing protocol requirements explicitly
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
optype is actively maintained, has zero external dependencies beyond typing-extensions, carries no known vulnerabilities, and is BSD-3-Clause licensed. It solves a real problem—expressing exact operator requirements in type hints—that most projects encounter when writing generic or mathematical code. Install it if you write code that needs to accept objects based on what operations they support rather than their concrete type.
Install
optype on PyPI
Before you install
Low install friction; pure Python wheel with only typing-extensions as a runtime dependency. Actively maintained with recent releases and a live repository.
Requires Python 3.12 or later
License in practice
BSD-3-Clause is permissive; you can use, modify, and distribute optype freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install optype
from optype import SupportsAdd
def add_numbers(x: SupportsAdd, y: SupportsAdd) -> SupportsAdd:
return x + y
Verify before relying
- Whether optional NumPy support requires additional setup or is automatically available
- Specific type checker versions known to work best with optype
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 packagetyping-extensions |
| Maintenance | Actively maintained 68 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,867,980 / month, #2,472 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 :: DevelopersIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Topic :: Scientific/EngineeringTopic :: Software DevelopmentTyping :: Typed |
Evidence: optype-0.18.0-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 › “type hints protocols”
- optypeoptype provides single-method protocols and typed operators for…
- useful-typesProvides reusable type protocols and aliases for Python projects to…
- numeraryProvides runtime-checkable protocols and type hints for working with…
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 types-docker · types-grpcio-reflection · types-paramiko · types-braintree · types-psycopg2 · types-assertpy · numerary · numpy-typing-compat · basedpyright