From 3b3736138b8e9e4a4c5beac3d7fa51cd3ddddf59 Mon Sep 17 00:00:00 2001 From: "Edward K. Ream" Date: Wed, 30 Nov 2022 09:03:36 -0600 Subject: [PATCH 1/3] Blacken one file --- rope/base/pyobjectsdef.py | 48 ++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/rope/base/pyobjectsdef.py b/rope/base/pyobjectsdef.py index abab073ed..4d310a55a 100644 --- a/rope/base/pyobjectsdef.py +++ b/rope/base/pyobjectsdef.py @@ -85,30 +85,32 @@ def get_param_names(self, special_args=True): result.append(self.arguments.kwarg.arg) return result - def get_kind(self): - """Get function type - - It returns one of 'function', 'method', 'staticmethod' or - 'classmethod' strs. - - """ - scope = self.parent.get_scope() - if isinstance(self.parent, PyClass): - for decorator in self.decorators: - pyname = rope.base.evaluate.eval_node(scope, decorator) - if pyname == rope.base.builtins.builtins["staticmethod"]: - return "staticmethod" - if pyname == rope.base.builtins.builtins["classmethod"]: - return "classmethod" - return "method" - return "function" - @property - def decorators(self): - try: - return getattr(self.ast_node, "decorator_list") - except AttributeError: - return getattr(self.ast_node, "decorators", None) +def get_kind(self): + """Get function type + + It returns one of 'function', 'method', 'staticmethod' or + 'classmethod' strs. + + """ + scope = self.parent.get_scope() + if isinstance(self.parent, PyClass): + for decorator in self.decorators: + pyname = rope.base.evaluate.eval_node(scope, decorator) + if pyname == rope.base.builtins.builtins["staticmethod"]: + return "staticmethod" + if pyname == rope.base.builtins.builtins["classmethod"]: + return "classmethod" + return "method" + return "function" + + +@property +def decorators(self): + try: + return getattr(self.ast_node, "decorator_list") + except AttributeError: + return getattr(self.ast_node, "decorators", None) class PyComprehension(pyobjects.PyComprehension): From e463b124a06f6b2d30c2e97a3d8552d58c4e9dd0 Mon Sep 17 00:00:00 2001 From: "Edward K. Ream" Date: Thu, 1 Dec 2022 17:04:38 -0600 Subject: [PATCH 2/3] Fix weird reversion. All tests now pass --- rope/base/pyobjectsdef.py | 48 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/rope/base/pyobjectsdef.py b/rope/base/pyobjectsdef.py index 4d310a55a..abab073ed 100644 --- a/rope/base/pyobjectsdef.py +++ b/rope/base/pyobjectsdef.py @@ -85,32 +85,30 @@ def get_param_names(self, special_args=True): result.append(self.arguments.kwarg.arg) return result + def get_kind(self): + """Get function type + + It returns one of 'function', 'method', 'staticmethod' or + 'classmethod' strs. + + """ + scope = self.parent.get_scope() + if isinstance(self.parent, PyClass): + for decorator in self.decorators: + pyname = rope.base.evaluate.eval_node(scope, decorator) + if pyname == rope.base.builtins.builtins["staticmethod"]: + return "staticmethod" + if pyname == rope.base.builtins.builtins["classmethod"]: + return "classmethod" + return "method" + return "function" -def get_kind(self): - """Get function type - - It returns one of 'function', 'method', 'staticmethod' or - 'classmethod' strs. - - """ - scope = self.parent.get_scope() - if isinstance(self.parent, PyClass): - for decorator in self.decorators: - pyname = rope.base.evaluate.eval_node(scope, decorator) - if pyname == rope.base.builtins.builtins["staticmethod"]: - return "staticmethod" - if pyname == rope.base.builtins.builtins["classmethod"]: - return "classmethod" - return "method" - return "function" - - -@property -def decorators(self): - try: - return getattr(self.ast_node, "decorator_list") - except AttributeError: - return getattr(self.ast_node, "decorators", None) + @property + def decorators(self): + try: + return getattr(self.ast_node, "decorator_list") + except AttributeError: + return getattr(self.ast_node, "decorators", None) class PyComprehension(pyobjects.PyComprehension): From a265149da7defd5aa311c85b824f3dd928dfeefe Mon Sep 17 00:00:00 2001 From: "Edward K. Ream" Date: Tue, 6 Dec 2022 06:53:50 -0600 Subject: [PATCH 3/3] Second try: walk should not ever return a value --- rope/base/ast.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rope/base/ast.py b/rope/base/ast.py index a2923fb9f..efe95fcbc 100644 --- a/rope/base/ast.py +++ b/rope/base/ast.py @@ -22,12 +22,13 @@ def parse(source, filename=""): raise error -def walk(node, walker): +def walk(node, walker) -> None: """Walk the syntax tree""" method_name = "_" + node.__class__.__name__ method = getattr(walker, method_name, None) if method is not None: - return method(node) + method(node) + return for child in get_child_nodes(node): walk(child, walker)