Skip to content
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

ruff check --fix --unsafe-fixes #1997

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Nov 21, 2024

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).

% ruff rule E711

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.

Copy link

codecov bot commented Nov 21, 2024

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).

Files with missing lines Patch % Lines
bbot/modules/base.py 57% 7 Missing ⚠️
bbot/scanner/scanner.py 64% 4 Missing ⚠️
bbot/core/helpers/interactsh.py 0% 3 Missing ⚠️
bbot/modules/internal/excavate.py 77% 3 Missing ⚠️
bbot/core/event/base.py 78% 2 Missing ⚠️
bbot/modules/dnsdumpster.py 0% 2 Missing ⚠️
bbot/test/test_step_1/test_modules_basic.py 96% 2 Missing ⚠️
bbot/core/helpers/depsinstaller/installer.py 75% 1 Missing ⚠️
bbot/core/helpers/dns/engine.py 0% 1 Missing ⚠️
bbot/core/helpers/files.py 0% 1 Missing ⚠️
... and 12 more
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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant