-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Don't flag redefined-while-unused
in if branches
#9418
Conversation
15bbe34
to
08931c5
Compare
redefined-while-unsed
in if branches
Just looking at with safe_import() as exc:
import cffi
if exc.error:
cffi = None # noqa: F811 from kivy.core.window import Window
from kivy.metrics import dp
from kivy.utils import platform
if "KIVY_DOC_INCLUDE" in os.environ:
dp = lambda x: x # NOQA: F811 |
Enforcing this is also the source of the bug we introduced in #2044. |
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF100 | 2 | 2 | 0 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+2 -0 violations, +0 -0 fixes in 2 projects; 41 projects unchanged)
apache/airflow (+1 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --preview --select ALL
+ tests/www/views/test_views_rendered.py:259:55: RUF100 [*] Unused `noqa` directive (unused: `F811`)
bokeh/bokeh (+1 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --preview --select ALL
+ src/bokeh/embed/util.py:143:32: RUF100 [*] Unused blanket `noqa` directive
Changes by rule (1 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF100 | 2 | 2 | 0 | 0 | 0 |
redefined-while-unsed
in if branchesredefined-while-unused
in if branches
Enforcing this would also resolve the bug introduced in #5561 (comment). |
Perhaps this should be preview though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is okay without preview since it's a reduction in scope; unless you think it is possible we will revert.
Summary
On
main
, we flag redefinitions in cases like:That is, we consider these to be in the "same branch", since they're not in disjoint branches. This matches Flake8's behavior, but it seems to lead to false positives.