bazel-contrib / bazel-contrib/rules_python

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

未关闭
#1,865 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
gazelle help wanted type: feature request
主要语言
Starlark
星标
688
派生
721
平均合并
15 小时 7 分钟
30 天内合并 PR
76

描述

# 🚀 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.

贡献指南

打开贡献指南

调研方向

首先阅读相关 issue #1862 以及 Gazelle 中对现有 Python 注释标注的实现。跟踪标注如何影响生成的 target,然后为 `# gazelle:include_data` 添加相应处理,使 `data` 属性包含所请求的 label,同时不生成该 target。当示例产生所示的 `py_test` 输出且现有行为保持不变时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
build-system, tooling
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。