summaryrefslogtreecommitdiffstats
path: root/Tools/clinic
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2023-10-10 09:35:36 (GMT)
committerGitHub <noreply@github.com>2023-10-10 09:35:36 (GMT)
commitfc811c8d205db9c19f42890e2c4193a0c2f87965 (patch)
treed7e847aa91ed8308e2cabffa1520488061849aaf /Tools/clinic
parent757cc35b6bf6c1df8c4c5b4879ca276963e46718 (diff)
downloadcpython-fc811c8d205db9c19f42890e2c4193a0c2f87965.zip
cpython-fc811c8d205db9c19f42890e2c4193a0c2f87965.tar.gz
cpython-fc811c8d205db9c19f42890e2c4193a0c2f87965.tar.bz2
gh-110558: Enable ruff's pyupgrade rules when running on Argument Clinic (#110603)
Diffstat (limited to 'Tools/clinic')
-rw-r--r--Tools/clinic/.ruff.toml15
-rwxr-xr-xTools/clinic/clinic.py2
2 files changed, 16 insertions, 1 deletions
diff --git a/Tools/clinic/.ruff.toml b/Tools/clinic/.ruff.toml
index 3bc9d90..cbb3a9a 100644
--- a/Tools/clinic/.ruff.toml
+++ b/Tools/clinic/.ruff.toml
@@ -2,9 +2,24 @@ target-version = "py310"
fix = true
select = [
"F", # Enable all pyflakes rules
+ "UP", # Enable all pyupgrade rules by default
"RUF100", # Ban unused `# noqa` comments
"PGH004", # Ban blanket `# noqa` comments (only ignore specific error codes)
]
+ignore = [
+ # Unnecessary parentheses to functools.lru_cache: just leads to unnecessary churn.
+ # https://github.com/python/cpython/pull/104684#discussion_r1199653347.
+ "UP011",
+ # Use format specifiers instead of %-style formatting.
+ # Doesn't always make code more readable.
+ "UP031",
+ # Use f-strings instead of format specifiers.
+ # Doesn't always make code more readable.
+ "UP032",
+ # Use PEP-604 unions rather than tuples for isinstance() checks.
+ # Makes code slower and more verbose. https://github.com/astral-sh/ruff/issues/7871.
+ "UP038",
+]
unfixable = [
# The autofixes sometimes do the wrong things for these;
# it's better to have to manually look at the code and see how it needs fixing
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 0f26350..1bcc855 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -2423,7 +2423,7 @@ extensions['py'] = PythonLanguage
def write_file(filename: str, new_contents: str) -> None:
try:
- with open(filename, 'r', encoding="utf-8") as fp:
+ with open(filename, encoding="utf-8") as fp:
old_contents = fp.read()
if old_contents == new_contents: