From 100f5661825515d9c7b7cd5b5b03203e9aaee5ff Mon Sep 17 00:00:00 2001 From: priscavdsluis Date: Thu, 16 Mar 2023 10:59:48 +0000 Subject: [PATCH] autoformat: isort & black --- hydrolib/core/basemodel.py | 12 ++++++------ hydrolib/core/rr/serializer.py | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/hydrolib/core/basemodel.py b/hydrolib/core/basemodel.py index 37d83117b..8b17e1445 100644 --- a/hydrolib/core/basemodel.py +++ b/hydrolib/core/basemodel.py @@ -1168,7 +1168,7 @@ def _save(self, save_settings: ModelSaveSettings) -> None: def _serialize(self, data: dict, save_settings: ModelSaveSettings) -> None: """Serializes the data to file. Should not be called directly, only through `_save`. - + Args: save_settings (ModelSaveSettings): The model save settings. """ @@ -1300,19 +1300,19 @@ def adjust_none(v: Any, field: ModelField) -> Any: class UserInputValidation: """Class to take care of user input validation""" + def __init__(self) -> None: self._os_path_style = get_path_style_for_current_operating_system() - def path_style(self, path_style: Optional[str]) -> PathStyle: - """ Validates the path style as string. - + """Validates the path style as string. + Args: path_style (Optional[str]): The path style as string value. - Returns: + Returns: PathStyle: The converted PathStyle object. - + Raises: ValueError: When an unsupported path style is passed. """ diff --git a/hydrolib/core/rr/serializer.py b/hydrolib/core/rr/serializer.py index 6a04de692..b15116d4d 100644 --- a/hydrolib/core/rr/serializer.py +++ b/hydrolib/core/rr/serializer.py @@ -12,7 +12,9 @@ def _calculate_max_value_length(data: Iterable) -> int: return max(map(get_str_len, data)) -def _get_string_value(path_value: Optional[Union[dict, Path, str]], save_settings: ModelSaveSettings) -> str: +def _get_string_value( + path_value: Optional[Union[dict, Path, str]], save_settings: ModelSaveSettings +) -> str: """Get printable string value of the path value in a typical RainfallRunoffModel. @@ -35,8 +37,14 @@ def _get_string_value(path_value: Optional[Union[dict, Path, str]], save_setting path = path_value elif isinstance(path_value, str): path = Path(path_value) - - value = "" if path is None else file_path_style_converter.convert_from_os_style(path, save_settings.path_style) + + value = ( + "" + if path is None + else file_path_style_converter.convert_from_os_style( + path, save_settings.path_style + ) + ) return f"'{value}'" @@ -201,7 +209,9 @@ def serialize(data: Dict, save_settings: ModelSaveSettings) -> str: # fmt: on -def write(path: Path, data: Dict, config: SerializerConfig, save_settings: ModelSaveSettings) -> None: +def write( + path: Path, data: Dict, config: SerializerConfig, save_settings: ModelSaveSettings +) -> None: """Write the specified model to the specified path. If the parent of the path does not exist, it will be created.