Uh oh!
There was an error while loading. Please reload this page.
chore: warn on implicit __init__.py creation - #3841
Conversation
Warn users when targets rely on deprecated implicit __init__.py creation to encourage migration to explicit inits. We add a formatted multiline warning block inside the execution path of `_should_create_init_files(ctx)` in `py_executable.bzl`. The warning identifies the offending target by label and provides instructions on how to explicitly create inits or disable the warning.
Add a changelog news entry for the newly introduced deprecation warning on implicit __init__.py creation.
Clarify in the warning message that implicit __init__.py creation will be disabled by default (rather than completely removed) in a future release.
There was a problem hiding this comment.
Code Review
This pull request introduces a deprecation warning for targets relying on implicit __init__.py creation. The review feedback suggests using more professional language by replacing the word "diabolic" and recommends condensing the multi-line warning message into a single line to prevent excessive console noise in large workspaces.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
In bazel-contrib#3841, a warning pushing users to migrate away from implicit `__init__.py` generation was added. While this is very nice to have, it forces users to either explicitly configure this option on every `py_binary` and `py_test` target, or configure the option globally in their `.bazelrc`. To better facilitate a migration, this change introduces a mechanism for modules to configure this option module-wide. This has multiple benefits: 1. Everyone working in the module doesn't need to remember to explicitly set `legacy_create_init` on every target. 2. Everyone that depends on the module receives the correct behavior as configured by the module. 3. It becomes possible to tell BCR-wide which modules have adopted this migration. Work towards bazel-contrib#2945
In bazel-contrib#3841, a warning pushing users to migrate away from implicit `__init__.py` generation was added. While this is very nice to have, it forces users to either explicitly configure this option on every `py_binary` and `py_test` target, or configure the option globally in their `.bazelrc`. To better facilitate a migration, this change introduces a mechanism for modules to configure this option module-wide. This has multiple benefits: 1. Everyone working in the module doesn't need to remember to explicitly set `legacy_create_init` on every target. 2. Everyone that depends on the module receives the correct behavior as configured by the module. 3. It becomes possible to tell BCR-wide which modules have adopted this migration. Work towards bazel-contrib#2945
In bazel-contrib#3841, a warning pushing users to migrate away from implicit `__init__.py` generation was added. While this is very nice to have, it forces users to either explicitly configure this option on every `py_binary` and `py_test` target, or configure the option globally in their `.bazelrc`. To better facilitate a migration, this change introduces a mechanism for modules to configure this option module-wide. This has multiple benefits: 1. Everyone working in the module doesn't need to remember to explicitly set `legacy_create_init` on every target. 2. Everyone that depends on the module receives the correct behavior as configured by the module. 3. It becomes possible to tell BCR-wide which modules have adopted this migration. Work towards bazel-contrib#2945
In bazel-contrib#3841, a warning pushing users to migrate away from implicit `__init__.py` generation was added. While this is very nice to have, it forces users to either explicitly configure this option on every `py_binary` and `py_test` target, or configure the option globally in their `.bazelrc`. To better facilitate a migration, this change introduces a mechanism for modules to configure this option module-wide. This has multiple benefits: 1. Everyone working in the module doesn't need to remember to explicitly set `legacy_create_init` on every target. 2. Everyone that depends on the module receives the correct behavior as configured by the module. 3. It becomes possible to tell BCR-wide which modules have adopted this migration. Work towards bazel-contrib#2945
…azel-contrib#3997) In bazel-contrib#3841, a warning pushing users to migrate away from implicit `__init__.py` generation was added. While it's good to flag this bad behavior, silencing it requires users to either explicitly configure this option on every `py_binary` and `py_test` target, or configure the option globally in their `.bazelrc`. To better facilitate a migration, this change introduces a mechanism for modules to configure this option module-wide. This has multiple benefits: 1. Everyone working in the module doesn't need to remember to explicitly set `legacy_create_init` on every target. 2. Everyone that depends on the module receives the correct behavior as configured by the module. 3. It becomes possible to tell BCR-wide which modules have adopted this migration. Work towards bazel-contrib#2945 --------- Co-authored-by: Richard Levasseur <richardlev@gmail.com>
…3997) In #3841, a warning pushing users to migrate away from implicit `__init__.py` generation was added. While it's good to flag this bad behavior, silencing it requires users to either explicitly configure this option on every `py_binary` and `py_test` target, or configure the option globally in their `.bazelrc`. To better facilitate a migration, this change introduces a mechanism for modules to configure this option module-wide. This has multiple benefits: 1. Everyone working in the module doesn't need to remember to explicitly set `legacy_create_init` on every target. 2. Everyone that depends on the module receives the correct behavior as configured by the module. 3. It becomes possible to tell BCR-wide which modules have adopted this migration. Work towards #2945 --------- Co-authored-by: Richard Levasseur <richardlev@gmail.com> (cherry picked from commit c2ebcd3) Work towards #4010
Implicit
__init__.pycreation is deprecated and will be disabled by default in a future release. We need to warn users when their targets rely on this behavior so they can transition to explicit__init__.pyfiles before the default changes and their builds break.Work towards #2945