Gazelle not raising error when a target py_test exists in place of a py_binary
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 48/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- build-system
Piste de recherche
Commencez par le point d’entrée de rules_python_gazelle_plugin qui gère les targets générées en conflit, en utilisant la reproduction lib/demo fournie et la commande bazel run //:gazelle -- -strict -mode fix. Comparez le conflit entre py_binary et py_test avec le cas py_library et py_test. La tâche est terminée lorsque le conflit py_binary est signalé comme une erreur et que la commande se termine avec le statut 1, comme pour l’autre conflit.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
🐞 bug report
Affected Rule
rules_python_gazelle_plugin functionality
Is this a regression?
Still needs assessment
Description
When gazelle runs over a BUILD file and finds a py_test target where it wants to make a py_binary target, the gazelle extension flags the conflict, but it does not elevate to an error. This is not the case for other target conflicts. For example, if a py_test exists where a py_library should, a full error is raised and the exit code respects this.
When this conflict happens, no other gazelle edits are recommended for the affected target. Recommendations to other targets proceed as normal.
🔬 Minimal Reproduction
Make a simple tree like
lib/demo/
- example_lib.py
- example_bin.py
- example_test.py
The contents of each are
example_bin.py
from lib.demo import example_lib
def main() -> None:
print("Lib call:", example_lib.some_helper())
if __name__ == "__main__":
main()
example_lib.py
def some_helper() -> int:
return 52
example_test.py
import unittest
from lib.demo import example_lib
def test_thing() -> None:
assert example_lib.some_helper() == 52
if __name__ == "__main__":
unittest.main()
Now make the BUILD file with the following contents
load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_test(
name = "example_bin",
srcs = ["example_bin.py"],
)
py_library(
name = "example_lib",
srcs = ["example_lib.py"],
)
py_test(
name = "example_test",
srcs = ["example_test.py"],
)
Run bazel run //:gazelle -- -strict -mode diff and see the following output
$ bazel run //:gazelle -- -strict -mode fix
(21:34:13) INFO: Current date is 2026-02-16
(21:34:13) INFO: Analyzed target //:gazelle (0 packages loaded, 0 targets configured).
(21:34:13) INFO: Found 1 target...
Target //:gazelle up-to-date:
bazel-bin/gazelle-runner.bash
bazel-bin/gazelle
(21:34:13) INFO: Elapsed time: 0.129s, Critical Path: 0.05s
(21:34:13) INFO: 1 process: 4 action cache hit, 1 internal.
(21:34:13) INFO: Build completed successfully, 1 total action
gazelle: failed to generate target "//lib/demo:example_bin" of kind "py_binary": a target of kind "py_test" with the same name already exists
Now notice the difference in error when py_library is converted incorrectly to a py_test.
gazelle: failed to generate target "//lib/demo:example_bin" of kind "py_binary": a target of kind "py_test" with the same name already exists
gazelle: ERROR: failed to generate target "//lib/demo:example_lib" of kind "py_library": a target of kind "py_test" with the same name already exists. Use the '# gazelle:python_library_naming_convention' directive to change the naming convention.
The details are the same, but the latter scenario is reflected in the exit code with a value of 1.
🌍 Your Environment
Operating System:
debian linux
Output of bazel version:
8.4.2
Rules_python version:
1.8.3
- Langage dominant
- Starlark
- Étoiles
- 688
- Forks
- 724
- Merge moyen
- 1 j 14 h
- PR mergées (30 j)
- 59
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de bazel-contrib/rules_python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
bazel-contrib/rules_python#4201 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
bazel-contrib/rules_python#4164 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
go:embed stdlib_list.txt file in gazelle/python/std_modules.go is missingPeut-être pris @udaya2899 l’a pris il y a 12 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
bazel-contrib/rules_python#3821 ·
Les mainteneurs répondent en général sous 1 jour
-
Bazel 7 native py_binary: startup and import failures with rules_python 2.4.1Peut-être pris @gleyba l’a pris il y a 3 jours. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 30/100
bazel-contrib/rules_python#4234 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 28/100
bazel-contrib/rules_python#4218 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de bazel-contrib/rules_python
Issues similaires
-
needs-triage Platform(Default)
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
atlassian-labs/compiled#1960 ·
Les mainteneurs répondent en général sous 1 jour
-
Cached wheel reuse fails when the build and metadata fallback share an output directoryPeut-être pris @harbinresearcher l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
pypa/pyproject-hooks#240 · 1 commentaire ·
-
Upgrade to Commons Codec 1.23.0Ouvertestatus: team-only type: dependency-upgrade
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
spring-projects/spring-boot#52143 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
Les mainteneurs répondent en général sous 2 jours