You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of replacing pylint with ruff, I think we can use both to see if there are any linting issues reported by pylint but not detected by ruff. We can then decide if we want to remove pylint before releasing v0.11.0. So I propose to have two separate PRs:
ruff supports many groups of rules (https://docs.astral.sh/ruff/rules/). I think we should go through the available rules and apply the rules that make sense to our project.
ruff v0.16.0 (released on 2026/07) provides the following linters/rules:
I've enabled ~32 rulesets that make sense to our project. Closing the issue now and we may revisit it in the feature if new ruff versions provide more rulesets.
I've been trying out some of these FURB rules in preview by running ruff check . --statistics, and got the following output at commit 41a0fe0 (those marked with an asterisk * are automatically fixable):
ruff check . --statistics
16 PLR6201 [*] Use a `set` literal when testing for membership
15 PLC0415 [ ] `import` should be at the top-level of a file
15 PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument
8 E226 [*] Missing whitespace around arithmetic operator
4 S404 [ ] `subprocess` module is possibly insecure
3 PLR6104 [*] Use `+=` to perform an augmented assignment directly
3 FURB113 [*] Use `lines.extend(('WARNING:', f' {warnmsg}'))` instead of repeatedly calling `lines.append()`
2 PLC1901 [ ] `err == ""` can be simplified to `not err` as an empty string is falsey
2 PLW3201 [ ] Bad or misspelled dunder method name `_repr_html_`
1 PLR0904 [ ] Too many public methods (30 > 20)
1 PLR0917 [ ] Too many positional arguments (11/10)
1 PLW0108 [*] Lambda may be unnecessary; consider inlining inner function
1 RUF027 [*] Possible f-string without an `f` prefix
Thinking of applying PLR6201 and maybe PLW1514, does that sound ok?
Activity
weiji14 commentedon Oct 15, 2023
Opened a PR to replace
flakeheavenandisortwithruffat #2747, so that we can move ahead with the Python 3.12 support.It should also be possible to replace
pylintwithruff(see https://docs.astral.sh/ruff/faq/#how-does-ruff-compare-to-pylint), which would:make lint(which is slow) from the Makefile (i.e. only havemake checkandmake format)ruffcan actually automatically fix some pylint rules (see those marked with 🛠️ at https://docs.astral.sh/ruff/rules/#pylint-pl)So should we replace
pylintwithruff? Vote 👍 for yes, 👎 for no. If everyone is generally in favour, we can open a PR after #2747 is merged.seisman commentedon Oct 16, 2023
Instead of replacing
pylintwithruff, I think we can use both to see if there are any linting issues reported by pylint but not detected byruff. We can then decide if we want to removepylintbefore releasing v0.11.0. So I propose to have two separate PRs:ruffas a linting toolpylintbefore v0.11.0seisman commentedon Nov 9, 2023
Last updated on 2024/11/29
ruff supports many groups of rules (https://docs.astral.sh/ruff/rules/). I think we should go through the available rules and apply the rules that make sense to our project.
ruff v0.16.0 (released on 2026/07) provides the following linters/rules:
A: flake8-builtins Enable ruff's flake8-builtins (A) rules #2882[unrelated to airflow]AIR: AirflowANN: flake8-annotations [This ruleset checks annotations of all parameters. So, we can't enable this ruleset until we're 100% type-complete]ARG: flake8-unused-arguments Enable ruff's flake8-unused-arguments (ARG) rules #2900[async is not used in pygmt]ASYNC: flake8-asyncB: flake8-bugbear Enable ruff's flake8-bugbear (B) rules #2825BLE: flake8-blind-except Enable ruff's BLE/ICN/PGH/RSE/TCH/TID/YTT rules #2878C4: flake8-comprehensions Enable ruff's flake8-comprehensions (C4) rules #2887C90: mccabe [Some functions have high complexity but it's a lot of work to refactor them]COM: flake8-commas Enable ruff's flake8-commas (COM) and refurb (FURB) rules #3531[we don't have copyright in any files]CPY: flake8-copyright[not a django project]DJ: flake8-djangoDOC: pydoclint [preview only]D: pydocstyle Enable ruff's pydocstyle (D) rules and remove docformatter #2925[I think we usually don't care about timezones)DTZ: flake8-datetimezEM: flake8-errmsg Enable ruff's EM (flake8-errmsg) rules and fix violations #3661[This linter has one rule to check commented-out Python code. It raises many errors because sometimes we have code-like comments.]ERA: eradicateE/W: pycodestyle Replace flakeheaven and isort with ruff #2747EXE: flake8-executable Enable ruff's flake8-executable (EXE) rules #2898FA: flake8-future-annotations Enable ruff's flake8-future-annotations (FA) rules #2855[unrelated to FastAPI]FAST: FastAPIFBT: flake8-boolean-trap [This ruleset causes too many errors. Better to refactor the function definition in Improve function signatures to use positional-only, positional-or-keyword, or keyword-only parameter #2893 first][FIXME is not used in pygmt]FIX: flake8-fixmeFLY: flynt Enable ruff's flynt (FLY) rules #2835F: Pyflakes Replace flakeheaven and isort with ruff #2747FURB: refurb Enable ruff's flake8-commas (COM) and refurb (FURB) rules #3531[logging is not used in pygmt]G: flake8-logging-formatICN: flake8-import-conventions Enable ruff's BLE/ICN/PGH/RSE/TCH/TID/YTT rules #2878I: isort Replace flakeheaven and isort with ruff #2747[report too many errors about examples]INP: flake8-no-pep420[gettext is not used in pygmt]INT: flake8-gettextISC: flake8-implicit-str-concat Enable ruff's flake8-implicit-str-concat (ISC) rules #2837[logging is not used in pygmt]LOG: flake8-loggingN: pep8-naming Enable ruff's pep8-naming (N) rules #2877NPY: NumPy-specific Enable ruff's NumPy-specific rules #2782PD: pandas-vet Enable ruff's pandas-vet (PD) rules #2830PERF: Perflint Enable ruff's perflint (PERF) rules #2886PGH: pygrep-hooks Enable ruff's BLE/ICN/PGH/RSE/TCH/TID/YTT rules #2878PIE: flake8-pie Enable ruff's flake8-pie (PIE) rules #2866PL: Pylint Enable ruff's pylint rules (PL) and remove pylint #2815PT: flake8-pytest-style Enable ruff's flake8-pytest-style (PT) rules #2899PTH: flake8-use-pathlib [too many violations. Address Replace os.path with pathlib #1834 first][PyGMT doesn't providePYI: flake8-pyi.pyifiles][Q: flake8-quotesruff formatalready enforces consistent quote style. The rules are redundant]RET: flake8-return Enable ruff's flake8-return (RET) rules and ignore RET504 #2897RSE: flake8-raise Enable ruff's BLE/ICN/PGH/RSE/TCH/TID/YTT rules #2878RUF: Ruff-specific Enable ruff's ruff-specific (RUF) rules #2901S: flake8-bandit Enable ruff's flake8-bandit (S) rules #2892SIM: flake8-simplify Enable ruff's flake8-simplify (SIM) rules #2829[I believe we only access class private members when necessary]SLF: flake8-self[pygmt has no subclasses of immutable types]SLOT: flake8-slots[no debugger information in pygmt]T10: flake8-debuggerT20: flake8-print Enable ruff's flake8-print (T20) rules #2894TC: flake8-type-checking Enable ruff's BLE/ICN/PGH/RSE/TCH/TID/YTT rules #2878TD: flake8-todos Enable ruff's flake8-todos (TD) rules #3723TID: flake8-tidy-imports Enable ruff's BLE/ICN/PGH/RSE/TCH/TID/YTT rules #2878TRY: tryceratops Enable ruff's TRY (tryceratops) rules #3665UP: pyupgrade Enable ruff's pyupgrade (UP) rules #2749YTT: flake8-2020 Enable ruff's BLE/ICN/PGH/RSE/TCH/TID/YTT rules #2878[-]Use ruff to lint the source codes[/-][+]Use ruff to improve code qualityu[/+][-]Use ruff to improve code qualityu[/-][+]Use ruff to improve code quality[/+]seisman commentedon Dec 21, 2023
I've enabled ~32 rulesets that make sense to our project. Closing the issue now and we may revisit it in the feature if new ruff versions provide more rulesets.
weiji14 commentedon Jul 8, 2024
I've been trying out some of these
FURBrules in preview by runningruff check . --statistics, and got the following output at commit 41a0fe0 (those marked with an asterisk * are automatically fixable):Thinking of applying
PLR6201and maybePLW1514, does that sound ok?seisman commentedon Jul 8, 2024
Sounds good.