-
-
Notifications
You must be signed in to change notification settings - Fork 677
feat(gazelle): Add directives for label format & normalisation #1976
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c955f00
Implement python_label_convention & python_label_normalization
wingsofovnia 4cfe427
Add tests
wingsofovnia 05e4a5d
Add docs
wingsofovnia 385a6dc
fix test
wingsofovnia d609e5d
pre-commit unrelated files
wingsofovnia 7538bf4
Update CHANGELOG.md
wingsofovnia 1cc0168
Remove deprecated test
wingsofovnia ab12466
Merge remote-tracking branch 'origin/main' into feature/1939
wingsofovnia 115d1d5
Merge branch 'bazelbuild:main' into feature/1939
wingsofovnia b2e321b
Remove excess mapping in gazelle_python.yaml tests
wingsofovnia 36ac873
Bring back default test normalization test
wingsofovnia 15338d9
Add new normalization tests
wingsofovnia 8928708
Apply convention before normaliation & tests
wingsofovnia 02695fe
Align snake_case norm with normalize_name.bzl
wingsofovnia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
gazelle/python/testdata/directive_python_label_convention/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Directive: `python_label_convention` | ||
|
|
||
| This test case asserts that the `# gazelle:python_label_convention` directive | ||
| works as intended when set. |
Empty file.
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions
11
gazelle/python/testdata/directive_python_label_convention/test1_unset/BUILD.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| load("@rules_python//python:defs.bzl", "py_library") | ||
|
|
||
| py_library( | ||
| name = "test1_unset", | ||
| srcs = ["bar.py"], | ||
| visibility = ["//:__subpackages__"], | ||
| deps = [ | ||
| "@gazelle_python_test//google_cloud_aiplatform", | ||
| "@gazelle_python_test//google_cloud_storage", | ||
| ], | ||
| ) |
6 changes: 6 additions & 0 deletions
6
gazelle/python/testdata/directive_python_label_convention/test1_unset/bar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from google.cloud import aiplatform, storage | ||
|
|
||
|
|
||
| def main(): | ||
| a = dir(aiplatform) | ||
| b = dir(storage) |
6 changes: 6 additions & 0 deletions
6
gazelle/python/testdata/directive_python_label_convention/test1_unset/gazelle_python.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| manifest: | ||
| modules_mapping: | ||
| google.cloud.aiplatform: google_cloud_aiplatform | ||
| google.cloud.storage: google_cloud_storage | ||
| pip_repository: | ||
| name: gazelle_python_test | ||
1 change: 1 addition & 0 deletions
1
gazelle/python/testdata/directive_python_label_convention/test2_custom_prefix_colon/BUILD.in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # gazelle:python_label_convention :$distribution_name$ |
13 changes: 13 additions & 0 deletions
13
...lle/python/testdata/directive_python_label_convention/test2_custom_prefix_colon/BUILD.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| load("@rules_python//python:defs.bzl", "py_library") | ||
|
|
||
| # gazelle:python_label_convention :$distribution_name$ | ||
|
|
||
| py_library( | ||
| name = "test2_custom_prefix_colon", | ||
| srcs = ["bar.py"], | ||
| visibility = ["//:__subpackages__"], | ||
| deps = [ | ||
| "@gazelle_python_test//:google_cloud_aiplatform", | ||
| "@gazelle_python_test//:google_cloud_storage", | ||
| ], | ||
| ) |
6 changes: 6 additions & 0 deletions
6
gazelle/python/testdata/directive_python_label_convention/test2_custom_prefix_colon/bar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from google.cloud import aiplatform, storage | ||
|
|
||
|
|
||
| def main(): | ||
| a = dir(aiplatform) | ||
| b = dir(storage) |
6 changes: 6 additions & 0 deletions
6
.../testdata/directive_python_label_convention/test2_custom_prefix_colon/gazelle_python.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| manifest: | ||
| modules_mapping: | ||
| google.cloud.aiplatform: google_cloud_aiplatform | ||
| google.cloud.storage: google_cloud_storage | ||
| pip_repository: | ||
| name: gazelle_python_test |
4 changes: 4 additions & 0 deletions
4
gazelle/python/testdata/directive_python_label_normalization/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Directive: `python_label_normalization` | ||
|
|
||
| This test case asserts that the `# gazelle:python_label_normalization` directive | ||
| works as intended when set. |
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
gazelle/python/testdata/directive_python_label_normalization/test1_type_none/BUILD.in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # gazelle:python_label_normalization none |
10 changes: 10 additions & 0 deletions
10
gazelle/python/testdata/directive_python_label_normalization/test1_type_none/BUILD.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| load("@rules_python//python:defs.bzl", "py_library") | ||
|
|
||
| # gazelle:python_label_normalization none | ||
|
|
||
| py_library( | ||
| name = "test1_type_none", | ||
| srcs = ["bar.py"], | ||
| visibility = ["//:__subpackages__"], | ||
| deps = ["@gazelle_python_test//google.cloud.storage"], | ||
| ) |
5 changes: 5 additions & 0 deletions
5
gazelle/python/testdata/directive_python_label_normalization/test1_type_none/bar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from google.cloud import storage | ||
|
|
||
|
|
||
| def main(): | ||
| b = dir(storage) |
6 changes: 6 additions & 0 deletions
6
.../python/testdata/directive_python_label_normalization/test1_type_none/gazelle_python.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| manifest: | ||
| modules_mapping: | ||
| # Weird google.cloud.storage here on purpose to make normalization apparent | ||
| google.cloud.storage: google.cloud.storage | ||
| pip_repository: | ||
| name: gazelle_python_test |
1 change: 1 addition & 0 deletions
1
gazelle/python/testdata/directive_python_label_normalization/test2_type_pep503/BUILD.in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # gazelle:python_label_normalization pep503 |
10 changes: 10 additions & 0 deletions
10
gazelle/python/testdata/directive_python_label_normalization/test2_type_pep503/BUILD.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| load("@rules_python//python:defs.bzl", "py_library") | ||
|
|
||
| # gazelle:python_label_normalization pep503 | ||
|
|
||
| py_library( | ||
| name = "test2_type_pep503", | ||
| srcs = ["bar.py"], | ||
| visibility = ["//:__subpackages__"], | ||
| deps = ["@gazelle_python_test//google-cloud-storage"], | ||
| ) |
5 changes: 5 additions & 0 deletions
5
gazelle/python/testdata/directive_python_label_normalization/test2_type_pep503/bar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from google.cloud import storage | ||
|
|
||
|
|
||
| def main(): | ||
| b = dir(storage) |
6 changes: 6 additions & 0 deletions
6
...ython/testdata/directive_python_label_normalization/test2_type_pep503/gazelle_python.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| manifest: | ||
| modules_mapping: | ||
| # Weird google.cloud.storage here on purpose to make normalization apparent | ||
| google.cloud.storage: google.cloud.storage | ||
| pip_repository: | ||
| name: gazelle_python_test |
1 change: 1 addition & 0 deletions
1
gazelle/python/testdata/directive_python_label_normalization/test3_type_snake_case/BUILD.in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # gazelle:python_label_normalization snake_case |
10 changes: 10 additions & 0 deletions
10
gazelle/python/testdata/directive_python_label_normalization/test3_type_snake_case/BUILD.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| load("@rules_python//python:defs.bzl", "py_library") | ||
|
|
||
| # gazelle:python_label_normalization snake_case | ||
|
|
||
| py_library( | ||
| name = "test3_type_snake_case", | ||
| srcs = ["bar.py"], | ||
| visibility = ["//:__subpackages__"], | ||
| deps = ["@gazelle_python_test//google_cloud_storage"], | ||
| ) |
5 changes: 5 additions & 0 deletions
5
gazelle/python/testdata/directive_python_label_normalization/test3_type_snake_case/bar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from google.cloud import storage | ||
|
|
||
|
|
||
| def main(): | ||
| b = dir(storage) |
6 changes: 6 additions & 0 deletions
6
...n/testdata/directive_python_label_normalization/test3_type_snake_case/gazelle_python.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| manifest: | ||
| modules_mapping: | ||
| # Weird google.cloud.storage here on purpose to make normalization apparent | ||
| google.cloud.storage: google.cloud.storage | ||
| pip_repository: | ||
| name: gazelle_python_test |
Empty file.
8 changes: 8 additions & 0 deletions
8
...estdata/directive_python_label_normalization/test4_unset_defaults_to_snake_case/BUILD.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| load("@rules_python//python:defs.bzl", "py_library") | ||
|
|
||
| py_library( | ||
| name = "test4_unset_defaults_to_snake_case", | ||
| srcs = ["bar.py"], | ||
| visibility = ["//:__subpackages__"], | ||
| deps = ["@gazelle_python_test//google_cloud_storage"], | ||
| ) |
5 changes: 5 additions & 0 deletions
5
...n/testdata/directive_python_label_normalization/test4_unset_defaults_to_snake_case/bar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from google.cloud import storage | ||
|
|
||
|
|
||
| def main(): | ||
| b = dir(storage) |
6 changes: 6 additions & 0 deletions
6
...rective_python_label_normalization/test4_unset_defaults_to_snake_case/gazelle_python.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| manifest: | ||
| modules_mapping: | ||
| # Weird google.cloud.storage here on purpose to make normalization apparent | ||
| google.cloud.storage: google.cloud.storage | ||
| pip_repository: | ||
| name: gazelle_python_test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.