-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
topic: typingtype-annotation issuetype-annotation issuetype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch
Description
What's the problem this feature will solve?
Add typing information for parameterized fixtures to have better support for type checkers.
Describe the solution you'd like
Given a fixture like
@pytest.fixture(params=["--setup-only", "--setup-plan", "--setup-show"])
def mode(request):
return request.paramwhat is the type of request? I thought it would be FixtureRequest but this class doesn't have a param object. Thus I suggest to add a generic class ParametrizedFixtureRequest[T] where T is the type of the parameter. Thus in the above example one could annotate request: ParametrizedFixtureRequest[str] and then the type checker would know that request.param is a string.
Alternative Solutions
Additional context
Jasha10, yukihiko-shinoda, posita, leonarduschen, michaeloliverx and 3 morevringar, ReneOschmann, vludax, Jasha10, yukihiko-shinoda and 2 more
Metadata
Metadata
Assignees
Labels
topic: typingtype-annotation issuetype-annotation issuetype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch