-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
topic: fixturesanything involving fixtures directly or indirectlyanything involving fixtures directly or indirectlytopic: 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
I could presumably submit a PR for this if it making SubRequest
a Generic
is deemed a good approach.
What's the problem this feature will solve?
When type hinting a parameter for a request
fixture the request.param
attribute is typed as Any
and I have to # type: ignore[no-any-return]
.
Describe the solution you'd like
Long term, a plugin would be nice to automatically relate the .param
to it's source in the @pytest.fixture()
decoration. Short term, Request
could just be a Generic
.
This would allow me to use request: _pytest.fixtures.SubRequest[MyType]
instead of the type ignore and get any useful hints on the .param
attribute inside the fixture as well as return type verification.
Alternative Solutions
I have not tried anything beyond the type ignore.
Additional context
None.
adamjstewart, EdwardEisenhauer, SyntaxColoring, benedikt-bartscher, gakugaku and 2 more
Metadata
Metadata
Assignees
Labels
topic: fixturesanything involving fixtures directly or indirectlyanything involving fixtures directly or indirectlytopic: 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