From 8f836a7a458c96b741ec5c958ea20cd5219bca4f Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 26 Dec 2024 16:20:29 -0500 Subject: [PATCH 1/3] Enable Ruff FURB --- pyproject.toml | 1 + scripts/create_baseline_stubs.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 501066318b0b..069d4a77680d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ external = ["F821", "NQA", "Y"] select = [ "B", # flake8-bugbear "FA", # flake8-future-annotations + "FURB", # refurb "I", # isort "RUF", # Ruff-specific and unused-noqa "UP", # pyupgrade diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index 69f5d2b307e3..46de29b026c7 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -218,7 +218,7 @@ def main() -> None: info = get_installed_package_info(project) if info is None: print(f'Error: "{project}" is not installed', file=sys.stderr) - print("", file=sys.stderr) + print(file=sys.stderr) print(f'Suggestion: Run "python3 -m pip install {project}" and try again', file=sys.stderr) sys.exit(1) project, version = info From d359fd9b9854d3d272a9cac35bdafdc8d999837d Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 28 Dec 2024 13:58:28 -0500 Subject: [PATCH 2/3] Enabling FURB on individual rules --- pyproject.toml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 069d4a77680d..953c98d51317 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,10 +39,22 @@ external = ["F821", "NQA", "Y"] select = [ "B", # flake8-bugbear "FA", # flake8-future-annotations - "FURB", # refurb "I", # isort "RUF", # Ruff-specific and unused-noqa "UP", # pyupgrade + # Most refurb rules are in preview and can be opinionated, + # consider them individually as they come out of preview (last check: 0.8.4) + "FURB105", # Unnecessary empty string passed to `print` + "FURB129", # Instead of calling `readlines()`, iterate over file object directly + "FURB136", # Replace `if` expression with `{min_max}` call + "FURB161", # Use of `bin({existing}).count('1')` + "FURB163", # Prefer `math.{log_function}({arg})` over `math.log` with a redundant base + "FURB167", # Use of regular expression alias `re.{}` + "FURB168", # Prefer `is` operator over `isinstance` to check if an object is `None` + "FURB169", # Compare the identities of `{object}` and None instead of their respective types + "FURB177", # Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + "FURB181", # Use of hashlib's `.digest().hex()` + "FURB187", # Use of assignment of `reversed` on list `{name}` # Flake8 base rules "E", # pycodestyle Error "F", # Pyflakes From 99ef3fbb27cdd33c9f530882c9847ba98d56f927 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 2 Jan 2025 08:19:29 +0000 Subject: [PATCH 3/3] Update pyproject.toml Co-authored-by: Avasam --- pyproject.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c2388eb2ecbb..22f662fc3a0b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,13 +53,10 @@ select = [ "FURB105", # Unnecessary empty string passed to `print` "FURB129", # Instead of calling `readlines()`, iterate over file object directly "FURB136", # Replace `if` expression with `{min_max}` call - "FURB161", # Use of `bin({existing}).count('1')` - "FURB163", # Prefer `math.{log_function}({arg})` over `math.log` with a redundant base "FURB167", # Use of regular expression alias `re.{}` "FURB168", # Prefer `is` operator over `isinstance` to check if an object is `None` "FURB169", # Compare the identities of `{object}` and None instead of their respective types "FURB177", # Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups - "FURB181", # Use of hashlib's `.digest().hex()` "FURB187", # Use of assignment of `reversed` on list `{name}` # PYI: only enable rules that have autofixes and that we always want to fix (even manually), # avoids duplicate # noqa with flake8-pyi and flake8-noqa flagging `PYI` codes