You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(gazelle): Add type-checking only dependencies to pyi_deps (bazel-contrib#3014)
bazel-contrib#2538 added the
attribute `pyi_deps` to python rules, intended to be used for
dependencies that are only used for type-checking purposes. This PR adds
a new directive, `gazelle:python_generate_pyi_deps`, which, when
enabled:
- When a dependency is added only to satisfy type-checking only imports
(in a `if TYPE_CHECKING:` block), the dependency is added to `pyi_deps`
instead of `deps`;
- Third-party stub packages (eg. `boto3-stubs`) are now added to
`pyi_deps` instead of `deps`.
---------
Co-authored-by: Douglas Thor <[email protected]>
Copy file name to clipboardExpand all lines: gazelle/README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -222,6 +222,8 @@ Python-specific directives are as follows:
222
222
| Controls how distribution names in labels to third-party deps are normalized. Useful for using Gazelle plugin with other rules with different label conventions (e.g. `rules_pycross` uses PEP-503). Can be "snake_case", "none", or "pep503". |
| Controls whether Gazelle resolves dependencies for import statements that use paths relative to the current package. Can be "true" or "false".|
225
+
|`# gazelle:python_generate_pyi_deps`|`false`|
226
+
| Controls whether to generate a separate `pyi_deps` attribute for type-checking dependencies or merge them into the regular `deps` attribute. When `false` (default), type-checking dependencies are merged into `deps` for backward compatibility. When `true`, generates separate `pyi_deps`. Imports in blocks with the format `if typing.TYPE_CHECKING:`/`if TYPE_CHECKING:` and type-only stub packages (eg. boto3-stubs) are recognized as type-checking dependencies. |
0 commit comments