Virgil Dupras avatar Virgil Dupras committed 6b8bfc9

allow function redefinition for modern property construction via property.detter/deleter

Taken from commit by Ronny Pfannschmidt at

Comments (0)

Files changed (2)


 class FunctionDefinition(Binding):
-    pass
+    is_property = False
         if (isinstance(self.scope.get(, FunctionDefinition)
-                    and isinstance(value, FunctionDefinition)):
+                    and isinstance(value, FunctionDefinition)
+                    and not self.scope.get(
+                    and not value.is_property):
                         lineno,, self.scope[].source.lineno)
             raise RuntimeError("Got impossible expression context: %r" % (node.ctx,))
     def FUNCTIONDEF(self, node):
+        is_property = False
         for deco in node.decorator_list:
             self.handleNode(deco, node)
-        self.addBinding(node.lineno, FunctionDefinition(, node))
+            if getattr(deco, 'id', None) == 'property':
+                is_property = True
+            if getattr(deco, 'attr', None) in ('setter', 'deleter'):
+                is_property = True
+        funcdef = FunctionDefinition(, node)
+        funcdef.is_property = is_property
+        self.addBinding(node.lineno, funcdef)
     def LAMBDA(self, node):


             a = classmethod(a)
+    def test_modern_property(self):
+        self.flakes("""
+        class A:
+            @property
+            def t(self):
+                pass
+            @t.setter
+            def t(self, value):
+                pass
+            @t.deleter
+            def t(self):
+                pass
+        """)
     def test_unaryPlus(self):
         '''Don't die on unary +'''
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.