diff options
-rw-r--r-- | pyflakes/checker.py | 5 | ||||
-rw-r--r-- | pyflakes/test/test_other.py | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py index e927715..4d778a8 100644 --- a/pyflakes/checker.py +++ b/pyflakes/checker.py @@ -263,6 +263,11 @@ class Definition(Binding): """ A binding that defines a function or a class. """ + def redefines(self, other): + return ( + super().redefines(other) or + (isinstance(other, Assignment) and self.name == other.name) + ) class Builtin(Definition): diff --git a/pyflakes/test/test_other.py b/pyflakes/test/test_other.py index 42e99ae..aebdcea 100644 --- a/pyflakes/test/test_other.py +++ b/pyflakes/test/test_other.py @@ -118,6 +118,12 @@ class Test(TestCase): def a(): pass ''', m.RedefinedWhileUnused) + def test_redefined_function_shadows_variable(self): + self.flakes(''' + x = 1 + def x(): pass + ''', m.RedefinedWhileUnused) + def test_redefinedUnderscoreFunction(self): """ Test that shadowing a function definition named with underscore doesn't |