Type hints describe the kinds of values a piece of Python code expects. In a unit-conversion app, annotations such as `abbrev: str` and `value_in_std_units: float` make a unit’s fields easier to understand and help editors flag mistakes early. They are good practice, not strictly required. section 3.6.2
Describe a collection of units
A `Quantity` has a standard unit name and a collection of units: `std_unit: str` and `units: Dict[str, Unit]`. The second hint says that each dictionary key is a string and each value is a `Unit`. Import `Dict` from `typing` and `Unit` from its module. section 3.6.2
Function signatures can describe parameters and return values too. In `convert_value(quantity_name: str, from_unit_name: str, to_unit_name: str, value: float) -> Result`, the inputs are named quantities, units, and a numeric value; the output is a `Result`. Another backend function uses `-> List[str]` for a list of names. section 3.6.2
Type hints also help describe functions offered as tools to an AI agent. Pair a tool’s annotated signature with a docstring explaining its purpose, arguments, and return value so the model can decide which tool to call. Keep the two descriptions consistent: a user-lookup example is annotated `-> int`, while its docstring also allows `None` when no user is found. section 10.6.3 section 10.6.3
















