mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00

## 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.
37 lines
472 B
Python
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)
|