Enable Ruff flake8-use-pathlib (PTH) (#13795)

Port existing code to pathlib
This commit is contained in:
Avasam
2025-05-05 12:59:43 -04:00
committed by GitHub
parent 0eb44e574c
commit 4265ee7c72
11 changed files with 101 additions and 113 deletions
+3 -3
View File
@@ -54,6 +54,7 @@ select = [
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # Pylint
"PTH", # flake8-use-pathlib
"RSE", # flake8-raise
"RUF", # Ruff-specific and unused-noqa
"SLOT", # flake8-slots
@@ -80,9 +81,6 @@ select = [
"FURB187", # Use of assignment of `reversed` on list `{name}`
# Used for lint.flake8-import-conventions.aliases
"ICN001", # `{name}` should be imported as `{asname}`
# Autofixable flake8-use-pathlib only
"PTH201", # Do not pass the current directory explicitly to `Path`
"PTH210", # Invalid suffix passed to `.with_suffix()`
# PYI: only enable rules that have autofixes and that we always want to fix (even manually),
# avoids duplicate # noqa with flake8-pyi
"PYI009", # Empty body should contain `...`, not pass
@@ -167,6 +165,8 @@ ignore = [
"PLR2004", # Magic value used in comparison, consider replacing `{value}` with a constant variable
# Keep codeflow path separation explicit
"PLR5501", # Use `elif` instead of `else` then `if`, to reduce indentation
# Often just leads to redundant more verbose code when needing an actual str
"PTH208", # Use `pathlib.Path.iterdir()` instead.
# Allow FIXME
"TD001", # Invalid TODO tag: `{tag}`
# Git blame is sufficient