Don't flag redefined-while-unused in if branches#9418
Merged
charliermarsh merged 1 commit intomainfrom Jan 8, 2024
Merged
Conversation
15bbe34 to
08931c5
Compare
redefined-while-unsed in if branches
Member
Author
|
Just looking at with safe_import() as exc:
import cffi
if exc.error:
cffi = None # noqa: F811from 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 |
Member
Author
|
Enforcing this is also the source of the bug we introduced in #2044. |
Contributor
|
| 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
Member
Author
|
Enforcing this would also resolve the bug introduced in #5561 (comment). |
Member
Author
|
Perhaps this should be preview though. |
zanieb
approved these changes
Jan 8, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.