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.

type-stubsserialization
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.

from numerary import Integer
from numerary import IntegralLike
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 footguns
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.
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.
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)`.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
22 hits · last 30 days
bytedance
5
gptbot
4
ahrefsbot
4
amazonbot
3
script
1
Resources