mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Trying to use prefer type annotations if they are available
This commit is contained in:
@@ -150,8 +150,12 @@ class FunctionExecutionContext(TreeContext):
|
||||
returns = get_yield_exprs(self.evaluator, funcdef)
|
||||
else:
|
||||
returns = funcdef.iter_return_stmts()
|
||||
context_set = docstrings.infer_return_types(self.function_context)
|
||||
context_set |= pep0484.infer_return_types(self.function_context)
|
||||
context_set = pep0484.infer_return_types(self.function_context)
|
||||
if context_set:
|
||||
# If there are annotations, prefer them over anything else.
|
||||
# This will make it faster.
|
||||
return context_set
|
||||
context_set |= docstrings.infer_return_types(self.function_context)
|
||||
|
||||
for r in returns:
|
||||
check = flow_analysis.reachability_check(self, funcdef, r)
|
||||
|
||||
@@ -332,7 +332,7 @@ class _BuiltinMappedMethod(Context):
|
||||
self._method = method
|
||||
self._builtin_func = builtin_func
|
||||
|
||||
def py__call__(self, params):
|
||||
def py__call__(self, arguments):
|
||||
# TODO add TypeError if params are given/or not correct.
|
||||
return self._method(self.parent_context)
|
||||
|
||||
|
||||
@@ -290,4 +290,5 @@ class ClassStubContext(_StubContextFilterMixin, ClassContext):
|
||||
|
||||
|
||||
class FunctionStubContext(_MixedStubContextMixin, FunctionContext):
|
||||
pass
|
||||
def py__call__(self, arguments):
|
||||
return self.stub_context.py__call__(arguments)
|
||||
|
||||
@@ -74,3 +74,7 @@ def test_method(Script):
|
||||
context = def_._name._context
|
||||
assert isinstance(context, BoundMethod), context
|
||||
assert isinstance(context._function, typeshed.FunctionStubContext), context
|
||||
|
||||
def_, = Script(code + '()').goto_definitions()
|
||||
context = def_._name._context
|
||||
assert isinstance(context, BoundMethod), context
|
||||
|
||||
Reference in New Issue
Block a user