Skip to content

Commit

Permalink
Address ruff RET (#1757)
Browse files Browse the repository at this point in the history
  • Loading branch information
shatakshiiii committed May 13, 2024
1 parent bc6d28b commit 24742a7
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 18 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Expand Up @@ -353,8 +353,6 @@ ignore = [
'PYI034', # `__enter__` methods in classes like `TmuxSession` usually return `self` at runtime
'PYI036', # The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None`
'PYI041', # Use `float` instead of `int | float`
'RET501', # [*] Do not explicitly `return None` in function if it is the only possible return value
'RET503', # [*] Missing explicit `return` at the end of function able to return non-`None` value
'RET504', # Unnecessary variable assignment before `return` statement
'RET505', # Unnecessary `else` after `return` statement
'RUF005', # [*] Consider `[self._name, *shlex.split(self._interaction.action.match.groupdict()["params"] or "")]` instead of concatenation
Expand Down
4 changes: 2 additions & 2 deletions src/ansible_navigator/actions/collections.py
Expand Up @@ -524,7 +524,7 @@ def _parse(self, output: str) -> None:
self._logger.error("Unable to extract collection json from stdout")
self._logger.debug("error json loading output: '%s'", str(exc))
self._logger.debug(output)
return None
return

for error in parsed["errors"]:
self._logger.error("%s %s", error["path"], error["error"])
Expand Down Expand Up @@ -593,7 +593,7 @@ def _parse(self, output: str) -> None:
error += parsed["collection_scan_paths"]
self._logger.warning(error)

return None
return

def _get_collection_plugins_details(
self, selected_collection: dict[str, Any]
Expand Down
8 changes: 4 additions & 4 deletions src/ansible_navigator/actions/config.py
Expand Up @@ -318,7 +318,7 @@ def _parse_and_merge(self, list_output: str, dump_output: str) -> None:
self._logger.debug("yaml loading list output succeeded")
except yaml.YAMLError as exc:
self._logger.debug("error yaml loading list output: '%s'", str(exc))
return None
return

regex = re.compile(r"^(?P<variable>\S+)\((?P<source>.*)\)\s=\s(?P<current>.*)$")
for line in dump_output.splitlines():
Expand Down Expand Up @@ -351,10 +351,10 @@ def _parse_and_merge(self, list_output: str, dump_output: str) -> None:
parsed[variable]["current_value"] = current
except KeyError:
self._logger.error("variable '%s' not found in list output")
return None
return
else:
self._logger.error("Unparsable dump entry: %s", line)
return None
return

for key, value in parsed.items():
value["option"] = key
Expand All @@ -368,4 +368,4 @@ def _parse_and_merge(self, list_output: str, dump_output: str) -> None:

self._config = list(parsed.values())
self._logger.debug("parsed and merged list and dump successfully")
return None
return
8 changes: 4 additions & 4 deletions src/ansible_navigator/actions/open_file.py
Expand Up @@ -178,7 +178,7 @@ def run(self, interaction: Interaction, app: AppPublic) -> None:
editor_console=editor_console,
editor_command=editor_command,
)
return None
return

temp_file_name = self._persist_content(content=requested, content_format=content_format)
temp_line_number = 0
Expand All @@ -188,7 +188,7 @@ def run(self, interaction: Interaction, app: AppPublic) -> None:
editor_console=editor_console,
editor_command=editor_command,
)
return None
return

if interaction.content:
content = interaction.content.showing
Expand All @@ -199,7 +199,7 @@ def run(self, interaction: Interaction, app: AppPublic) -> None:
serialization_format=serialization_format,
)
else:
return None
return

content_file_name = self._persist_content(content=content, content_format=content_format)
content_line_number = 0
Expand All @@ -209,4 +209,4 @@ def run(self, interaction: Interaction, app: AppPublic) -> None:
editor_console=editor_console,
editor_command=editor_command,
)
return None
return
6 changes: 3 additions & 3 deletions src/ansible_navigator/actions/write_file.py
Expand Up @@ -47,15 +47,15 @@ def run(self, interaction: Interaction, app: AppPublic) -> None:
"Append operation failed because %s does not exist, force with !",
filename,
)
return None
return
file_mode = "a"
else:
if os.path.exists(filename) and not match["force"]:
self._logger.warning(
"Write operation failed because %s exists, force with !",
filename,
)
return None
return
file_mode = "w"

if interaction.content:
Expand Down Expand Up @@ -102,4 +102,4 @@ def run(self, interaction: Interaction, app: AppPublic) -> None:
serialization_format=SerializationFormat.JSON,
)
self._logger.info("Wrote to '%s' with mode '%s' as '%s'", filename, file_mode, write_as)
return None
return
2 changes: 1 addition & 1 deletion tests/unit/configuration_subsystem/test_invalid_params.py
Expand Up @@ -98,7 +98,7 @@ def local_which(*_args: Any, **_kwargs: dict[str, Any]) -> None:
:param _kwargs: kwargs
:returns: no container engine
"""
return None
return

monkeypatch.setattr("shutil.which", local_which)
response = generate_config()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/logger/test_append.py
Expand Up @@ -69,7 +69,7 @@ def return_none(*_args: Any, **_kwargs: dict[str, Any]) -> None:
:param _kwargs: Keyword arguments
:returns: Nothing
"""
return None
return

new_session_msg = "New ansible-navigator instance"
log_file = tmp_path / "ansible-navigator.log"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/logger/test_time_zone.py
Expand Up @@ -90,7 +90,7 @@ def return_none(*_args: Any, **_kwargs: dict[str, Any]) -> None:
:param _kwargs: Keyword arguments
:returns: Nothing
"""
return None
return

log_file = tmp_path / "ansible-navigator.log"
args = data.args(log_file=log_file)
Expand Down

0 comments on commit 24742a7

Please sign in to comment.