Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
maddenp-noaa committed Jan 3, 2025
1 parent 2fdf73a commit c6b690b
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/uwtools/config/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,15 @@ def convert(self) -> UWYAMLConvert.ValT:
Will raise an exception if the value cannot be represented as the specified type.
"""
load_as = lambda t, v: t(yaml.safe_load(str(v)))
converters: dict[str, Callable[..., UWYAMLConvert.ValT]] = dict(
zip(
self.TAGS,
[
partial(load_as, bool),
datetime.fromisoformat,
partial(load_as, dict),
float,
int,
partial(load_as, list),
],
)
)
return converters[self.tag](self.value)
converters: list[Callable[..., UWYAMLConvert.ValT]] = [
partial(load_as, bool),
datetime.fromisoformat,
partial(load_as, dict),
float,
int,
partial(load_as, list),
]
return dict(zip(self.TAGS, converters))[self.tag](self.value)


class UWYAMLRemove(UWYAMLTag):
Expand Down

0 comments on commit c6b690b

Please sign in to comment.