-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Applying more Ruff groups to this repository #13295
Comments
It makes sense to me to enable some more ruff rules on this repository — some of the changes in Avasam#39 look very useful! Some look not-so-useful to me, though ;) I think I'd definitely want to review each rule group being added on its own merits. A lot of ruff's rules are really useful, but not all of them make sense for every codebase. Some are extremely opinionated and enforce patterns that many would disagree with; some don't make sense at all for code in some domains; and some make sense in theory but are so nitpicky that they're pretty annoying to have enforced in CI without autofixes considering the benefits they actually bring. |
The current selection of Ruff rules comes as a direct translation from when we were using isort, pyupgrade, pycln, Flake8, and some plugins.
It made perfect sense at the time to restrict ourselves to only the most necessary rules, as additional linters and tooling to be installed and run could mean an increase in CI runtime, security risks, upgrade maintenance, and complications between incompatible versions of libraries.
But with Ruff, the context is completely different. It is so fast than any additional rule group is negligible on the runtime and it's a single dependency. Which means that we could enable more rule groups w/o much concerns to help keep our growing non-stubs code up to the best standards. And explore more lints that could be beneficial to stubs.
As a side effect, we get to test various Ruff rules on a very 3rd-party type-stubs-driven repository, helping catch edge-cases and rules that don't belong in that context. This, in my opinion, would further bolster the existing collaboration between Ruff and typeshed, as well as indirectly help the Python typing community that also uses Ruff.
I'm already ready with an experiment PR to see the width and scale of changes this would entail with nearly all rules enabled.
Avasam#39 (not something to be reviewed, just a launching point for me, like a possible "todo list")
Of course I would go incrementally: starting with those that already pass as-is, then those covered by autofixes, individually splitting off the more massive ones, finishing with the manual interventions.
Checklist
Flake8
:Pyflakes (F)
: Replace Flake8 checks with Ruff (except for flake8-pyi) #11496pycodestyle Error (E)
: Replace Flake8 checks with Ruff (except for flake8-pyi) #11496pycodestyle Warning (W)
: Replace Flake8 checks with Ruff (except for flake8-pyi) #11496mccabe (C90)
: ❌We don't actually mind long and complex tests. This is also very arbitrary, let's make that call on individual reviewsisort (I)
: Replacing isort with Ruff #10912pep8-naming (N)
: Enable Ruff N (pep8-naming) on non-stubs #13327pydocstyle (D)
: Enable Ruff D (pydocstyle) with pep257 convention #13326 &pyupgrade (UP)
: Enable nearly all pyupgrade rules (except on test cases) #11499flake8-2020 (YTT)
: Enable Ruff YTT #13314flake8-annotations (ANN)
: Enable Ruff ANN2 (flake8-annotations, autofixes only) #13331Any
rather thanIncomplete
#9550 is complete,ANN401
could be consideredflake8-async (ASYNC)
: Enable Ruff flake8-async (ASYNC) #13727flake8-bandit (S)
: https://github.com/Avasam/typeshed/tree/Ruff-S-flake8-banditflake8-blind-except (BLE)
: Enable Ruff flake8-blind-except (BLE) #13728flake8-boolean-trap (FBT)
: ☑flake8-bugbear (B)
: Replace flake8-bugbear with Ruff #11500 & Remove redundant Bugbear disabling in stubs #13308flake8-builtins (A)
: Enable Ruff flake8-builtins (A) #13729flake8-commas (COM)
: ❌Already taken care of by, or conflict with, Blackflake8-copyright (CPY)
: ❌Not using top-of-file copyright noticesflake8-comprehensions (C4)
: ☑flake8-datetimez (DTZ)
: ☑flake8-debugger (T10)
: ☑flake8-django (DJ)
: ❌Not using Django at runtimeflake8-errmsg (EM)
: Enable Ruff flake8-errmsg (EM) #13730flake8-executable (EXE)
: Enable Ruff EXE (flake8-executable) #13346flake8-future-annotations (FA)
: Use Ruff forfrom __future__ import annotations
checks #10910flake8-implicit-str-concat (ISC)
: ❌Mostly taken care of by the formatter. And we allow both implicit and explicit multiline strings (to my dismay 😆)flake8-import-conventions (ICN)
: Enable Ruff flake8-import-conventions (ICN) #13731flake8-logging (LOG)
: ❌Not using logging at runtimeflake8-logging-format (G)
: ❌Not using logging at runtimeflake8-no-pep420 (INP)
:flake8-pie (PIE)
:flake8-print (T20)
: ❌We use print as a logging mechanismflake8-pyi (PYI)
: Add some ruff autofixes to CI #10458 and ongoingflake8-pytest-style (PT)
: ❌Not using pytest at runtime / in our test suiteflake8-quotes (Q)
: ❌This should be fully covered by formatters (whether Black or Ruff)flake8-raise (RSE)
: ☑flake8-return (RET)
: Enable Ruff RET (flake8-return) #13323flake8-self (SLF)
:flake8-slots (SLOT)
: ☑flake8-simplify (SIM)
: Enable Ruff SIM #13309flake8-tidy-imports (TID)
: ❌Banned APIs need to be configured to be useful. A mix of stubs use relative imports.flake8-type-checking (TC)
: Enable some Ruff TC rules (flake8-type-checking) #13333flake8-gettext (INT)
: ❌Not using gettext or translationsflake8-unused-arguments (ARG)
: Enable Ruff ARG (flake8-unsued-arguments) and remove unused arguments #13334flake8-use-pathlib (PTH)
:flake8-todos (TD)
:flake8-fixme (FIX)
: ❌It doesn't make sense to block the CI on TODOseradicate (ERA)
: ❌Way too many false-positivespandas-vet (PD)
: ❌Not using Pandas at runtimepygrep-hooks (PGH)
: Enable Ruff PGH rules #13304Pylint (PL)
Pylint Convention (PLC)
: Enable Ruff PLC (Pylint Convention) #13306Pylint Error (PLE)
: Enable Ruff PLE (Pylint Error) #13305Pylint Refactor (PLR)
: Enable Ruff PLR (Pylint Refactor) #13307Pylint Warning (PLW)
:tryceratops (TRY)
: Enable Ruff TRY (tryceratops) #13359flynt (FLY)
: ☑NumPy-specific rules (NPY)
: ❌We may have to reference or support deprecated numpy types at timesFastAPI (FAST)
: ❌Not using FastAPI at runtimeAirflow (AIR)
: ❌Not using Airflow at runtimePerflint (PERF)
: Enable Ruff PERF #13312refurb (FURB)
: Enable Ruff FURB #13310pydoclint (DOC)
: (all in preview, enabling this would do nothing atm)Ruff-specific rules (RUF)
: Replace Flake8 checks with Ruff (except for flake8-pyi) #11496☑: We already pass all these (not yet configured) as-is. Can enable together.
The text was updated successfully, but these errors were encountered: