Skip to content

Commit

Permalink
Return None if unit is None
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Sep 24, 2024
1 parent de446b6 commit 4efc6d1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyenzyme/sbml/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 4efc6d1

Please sign in to comment.