feat: expose FixtureFunctionDefinition for typing - #14862
Open
teddygood wants to merge 1 commit into
Open
Conversation
Co-authored-by: OpenAI Codex <noreply@openai.com>
| @@ -1454,6 +1454,12 @@ def __call__(self, function: FixtureFunction) -> FixtureFunctionDefinition: | |||
|
|
|||
| # TODO: paramspec/return type annotation tracking and storing | |||
| class FixtureFunctionDefinition: | |||
Member
There was a problem hiding this comment.
@pytest-dev/core if we expose this - do we want to make the return type a generic?
| """The type of a fixture function after decoration by :func:`pytest.fixture`. | ||
| This type is public for type annotations. It should not be instantiated | ||
| or subclassed by users, and its attributes are not part of the public API. |
Member
There was a problem hiding this comment.
It should probably be marked @final?
Author
There was a problem hiding this comment.
Thanks. I had considered whether @final was necessary, but you’re right. I’ll add it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14853
Summary
pytest.fixturereturns aFixtureFunctionDefinition, but users previously had to import this type from the private_pytest.fixturesmodule when annotating fixture factories.This change exports the existing class as
pytest.FixtureFunctionDefinitionand adds it to the API reference. It does not introduce a new class or change fixture behavior at runtime. The supported public surface is limited to its use in type annotations. Direct instantiation, subclassing, and its attributes remain outside the public API.A typing check covers fixture factories returning the public type. The obsolete Sphinx cross-reference exception is also removed now that the type has a public documentation target.