mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
Merge pull request #1800 from Boerde/pytest_improve_fixture_completion
Improve completion for pytest fixtures
This commit is contained in:
@@ -344,7 +344,8 @@ class BaseFunctionExecutionContext(ValueContext, TreeContextMixin):
|
|||||||
GenericClass(c, TupleGenericManager(generics)) for c in async_classes
|
GenericClass(c, TupleGenericManager(generics)) for c in async_classes
|
||||||
).execute_annotation()
|
).execute_annotation()
|
||||||
else:
|
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)])
|
return ValueSet([iterable.Generator(inference_state, self)])
|
||||||
else:
|
else:
|
||||||
return self.get_return_values()
|
return self.get_return_values()
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ def infer_anonymous_param(func):
|
|||||||
return function_context.get_return_values()
|
return function_context.get_return_values()
|
||||||
|
|
||||||
def wrapper(param_name):
|
def wrapper(param_name):
|
||||||
|
# parameters with an annotation do not need special handling
|
||||||
|
if param_name.annotation_node:
|
||||||
|
return func(param_name)
|
||||||
is_pytest_param, param_name_is_function_name = \
|
is_pytest_param, param_name_is_function_name = \
|
||||||
_is_a_pytest_param_and_inherited(param_name)
|
_is_a_pytest_param_and_inherited(param_name)
|
||||||
if is_pytest_param:
|
if is_pytest_param:
|
||||||
|
|||||||
@@ -309,3 +309,8 @@ def annotation2() -> Iterator[float]:
|
|||||||
next(annotation1())
|
next(annotation1())
|
||||||
#? float()
|
#? float()
|
||||||
next(annotation2())
|
next(annotation2())
|
||||||
|
|
||||||
|
|
||||||
|
# annotations should override generator inference
|
||||||
|
#? float()
|
||||||
|
annotation1()
|
||||||
|
|||||||
@@ -64,6 +64,11 @@ def lala(my_fixture):
|
|||||||
def lala(my_fixture):
|
def lala(my_fixture):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# overriding types of a fixture should be possible
|
||||||
|
def test_x(my_yield_fixture: str):
|
||||||
|
#? str()
|
||||||
|
my_yield_fixture
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# completion
|
# completion
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user