ruff/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_30.py
ukyen 068b75cc8e
[pyflakes] Detect assignments that shadow definitions (F811) (#11961)
## Summary
This PR updates `F811` rule to include assignment as possible shadowed
binding. This will fix issue: #11828 .

## Test Plan

Add a test file, F811_30.py, which includes a redefinition after an
assignment and a verified snapshot file.
2024-06-23 13:29:32 -04:00

37 lines
472 B
Python

"""Regression test for: https://github.com/astral-sh/ruff/issues/11828"""
class A:
"""A."""
def foo(self) -> None:
"""Foo."""
bar = foo
def bar(self) -> None:
"""Bar."""
class B:
"""B."""
def baz(self) -> None:
"""Baz."""
baz = 1
class C:
"""C."""
def foo(self) -> None:
"""Foo."""
bar = (foo := 1)
class D:
"""D."""
foo = 1
foo = 2
bar = (foo := 3)
bar = (foo := 4)