Skip to content

Commit

Permalink
autoformat: isort & black
Browse files Browse the repository at this point in the history
  • Loading branch information
priscavdsluis committed Mar 16, 2023
1 parent 68bc508 commit 100f566
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
12 changes: 6 additions & 6 deletions hydrolib/core/basemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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.
"""
Expand Down
18 changes: 14 additions & 4 deletions hydrolib/core/rr/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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}'"

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 100f566

Please sign in to comment.