fixtures: deprecate FixtureDef.has_location and None global fixture visibility#14567
Merged
Conversation
Member
|
i wonder if this has actual external users and which those are to decide actual removal later |
bluetech
force-pushed
the
visibility-override
branch
2 times, most recently
from
June 7, 2026 18:32
41bc25f to
7186cd4
Compare
has_location was used to determine the fixture override order, pushing fixturedefs with no location to the front of the override chain. Now that the override order is determined by the fixtures' visibility in the collection tree, the attribute is no longer needed. Turn it into a property that emits a PytestRemovedIn10Warning, backed by the private _has_location attribute, and document the deprecation.
…ility instead of None Let's get rid of the `None` global visibility. Use `Session` which is functionality equivalent instead. - Allows us to remove an annoying special case from the fixture core. - Allows a cleaner public `register_fixture` interface (upcoming). There was previously a distinction between "has location" (e.g. conftest plugins) and "no location" (e.g. external plugins), but it's no longer needed after recent changes. Since initial conftest plugins are always registered after core & external plugins, the override chain order is maintained.
The nodeid-visibility/baseid deprecation previously allowed None (global) visibility. But this visibility is no longer needed, should use Session visibility instead. So let's include it in the deprecation as well, this way we can have a clean break in pytest 10.
bluetech
force-pushed
the
more-visibility-deprecate
branch
from
June 7, 2026 18:52
b50559e to
547eb13
Compare
Member
Author
nicoddemus
approved these changes
Jun 8, 2026
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.
This PR is stacked on:
get_scope_packagewhen possible #14565The first commit deprecates
FixtureDef.has_location. With #14566 it is no longer needed, and use of it is probably wrong.The second commit removes internal use of
Noneglobal visibility, replaced bySessionvisibility.The third commit deprecates global
Nonevisibility (extends thenodeid/baseiddeprecation).With this (the non-deprecated parts of)
_register_fixtureare neat and clean and this readies us to expose apytest.register_fixture(next commit in the stack).