Fix fixture annotations for pytest

This means mostly these:

@fixture
def foo() -> Generator[int, None, None]: ...
This commit is contained in:
Dave Halter committed 2021-11-16 22:57:25 +01:00
1 parent 8bd969c24a
commit 42508d9309
2 files changed
+23 -1

No files matched your search

+9 -1
View File
@@ -31,7 +31,15 @@ def execute(callback):
def infer_anonymous_param(func):
def get_returns(value):
if value.tree_node.annotation is not None:
return value.execute_with_values()
result = value.execute_with_values()
if any(v.name.get_qualified_names(include_module_names=True)
== ('typing', 'Generator')
for v in result):
return ValueSet.from_sets(
v.py__getattribute__('__next__').execute_annotation()
for v in result
)
return result
# In pytest we need to differentiate between generators and normal
# returns.