Skip to content

Commit e1f838a

Browse files
Tidier Enum handling
Co-authored-by: Misha Veldhoen <misha.veldhoen@gmail.com>
1 parent 22515ba commit e1f838a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cfspopcon/file_io.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ def sanitize_variable(val: xr.DataArray, key: str, coord: bool = False) -> Union
3939
pass
4040

4141
def get_name(val: Enum | str) -> str:
42-
return getattr(val, "name", val) # type:ignore[arg-type]
42+
if isinstance(val, Enum):
43+
return val.name
44+
else:
45+
return val
4346

4447
if val.dtype == object:
4548
try:

0 commit comments

Comments
 (0)