bazel-contrib / bazel-contrib/rules_python

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

Offen
#1,865 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
gazelle help wanted type: feature request
Vorherrschende Sprache
Starlark
Sterne
688
Forks
721
Ø Merge
15 Std. 7 Min.
Gemergte PRs (30 T.)
76

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

```python
# 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:

```starlark
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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by reading the related issue #1862 and the Gazelle implementation for existing Python comment annotations. Trace how annotations affect generated targets, then add the corresponding handling for `# gazelle:include_data` so the `data` attribute contains the requested label without generating the target. Done means the example produces the shown `py_test` output and existing behavior remains intact.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
build-system, tooling
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.