-
-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
calling parent
on a node that is part of a type comment returns the (original) _ast
module's FunctionDef
#851
Comments
Hi, thanks for the report. I tried to reproduce this but I was not able, can you paste the exact code you used to demonstrate the issue? |
@PCManticore, reproducibility of this one is straightforward to me, here's a (partial) example — but note that I had a typo in the original snippet: I missed the colon after Assume an AST visitor with:
|
I've just hit this myself. Here's what I did to reproduce: >>> import astroid
>>> f = astroid.extract_node("""
def f(a):
# type: (A) -> None
pass
""")
>>> f.type_comment_args[0].parent
<ast.FunctionDef object at 0x7f0b0fb077f0> |
These nodes used to be parented to their original ast.FunctionDef parent but are now correctly parented to their astroid.FunctionDef parent. Closes #851
These nodes used to be parented to their original ast.FunctionDef parent but are now correctly parented to their astroid.FunctionDef parent. Closes #851
These nodes used to be parented to their original ast.FunctionDef parent but are now correctly parented to their astroid.FunctionDef parent. Closes #851
Consider this snippet:
Given the
node
from the type comment,Name.int(name='int')
, if I call its parent (i.e.,node.parent
), I get the original _ast module's FunctionDef, instead of astroid's FunctionDef.The text was updated successfully, but these errors were encountered: