1
0
forked from VimPlug/jedi

Move annotation pep0484 file (about anontations) to gradual folder

This commit is contained in:
Dave Halter
2018-12-24 17:48:21 +01:00
parent e2ab4c060f
commit 59c7623769
7 changed files with 19 additions and 18 deletions
+2 -2
View File
@@ -6,7 +6,6 @@ from jedi.evaluate.cache import evaluator_method_cache, CachedMetaClass
from jedi.evaluate import compiled
from jedi.evaluate import recursion
from jedi.evaluate import docstrings
from jedi.evaluate import pep0484
from jedi.evaluate import flow_analysis
from jedi.evaluate import helpers
from jedi.evaluate.signature import TreeSignature
@@ -20,6 +19,7 @@ from jedi.evaluate.lazy_context import LazyKnownContexts, LazyKnownContext, \
from jedi.evaluate.context import iterable
from jedi import parser_utils
from jedi.evaluate.parser_cache import get_yield_exprs
from jedi.evaluate.gradual.annotation import infer_return_types
class LambdaName(AbstractNameDefinition):
@@ -179,7 +179,7 @@ class FunctionExecutionContext(TreeContext):
returns = get_yield_exprs(self.evaluator, funcdef)
else:
returns = funcdef.iter_return_stmts()
context_set = pep0484.infer_return_types(self)
context_set = infer_return_types(self)
if context_set:
# If there are annotations, prefer them over anything else.
# This will make it faster.
+4 -3
View File
@@ -273,7 +273,8 @@ class TreeInstance(AbstractInstanceContext):
# to itself.
@evaluator_method_cache(default=None)
def _get_annotated_class_object(self):
from jedi.evaluate import pep0484
from jedi.evaluate.gradual.annotation import py__annotations__, \
infer_type_vars_for_execution
for func in self._get_annotation_init_functions():
# Just take the first result, it should always be one, because we
@@ -285,9 +286,9 @@ class TreeInstance(AbstractInstanceContext):
# need to infer anything.
continue
all_annotations = pep0484.py__annotations__(execution.tree_node)
all_annotations = py__annotations__(execution.tree_node)
defined = self.class_context.define_generics(
pep0484.infer_type_vars_for_execution(execution, all_annotations),
infer_type_vars_for_execution(execution, all_annotations),
)
debug.dbg('Inferred instance context as %s', defined, color='BLUE')
return defined
+1 -1
View File
@@ -228,7 +228,7 @@ class ClassContext(use_metaclass(CachedMetaClass, ClassMixin, TreeContext)):
if stars:
continue # These are not relevant for this search.
from jedi.evaluate.pep0484 import find_unknown_type_vars
from jedi.evaluate.gradual.annotation import find_unknown_type_vars
for type_var in find_unknown_type_vars(self.parent_context, node):
if type_var not in found:
# The order matters and it's therefore a list.