Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gazelle): Include types/stubs packages #2425

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ewianda
Copy link
Contributor

@ewianda ewianda commented Nov 18, 2024

This PR adds logic that checks if a package has a corresponding types or stubs package and automatically adds that to the BUILD file. This is useful for typeckers e.g pyright , mypy

@aignas
Copy link
Collaborator

aignas commented Nov 18, 2024

Thank you @ewianda for the contribution. @dougthor42, would you have time to look at this?

Copy link
Contributor

@dougthor42 dougthor42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll probably be able to test this out sometime this week.

Until then, here are some review comments. Also, please add a flag to turn this on or off. It should be off by default for now, and then in a couple releases we can consider making it on by default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can avoid committing the binary wheels here?

typeModule := fmt.Sprintf("%s_types", strings.ToLower(distributionName))
if dep, _, ok := cfg.FindThirdPartyDependency(typeModule); ok {
deps.Add(dep)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove extra newline

// Add the type and stub dependencies if they exist.
typeModule := fmt.Sprintf("%s_types", strings.ToLower(distributionName))
if dep, _, ok := cfg.FindThirdPartyDependency(typeModule); ok {
deps.Add(dep)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test case for these two to gazelle/python/testdata

Comment on lines +9 to +11
whl = pathlib.Path(
pathlib.Path(__file__).parent, "testdata", "pytest-7.1.1-py3-none-any.whl"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: use / to build path:

whl = pathlib.Path(__file__).parent / "testdata" / "pytest-7.1.1-py3-none-any.whl"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants