ruff check --fix --unsafe-fixes
Autofixes are made with ruff, a radical superset of flake8.
Most of these transformations were documented 23 years ago in the Python style guide PEP8.
% ruff check --statistics | grep "\[\*\]" | sort -k2
32 E711 [*] none-comparison
537 E712 [*] true-false-comparison
128 E713 [*] not-in-test
2 E731 [*] lambda-assignment
128 F541 [*] f-string-missing-placeholders
3 F601 [*] multi-value-repeated-key-literal
[*] fixable with `ruff check --fix`
% ruff check --fix --unsafe-fixes
Found 1294 errors (830 fixed, 464 remaining).
none-comparison (E711)
Derived from the pycodestyle linter.
Fix is always available.
What it does
Checks for comparisons to None which are not using the is operator.
Why is this bad?
According to PEP 8, "Comparisons to singletons like None should always be done with
is or is not, never the equality operators."
Example
if arg != None:
pass
if None == arg:
pass
Use instead:
if arg is not None:
pass
Fix safety
This rule's fix is marked as unsafe, as it may alter runtime behavior when
used with libraries that override the ==/__eq__ or !=/__ne__ operators.
In these cases, is/is not may not be equivalent to ==/!=. For more
information, see this issue.
Codecov Report
Attention: Patch coverage is 92.03354% with 38 lines in your changes missing coverage. Please review.
Project coverage is 93%. Comparing base (
2323594) to head (14704ea).
Additional details and impacted files
@@ Coverage Diff @@
## dev #1997 +/- ##
=====================================
- Coverage 93% 93% -0%
=====================================
Files 370 370
Lines 28312 28313 +1
=====================================
- Hits 26133 26118 -15
- Misses 2179 2195 +16
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
🚨 Try these New Features:
- Flaky Tests Detection - Detect and resolve failed and flaky tests
This looks good @cclauss. When you rebase, can you also replace black in a few other places:
- badge in
README.md
[](https://github.com/astral-sh/ruff)
-
pyproject.toml -
dev_environment.md -
tests.md
Thanks
I never have much luck with Poetry so perhaps I made ruff a dependency instead of a dev dependency.
I never have much luck with Poetry so perhaps I made
ruffa dependency instead of a dev dependency.
Ah yeah you have to do poetry add --group=dev