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

fix(gazelle): delete invalid py_library and use correct NonEmptyAttrs for py_* #1887

Merged
merged 6 commits into from May 15, 2024

Conversation

hunshcn
Copy link
Contributor

@hunshcn hunshcn commented May 8, 2024

Before gazelle would leave generated py_library targets aroundeven when no files in a directory exist because X. With this change gazelle correctly handles this case.

@hunshcn hunshcn requested a review from f0rmiga as a code owner May 8, 2024 12:39
Copy link
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Could you add a test that ensures that we don't regress in the future and adjust the changelog notes please?

@hunshcn hunshcn requested a review from rickeylev as a code owner May 10, 2024 03:00
@hunshcn
Copy link
Contributor Author

hunshcn commented May 10, 2024

changelog has been added.

It requires two test part.

  1. Existing tests to ensure that everything is normal.
  2. Make a empty folder only has BUILD with a py_library rule generated by gazelle before. After gazelle, BUILD will be empty.

But I have no idea who to add test about 2.

@hunshcn hunshcn requested a review from aignas May 10, 2024 03:05
@aignas
Copy link
Collaborator

aignas commented May 10, 2024

For 2. you should be able to construct a test similar to how we have them in https://github.com/bazelbuild/rules_python/tree/main/gazelle/python/testdata

You can have the bazel file before running gazelle and after running gazelle, where the test framework will ensure that it works as you expect it to.

@hunshcn
Copy link
Contributor Author

hunshcn commented May 10, 2024

test added @aignas

@hunshcn
Copy link
Contributor Author

hunshcn commented May 13, 2024

ping @aignas

@hunshcn hunshcn requested a review from aignas May 13, 2024 05:00
@hunshcn
Copy link
Contributor Author

hunshcn commented May 14, 2024

could we continue?

Copy link
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

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

In general LGTM, thank you very much for the PR.

Could you please modify the PR description so that is more useful as a git commit message when people look at the history later?

Something like:
Before gazelle would leave generated py_library targets aroundeven when no files in a directory exist because X. With this change gazelle correctly handles this case.

Summary:

  1. Change private attrs
  2. Something else.

gazelle/python/testdata/remove_invalid_library/BUILD.out Outdated Show resolved Hide resolved
@aignas aignas added this pull request to the merge queue May 15, 2024
Merged via the queue into bazelbuild:main with commit 781935f May 15, 2024
4 checks passed
hunshcn added a commit to hunshcn/rules_python that referenced this pull request May 16, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 16, 2024
#1887 incorrectly generated an empty py_library for all dirs, although
it will eventually be removed because it is empty, but it will easily
conflict with other existing rules.

Fix this error, and only generate an empty py_library for bazel packages
with the same name py_library rule.
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.

None yet

2 participants