Conversion factors between units are currently scattered throughout the codebase. Followed by aerocore.types, fr24.types.isqx, we can use isqx (a zero dependency units/quantity kinds library) to:
import isqx
import isqx.usc
# 1. safely convert between metric and imperial units
fpm_to_mps = isqx.convert(isqx.usc.FT * isqx.MIN**-1, isqx.M * isqx.S**-1)
assert fpm_to_mps(1300) == 6.604
# 2. also embed metadata into type annotations
from typing import TypeVar, Annotated
import isqx.aerospace
_T = TypeVar("_T")
PressureAltitudeM = Annotated[_T, isqx.aerospace.PRESSURE_ALTITUDE(isqx.M)]
def _(alt: PressureAltitudeM) -> ...:
...
The use of Annotated[_T, M] and typing.get_type_hints(..., extra=True) to extract M naturally integrates with #37.
cc @xoolive Testing the static analyser here will be fun, though it is very low priority :)
Conversion factors between units are currently scattered throughout the codebase. Followed by
aerocore.types,fr24.types.isqx, we can useisqx(a zero dependency units/quantity kinds library) to:The use of
Annotated[_T, M]andtyping.get_type_hints(..., extra=True)to extractMnaturally integrates with #37.cc @xoolive Testing the static analyser here will be fun, though it is very low priority :)