summaryrefslogtreecommitdiff
path: root/tests/unittest_nodes.py
diff options
context:
space:
mode:
authorAshley Whetter <ashley@awhetter.co.uk>2021-01-30 22:40:55 -0800
committerAshley Whetter <ashley@awhetter.co.uk>2021-01-31 09:47:19 -0800
commit217aa531a438c3b25cea8ecfd1bb0b834f5bc4f8 (patch)
treece9f320767e20e60e7138913173bcee0ee260208 /tests/unittest_nodes.py
parent5f67396894c79c4661e357ec8bb03aa134a51109 (diff)
downloadastroid-git-fix_851.tar.gz
Corrected the parent of function type comment nodesfix_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
Diffstat (limited to 'tests/unittest_nodes.py')
-rw-r--r--tests/unittest_nodes.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/unittest_nodes.py b/tests/unittest_nodes.py
index d138ee17..0ba6b3e5 100644
--- a/tests/unittest_nodes.py
+++ b/tests/unittest_nodes.py
@@ -1181,6 +1181,19 @@ def test_type_comments_posonly_arguments():
assert actual_arg.as_string() == expected_arg
+@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast")
+def test_correct_function_type_comment_parent():
+ data = """
+ def f(a):
+ # type: (A) -> A
+ pass
+ """
+ astroid = builder.parse(data)
+ f = astroid.body[0]
+ assert f.type_comment_args[0].parent is f
+ assert f.type_comment_returns.parent is f
+
+
def test_is_generator_for_yield_assignments():
node = astroid.extract_node(
"""