TypedUnits

raw JSON →
0.0.2 verified Fri May 01 auth: no python

TypedUnits is a fast units and dimensions library with support for static dimensionality checking and protobuffer serialization, written in Cython. Current version is 0.0.2, requires Python >=3.10. Release cadence is irregular.

pip install typedunits
error ModuleNotFoundError: No module named 'typedunits'
cause Library not installed or Python environment mismatch.
fix
Run 'pip install typedunits' and ensure Python >=3.10.
error AttributeError: module 'typedunits' has no attribute 'Unit'
cause Incorrect import path or library version too old.
fix
Use 'from typedunits import Unit'. Upgrade to >=0.0.2.
gotcha Static dimensionality checking may break code that relies on duck typing or dynamic unit conversion. Ensure unit types are consistent.
fix Use explicit unit conversions via the library's conversion methods.
breaking Version 0.0.2 introduced tighter static typing checks, which may cause new type errors in existing code.
fix Update type annotations to match stricter expectations.

Create a simple unit value and print it.

from typedunits import Unit

u = Unit('m', 3.0)  # 3 meters
print(u)