{"id":8358,"library":"numerary","title":"Numerary","description":"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.","status":"active","version":"0.4.4","language":"python","source_language":"en","source_url":"https://github.com/numerary-dev/numerary","tags":["type-hinting","protocol","numbers","mypy","static-analysis","runtime-checking"],"install":[{"cmd":"pip install numerary","lang":"bash","label":"Install stable release"}],"dependencies":[{"reason":"Requires Python 3.8 or higher.","package":"python","optional":false}],"imports":[{"wrong":"from numerary import Integer","symbol":"Integer","correct":"from numerary import Integer"},{"symbol":"IntegralLike","correct":"from numerary import IntegralLike"},{"symbol":"RealLike","correct":"from numerary import RealLike"}],"quickstart":{"code":"from numerary import Integer, Float, Real, Number\n\ndef process_number(n: Number) -> str:\n    if isinstance(n, Integer):\n        return f\"It's an integer: {n} (type: {type(n).__name__})\"\n    elif isinstance(n, Float):\n        return f\"It's a float: {n} (type: {type(n).__name__})\"\n    elif isinstance(n, Real):\n        return f\"It's a real number: {n} (type: {type(n).__name__})\"\n    else:\n        return f\"It's a generic number: {n} (type: {type(n).__name__})\"\n\nprint(process_number(5))\nprint(process_number(5.0))\nprint(process_number(3 + 4j))\nprint(process_number(10.5))","lang":"python","description":"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."},"warnings":[{"fix":"Always pin to a specific minor version (e.g., `numerary==0.4.*`) and review release notes for breaking changes before updating.","message":"Numerary 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.","severity":"breaking","affected_versions":"<1.0.0"},{"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.","message":"Numerary 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.","severity":"gotcha","affected_versions":"All"},{"fix":"For strict runtime differentiation between `int` and `float` (e.g., `float` only), prefer `isinstance(value, float)` rather than `isinstance(value, numerary.Float)`.","message":"The `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)`.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'0.4.4':41 'activ':45 'analysi':59 'check':30,62 'complex':20 'current':38 'design':22 'develop':46 'e.g':16 'float':18 'frequent':48 'hint':14,53 'integ':17 'librari':6 'mypi':56 'number':21,55 'numer':32 'numerari':1,2 'precis':25 'protocol':15,54 'provid':8 'python':5,35 'real':19 'robust':27 'runtim':61 'runtime-check':60 'set':10 'smaller':49 'static':58 'static-analysi':57 'type':13,29,33,52 'type-check':28 'type-hint':12,51 'updat':50 'version':40","created_at":"2026-04-16T17:01:46.396502+00:00","updated_at":"2026-04-16T17:01:46.396502+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'Integer' from 'numerary' (/tmp/tmpuazo1hiw/venv/lib/python3.12/site-packages/numerary/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.4.4","cli_name":"","cli_version":null,"type":"library","homepage":"https://posita.github.io/numerary/","github":"https://github.com/posita/numerary","docs":null,"changelog":null,"pypi":"https://pypi.org/project/numerary/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}