Anonymous avatar Anonymous committed 0bae88a

pyobjectsdef: FunctionDef.decorators was renamed to decorator_list

Comments (0)

Files changed (3)


         PyDefinedObject.__init__(self, pycore, ast_node, parent)
         self.arguments = self.ast_node.args
-        self.decorators = self.ast_node.decorators
         self.parameter_pyobjects = pynames._Inferred(
             self._infer_parameters, self.get_module()._get_concluded_data())
         self.returned = pynames._Inferred(self._infer_returned)
         scope = self.parent.get_scope()
         if isinstance(self.parent, PyClass):
-            for decorator in self.get_ast().decorators:
+            for decorator in self.decorators:
                 pyname = rope.base.evaluate.get_statement_result(scope,
                 if pyname == rope.base.builtins.builtins['staticmethod']:
             return 'method'
         return 'function'
+    @property
+    def decorators(self):
+        if hasattr(self.ast_node, 'decorator_list'):
+            return self.ast_node.decorators
+        return self.ast_node.decorators
 class PyClass(pyobjects.PyClass):


         lines = self.pymodule.lines
         logicals = self.pymodule.logical_lines
         start_line = scope.get_start()
-        if self.pyfunction.get_ast().decorators:
-            decorators = self.pyfunction.get_ast().decorators
+        if self.pyfunction.decorators:
+            decorators = self.pyfunction.decorators
             if hasattr(decorators[0], 'lineno'):
                 start_line = decorators[0].lineno
         start_offset = lines.get_line_start(start_line)


     def _FunctionDef(self, node):
         children = []
-        if node.decorators:
-            for decorator in node.decorators:
+        decorators = getattr(node, 'decorator_list',
+                             getattr(node, 'decorators'))
+        if decorators:
+            for decorator in decorators:
         children.extend(['def',, '(', node.args])
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.