Conversation
Concurrent parsing let an unset value overwrite an explicit annotation. This made test generation depend on parser completion order. Track explicit true and false values across all source files. Preserve an agreed value and reject conflicts.
The news fragment did not clearly describe the user-visible outcome. Clarify when annotations are kept and when Gazelle reports an error. Also wrap the stderr fixture and use API cross-references.
amartani
marked this pull request as ready for review
September 19, 2026 04:03
amartani
requested review from
aignas,
dougthor42 and
rickeylev
as code owners
September 19, 2026 04:03
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Restrict annotation conflict aggregation to py_test paths so non-test targets do not fail on irrelevant conflicting values.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Fixes nondeterministic merging of include_pytest_conftest annotations across multiple Python sources.
Changes:
- Preserve explicit values and reject conflicting values.
- Add unit and integration coverage.
- Document the behavior and add a release note.
| File | Summary |
|---|---|
news/gazelle-pytest-conftest.fixed.md |
Adds a release note. |
gazelle/python/testdata/annotation_include_pytest_conftest_conflict/WORKSPACE |
Defines the integration fixture workspace. |
gazelle/python/testdata/annotation_include_pytest_conftest_conflict/true_test.py |
Provides the explicit true annotation case. |
gazelle/python/testdata/annotation_include_pytest_conftest_conflict/test.yaml |
Configures the integration fixture. |
gazelle/python/testdata/annotation_include_pytest_conftest_conflict/README.md |
Documents the conflict fixture. |
gazelle/python/testdata/annotation_include_pytest_conftest_conflict/false_test.py |
Provides the explicit false annotation case. |
gazelle/python/testdata/annotation_include_pytest_conftest_conflict/conftest.py |
Supports the pytest fixture. |
gazelle/python/testdata/annotation_include_pytest_conftest_conflict/BUILD.out |
Expected generated BUILD output. |
gazelle/python/testdata/annotation_include_pytest_conftest_conflict/BUILD.in |
Input BUILD fixture. |
gazelle/python/parser.go |
Aggregates annotation values and detects conflicts. Moderate issue: this also affects non-test targets and can reject conflicting annotations that should have no effect there. |
gazelle/python/parser_test.go |
Adds parser coverage. |
gazelle/python/BUILD.bazel |
Registers test sources and dependencies. |
gazelle/docs/annotations.md |
Documents multi-source annotation behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.

When a
py_testhad multiplesrcs, Gazelle kept only the lastinclude_pytest_conftestannotation parsed from those sources.Because sources are parsed concurrently, an omitted annotation could
overwrite an explicit value, such as
false. Explicittrueandfalsevalues could also silently overwrite each other.Aggregate explicitly set values across all sources instead. Preserve an
explicit value when other sources omit the annotation, and reject
conflicting explicit values so generation remains deterministic.
Add unit and integration coverage and document the behavior.
Related to #3076.