[pyflakes] Flag annotated variable redeclarations as F811 in preview mode#24244
Conversation
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| F811 | 1 | 1 | 0 | 0 | 0 |
|
Thanks for your interest in contributing to Ruff! Could you please take a look at the AI policy and make any necessary adjustments? |
|
@dylwil3 I checked every line one by one and all are good implemented. I used a |
3c9dcc1 to
cc4f43c
Compare
|
Ok, thank you! I think we can get away with something a bit simpler without introducing a new flag. I pushed a different approach, we'll see if CI passes but it ought to be equivalent. |
pyflakes] Flag annotated variable redeclarations as F811 in preview mode
dylwil3
left a comment
There was a problem hiding this comment.
Thanks! Just need some documentation.
* main: (40 commits) [ty] resolve union-likes in emitting union attribute errors (#24263) [ty] Improve support for `Callable` type context (#23888) [ty] Propagate type context through `await` expressions (#24256) [`pyflakes`] Flag annotated variable redeclarations as `F811` in preview mode (#24244) [ty] Preserve `Divergent` when materializing recursive aliases (#24245) Fix W391 fixes for consecutive empty notebook cells (#24236) [flake8-bugbear] Clarify RUF071 fix safety for non-path string comparisons (#24149) [ty] Ban type qualifiers in PEP-695 type aliases (#24242) [ty] Include keyword-prefixed symbols in completions for attributes (#24232) [ty] Add tests for TypedDict method overloads on unions (#24230) [ty] report unused bindings as unnecessary hint diagnostics (#23305) Remove unused `non_root` variable (#24238) Extend F507 to flag %-format strings with zero placeholders (#24215) [`flake8-simplify`] Suppress `SIM105` for `except*` before Python 3.12 (#23869) Ignore pre-initialization references in SIM113 (#24235) Parenthesize expression in RUF050 fix (#24234) Publish playgrounds using the `release-playground` environment (#24223) [ty] Fix instance-attribute lookup in methods of protocol classes (#24213) [ty] Used shared expression cache during generic call inference (#24219) [ty] make `Type::BoundMethod` include instances of same-named methods bound to a subclass (#24039) ...
Summary
bar: int = 1; bar: int = 2as unused redefinitionsx = 1; x = 2) remain unflagged, as this is normal Pythonbar: int = 1; bar: int = 2— flaggedbar = 1; bar = 2— not flagged (plain reassignment)bar = 1; bar: int = 2— not flagged (mixed)bar: int = 1; bar = 2— not flagged (mixed)bar: int = 1; print(bar); bar: int = 2— not flagged (first is used)Closes #23802
Test plan
F811_34.pytest fixture covering all combinations (annotated/plain, used/unused)