Skip to content

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

Merged
aignas merged 6 commits intobazel-contrib:mainfrom
hunshcn:fix/NonEmptyAttrs
May 15, 2024
Merged

fix(gazelle): delete invalid py_library and use correct NonEmptyAttrs for py_*#1887
aignas merged 6 commits intobazel-contrib:mainfrom
hunshcn:fix/NonEmptyAttrs

Conversation

@hunshcn
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

hunshcn commented May 10, 2024

test added @aignas

@hunshcn hunshcn force-pushed the fix/NonEmptyAttrs branch from 031e34f to 52b4bf5 Compare May 12, 2024 13:49
@hunshcn
Copy link
Copy Markdown
Contributor Author

hunshcn commented May 13, 2024

ping @aignas

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

hunshcn commented May 14, 2024

could we continue?

@hunshcn hunshcn force-pushed the fix/NonEmptyAttrs branch from 54fd2c4 to 76e5f52 Compare May 14, 2024 13:47
Copy link
Copy Markdown
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.

@hunshcn hunshcn force-pushed the fix/NonEmptyAttrs branch from fc5c57b to b666908 Compare May 15, 2024 03:27
@aignas aignas added this pull request to the merge queue May 15, 2024
Merged via the queue into bazel-contrib:main with commit 781935f May 15, 2024
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.

2 participants