diff options
| author | Ashley Whetter <ashley@awhetter.co.uk> | 2021-01-30 22:40:55 -0800 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2021-02-07 10:10:52 +0100 |
| commit | 599fe72a0c0e07e2a7720237c40800aa3c611708 (patch) | |
| tree | f00321410311d97cc24268692dcc4ea534355e0c /astroid | |
| parent | 4629b93e59037e7d43fd70cb19085c6cb93d58a6 (diff) | |
| download | astroid-git-599fe72a0c0e07e2a7720237c40800aa3c611708.tar.gz | |
Corrected the parent of function type comment nodes
These nodes used to be parented to their original ast.FunctionDef parent
but are now correctly parented to their astroid.FunctionDef parent.
Closes #851
Diffstat (limited to 'astroid')
| -rw-r--r-- | astroid/rebuilder.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py index 3fc1a83f..e56abbf8 100644 --- a/astroid/rebuilder.py +++ b/astroid/rebuilder.py @@ -238,7 +238,7 @@ class TreeRebuilder: return type_object.value - def check_function_type_comment(self, node): + def check_function_type_comment(self, node, parent): type_comment = getattr(node, "type_comment", None) if not type_comment: return None @@ -251,10 +251,10 @@ class TreeRebuilder: returns = None argtypes = [ - self.visit(elem, node) for elem in (type_comment_ast.argtypes or []) + self.visit(elem, parent) for elem in (type_comment_ast.argtypes or []) ] if type_comment_ast.returns: - returns = self.visit(type_comment_ast.returns, node) + returns = self.visit(type_comment_ast.returns, parent) return returns, argtypes @@ -615,7 +615,7 @@ class TreeRebuilder: returns = None type_comment_args = type_comment_returns = None - type_comment_annotation = self.check_function_type_comment(node) + type_comment_annotation = self.check_function_type_comment(node, newnode) if type_comment_annotation: type_comment_returns, type_comment_args = type_comment_annotation newnode.postinit( |
