Skip to content

Commit 7f5e163

Browse files
fix: resolve mypy attr-defined errors in new test functions
1 parent bfcfa44 commit 7f5e163

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tests/test_code_context_extractor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4133,13 +4133,15 @@ def my_func(ctx: Context) -> None:
41334133
def test_collect_type_names_simple() -> None:
41344134
tree = ast.parse("def f(x: Foo): pass")
41354135
func = tree.body[0]
4136+
assert isinstance(func, ast.FunctionDef)
41364137
ann = func.args.args[0].annotation
41374138
assert collect_type_names_from_annotation(ann) == {"Foo"}
41384139

41394140

41404141
def test_collect_type_names_generic() -> None:
41414142
tree = ast.parse("def f(x: list[Foo]): pass")
41424143
func = tree.body[0]
4144+
assert isinstance(func, ast.FunctionDef)
41434145
ann = func.args.args[0].annotation
41444146
names = collect_type_names_from_annotation(ann)
41454147
assert "Foo" in names
@@ -4149,6 +4151,7 @@ def test_collect_type_names_generic() -> None:
41494151
def test_collect_type_names_optional() -> None:
41504152
tree = ast.parse("def f(x: Optional[Foo]): pass")
41514153
func = tree.body[0]
4154+
assert isinstance(func, ast.FunctionDef)
41524155
ann = func.args.args[0].annotation
41534156
names = collect_type_names_from_annotation(ann)
41544157
assert "Optional" in names
@@ -4158,6 +4161,7 @@ def test_collect_type_names_optional() -> None:
41584161
def test_collect_type_names_union_pipe() -> None:
41594162
tree = ast.parse("def f(x: Foo | Bar): pass")
41604163
func = tree.body[0]
4164+
assert isinstance(func, ast.FunctionDef)
41614165
ann = func.args.args[0].annotation
41624166
names = collect_type_names_from_annotation(ann)
41634167
assert names == {"Foo", "Bar"}
@@ -4170,6 +4174,7 @@ def test_collect_type_names_none_annotation() -> None:
41704174
def test_collect_type_names_attribute_skipped() -> None:
41714175
tree = ast.parse("def f(x: module.Foo): pass")
41724176
func = tree.body[0]
4177+
assert isinstance(func, ast.FunctionDef)
41734178
ann = func.args.args[0].annotation
41744179
assert collect_type_names_from_annotation(ann) == set()
41754180

0 commit comments

Comments
 (0)