Use AnnotatedSubClass for Async classes like everywhere else as stubs

This commit is contained in:
Dave Halter
2018-11-23 00:03:32 +01:00
parent 1948f23fb3
commit 55982d699b
2 changed files with 3 additions and 7 deletions

View File

@@ -327,7 +327,7 @@ class FunctionExecutionContext(TreeContext):
# The contravariant doesn't seem to be defined.
generics = (yield_contexts.py__class__(), NO_CONTEXTS)
return ContextSet(
AnnotatedSubClass(c, generics) for c in async_generator_classes
AnnotatedSubClass(c.stub_context, generics) for c in async_generator_classes
).execute_annotation()
else:
if evaluator.environment.version_info < (3, 5):
@@ -337,7 +337,7 @@ class FunctionExecutionContext(TreeContext):
# Only the first generic is relevant.
generics = (return_contexts.py__class__(), NO_CONTEXTS, NO_CONTEXTS)
return ContextSet(
AnnotatedSubClass(c, generics) for c in async_classes
AnnotatedSubClass(c.stub_context, generics) for c in async_classes
).execute_annotation()
else:
if is_generator:

View File

@@ -295,6 +295,7 @@ class TreeInstance(AbstractInstanceContext):
)
debug.dbg('Inferred instance context as %s', defined, color='BLUE')
return defined
return None
def get_annotated_class_object(self):
return self._get_annotated_class_object() or self.class_context
@@ -396,11 +397,6 @@ class BoundMethod(FunctionMixin, ContextWrapper):
return super(BoundMethod, self).get_function_execution(arguments)
def get_default_param_context(self):
if isinstance(self._wrapped_context, MethodContext):
return self.class_context
return self._wrapped_context.get_default_param_context()
def py__call__(self, arguments):
if isinstance(self._wrapped_context, OverloadedFunctionContext):
return self._wrapped_context.py__call__(self._get_arguments(arguments))