-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gazelle): __init__.py in per-file targets (#1582)
As per Python spec, `__init__.py` files are depended upon by every file in the package, so let's make sure that our generated targets also understand this implicit dependency. Note that because Python module dependencies are not a DAG, we can not depend on the Bazel target for `__init__.py` files (to avoid cycles in Bazel), and hence a non-empty `__init__.py` file is added to the `srcs` attribute of every `py_library` target. The language spec also says that each package depends on the parent package, but that is a less commonly used feature, and can make things more complex. From [importlib] docs: > Changed in version 3.3: Parent packages are automatically imported. From [import] language reference: > Importing parent.one will implicitly execute parent/__init__.py and parent/one/__init__.py. [importlib]: https://docs.python.org/3/library/importlib.html#importlib.import_module [import]: https://docs.python.org/3/reference/import.html#regular-packages --------- Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com>
- Loading branch information
1 parent
eca368a
commit 5ba63a8
Showing
11 changed files
with
117 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
|
||
# gazelle:python_generation_mode file | ||
# gazelle:python_generation_mode_per_file_include_init true |
This file contains 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 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_generation_mode_per_file_include_init true |
This file contains 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
Empty file.
This file contains 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