Skip to content

Commit 4efc6d1

Browse files
committed
Return None if unit is None
1 parent de446b6 commit 4efc6d1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pyenzyme/sbml/serializer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,12 @@ def _get_sbml_kind(unit_type: pe.UnitType):
438438
raise ValueError(f"Unit type {unit_type} not found in libsbml")
439439

440440

441-
def _get_unit_id(unit: pe.UnitDefinition) -> str:
441+
def _get_unit_id(unit: pe.UnitDefinition) -> str | None:
442442
"""Helper function to get the unit from the list of units."""
443443

444+
if unit is None:
445+
return None
446+
444447
if unit.id is None:
445448
raise ValueError(f"Unit {unit.name} does not have an ID")
446449

0 commit comments

Comments
 (0)