Skip to content

Gazelle: include .pyi sibling files in pyi_srcs #3354

@dougthor42

Description

@dougthor42

🚀 feature request

Relevant Rules

Gazelle

Description

New directive: # gazelle:python_generate_pyi_srcs true or similar

If a manually-generated .pyi file is present, it should be added to the pyi_srcs target attribute:

foo.py
foo.pyi
py_library(
    name = "foo",
    srcs = ["foo.py"],
    pyi_srcs = ["foo.pyi"],
)

Describe the solution you'd like

New directive: # gazelle:python_generate_pyi_srcs true or similar

At a very high level, the logic is basically just looking for a file with the same name as the python module but a different extension:

# pseudocode
for python_file in list_of_files:
    pyi_file = python_file.with_ext(".pyi")  # foo.py --> foo.pyi
    if pyi_file.exists():
        pyi_srcs.append(pyi_file)
    # rest of the target generation

Describe alternatives you've considered

None 😜

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions