Skip to content

Commit

Permalink
Address ruff PTH204 exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
shatakshiiii committed May 22, 2024
1 parent 8804d6e commit 13c95d4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ ignore = [
'PTH119', # `os.path.basename()` should be replaced by `Path.name`
'PTH120', # `os.path.dirname()` should be replaced by `Path.parent`
'PTH122', # `os.path.splitext()` should be replaced by `Path.suffix`
'PTH204', # `os.path.getmtime` should be replaced by `Path.stat().st_mtime`
'PTH207', # Replace `glob` with `Path.glob` or `Path.rglob`
'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/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ def _set_inventories_mtime(self) -> None:
if Path(inventory).is_dir():
modification_times.append(
max(
os.path.getmtime(e)
Path(e).stat().st_mtime
for e in glob.glob(os.path.join(inventory, "**"), recursive=True)
),
)
elif os.path.isfile(inventory):
modification_times.append(os.path.getmtime(inventory))
modification_times.append(Path(inventory).stat().st_mtime)
if modification_times:
self._inventories_mtime = max(modification_times)
else:
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def time_stamp_for_file(path: str, time_zone: str) -> tuple[float | None, str |
:returns: The UNIX timestamp and an ISO 8601 string
"""
try:
modified = os.path.getmtime(path)
modified = Path(path).stat().st_mtime

Check warning on line 506 in src/ansible_navigator/utils/functions.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_navigator/utils/functions.py#L506

Added line #L506 was not covered by tests
except FileNotFoundError:
# It may have been mounted to a different location in the execution environment
modified = None
Expand Down

0 comments on commit 13c95d4

Please sign in to comment.