Skip to content

Commit

Permalink
Fix field unit properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Yrob committed Aug 26, 2024
1 parent edaa542 commit 075ae23
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/schematools/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,12 +1406,14 @@ def description(self) -> str | None:

@property
def unit(self) -> str | None:
"""Description of the dataset (if set)."""
"""Unit of the field (if set)."""
unit = self.get("unit")
return unit.get("value", unit)
if isinstance(unit, dict):
return unit.get("value", unit)
return unit

@property
def discription_with_unit(self) -> str | None:
def description_with_unit(self) -> str | None:
"""Description of the dataset (if set), with unit (if set)."""
if self.unit:
return f"{self.description} [{self.unit}]"
Expand Down

0 comments on commit 075ae23

Please sign in to comment.