annotations should be preferred even when it is a generator

This commit is contained in:
Laurent Soest
2021-08-28 20:53:54 +02:00
committed by boerde
parent 96b4330ef9
commit fe50352f9c

View File

@@ -344,7 +344,8 @@ class BaseFunctionExecutionContext(ValueContext, TreeContextMixin):
GenericClass(c, TupleGenericManager(generics)) for c in async_classes
).execute_annotation()
else:
if self.is_generator():
# If there are annotations, prefer them over anything else.
if self.is_generator() and not self.infer_annotations():
return ValueSet([iterable.Generator(inference_state, self)])
else:
return self.get_return_values()