bazel-contrib/rules_python

Add a new python comment annotation that adds targets to `data`

Open

#1.865 geöffnet am 23. Apr. 2024

Auf GitHub ansehen
 (4 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Starlark (705 Forks)auto 404
gazellehelp wantedtype: feature request

Repository-Metriken

Stars
 (679 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

🚀 feature request

Relevant Rules

  • gazelle

Description

This is the same as #1862, but for the data attribute on generated targets.

Describe the solution you'd like

# foo/bar/baz_test.py
import pathlib

# gazelle:include_data //foo/bar:test_data
TEST_DATA_DIR = pathlib.Path(__file__).parent / "test_data"

def test_main():
    assert TEST_DATA_DIR.exists()

Running Gazelle generates:

py_test(
    name = "baz_test",
    srcs = ["baz_test.py"],
    data = ["//foo/bar:test_data"],
)

Note that Gazelle does not generate the test_data target - it's still on the user to do that themselves.

Describe alternatives you've considered

The current method is to manually add data attributes.

Contributor Guide