diff --git a/pyenzyme/sbml/serializer.py b/pyenzyme/sbml/serializer.py index 5e440eb..dd5a5d1 100644 --- a/pyenzyme/sbml/serializer.py +++ b/pyenzyme/sbml/serializer.py @@ -438,9 +438,12 @@ def _get_sbml_kind(unit_type: pe.UnitType): raise ValueError(f"Unit type {unit_type} not found in libsbml") -def _get_unit_id(unit: pe.UnitDefinition) -> str: +def _get_unit_id(unit: pe.UnitDefinition) -> str | None: """Helper function to get the unit from the list of units.""" + if unit is None: + return None + if unit.id is None: raise ValueError(f"Unit {unit.name} does not have an ID")