Registry / type-stubs / numerary

numerary

JSON →
library0.4.4pypypiunverified

Numerary is a Python library that provides a set of type-hinting protocols (e.g., `Integer`, `Float`, `Real`, `Complex`, `Number`) designed for more precise and robust type-checking of numeric types in Python. It is currently at version 0.4.4 and is under active development with frequent, smaller updates.

pip install numerary
INSTALL
IMPORT
SIG · NUMERARY
N
numerary
type-stubspythonv0.4.4
Install
2.0s avg
Import
Disk
25MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 27MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.0s · import 0.000s · 27MB
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Integer
from numerary import Integer
from numerary import Integer
IntegralLike
from numerary import IntegralLike
RealLike
from numerary import RealLike

This quickstart demonstrates how to use `numerary` protocols for runtime type checking with `isinstance` and static type hints. The protocols allow distinguishing between different categories of numbers.

from numerary import Integer, Float, Real, Number def process_number(n: Number) -> str: if isinstance(n, Integer): return f"It's an integer: {n} (type: {type(n).__name__})" elif isinstance(n, Float): return f"It's a float: {n} (type: {type(n).__name__})" elif isinstance(n, Real): return f"It's a real number: {n} (type: {type(n).__name__})" else: return f"It's a generic number: {n} (type: {type(n).__name__})" print(process_number(5)) print(process_number(5.0)) print(process_number(3 + 4j)) print(process_number(10.5))
Debug
Known issues
breakingNumerary is pre-1.0.0, meaning its API may still undergo breaking changes in minor versions. While efforts are made to maintain compatibility, users should review release notes when upgrading.
fix
Always pin to a specific minor version (e.g., `numerary==0.4.*`) and review release notes for breaking changes before updating.
affects: <1.0.0
gotchaNumerary protocols are `typing.Protocol`s. They define interfaces for numeric types, primarily for static type checking (e.g., MyPy) and runtime `isinstance` checks when decorated with `@runtime_checkable` (which `numerary` does). They do not modify Python's built-in numeric types, but rather describe properties they satisfy.
fix
Understand that `numerary` works with Python's existing type system to add more granular numeric type hints, rather than replacing or altering core numeric behavior.
affects: All
gotchaThe `numerary.Float` protocol (like `numbers.Real`) is satisfied by both `int` and `float` built-in types. If you need to strictly differentiate between `int` and `float` instances at runtime (i.e., accept only `float` and not `int`), use `isinstance(obj, float)` directly rather than `isinstance(obj, numerary.Float)`.
fix
For strict runtime differentiation between `int` and `float` (e.g., `float` only), prefer `isinstance(value, float)` rather than `isinstance(value, numerary.Float)`.
affects: All
Upgrade
Version history
0.4.4latest on PyPI · released Aug 3, 2023
Audit
Dependencies
pythonrequiredRequires Python 3.8 or higher.
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
numerary — pip install numerary · libregistry