feat(gazelle): resolve pytest_plugins declarations as dependencies - #4207
Draft
TrapsterDK wants to merge 4 commits into
Draft
TrapsterDK wants to merge 4 commits into
TrapsterDK wants to merge 4 commits into
Conversation
This branch has not been deployed
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.
AI written, human reviewed.
Summary
Pytest loads reusable fixture modules through
pytest_plugins, but Gazellecurrently discovers only ordinary imports. Users must therefore duplicate plugin
dependencies in BUILD files or
gazelle:include_depannotations.Treat static module-level
pytest_pluginsassignments as imports and reuse theexisting dependency resolver. Support literal strings, lists, tuples, annotated
and chained assignments, implicit string concatenation, and common Python string
escapes. Reuse buildtools' existing unquoting with narrow Python 3 normalization.
Match pytest's comma-separated single-string form and retain literal dependencies
when lists or tuples also contain dynamic entries.
Preserve dependency-ignore annotations, resolution directives, source locations,
and type-checking metadata. Exclude function/class-local declarations and document
unsupported dynamic expressions. Conditional declarations are conservatively
included, as with ordinary conditional imports.
Add parser edge-case tests and BUILD-generation regressions covering reusable
plugin prerequisites, a workspace-root conftest, external modules, duplicate dependencies,
resolution overrides, ignore behavior, and unrelated sibling test isolation.
Fixes #4196.
Verification
From
gazelle/:bazel test --config=fast-tests //...— all 87 test targets pass.gofmtcheck on the modified Go files — clean.git diff --check— clean.This changes dependency generation only; pytest's invocation-wide plugin
registration behavior is unchanged. Dynamic declarations and named Unicode
escapes remain unsupported and can use the existing explicit dependency
annotation.