@@ -390,191 +390,6 @@ py_proto_library(
390390
391391When ` false ` , Gazelle will ignore any ` py_proto_library ` , including previously-generated or hand-created rules.
392392
393- ### Annotations
394-
395- * Annotations* refer to comments found _ within Python files_ that configure how
396- Gazelle acts for that particular file.
397-
398- Annotations have the form:
399-
400- ``` python
401- # gazelle:annotation_name value
402- ```
403-
404- and can reside anywhere within a Python file where comments are valid. For example:
405-
406- ``` python
407- import foo
408- # gazelle:annotation_name value
409-
410- def bar (): # gazelle:annotation_name value
411- pass
412- ```
413-
414- The annotations are:
415-
416- | ** Annotation** | ** Default value** |
417- | ---------------------------------------------------------------| -------------------|
418- | [ ` # gazelle:ignore imports ` ] ( #annotation-ignore ) | N/A |
419- | Tells Gazelle to ignore import statements. ` imports ` is a comma-separated list of imports to ignore. | |
420- | [ ` # gazelle:include_dep targets ` ] ( #annotation-include_dep ) | N/A |
421- | Tells Gazelle to include a set of dependencies, even if they are not imported in a Python module. ` targets ` is a comma-separated list of target names to include as dependencies. | |
422- | [ ` # gazelle:include_pytest_conftest bool ` ] ( #annotation-include_pytest_conftest ) | N/A |
423- | Whether or not to include a sibling ` :conftest ` target in the deps of a ` py_test ` target. Default behaviour is to include ` :conftest ` . | |
424-
425-
426- #### Annotation: ` ignore `
427-
428- This annotation accepts a comma-separated string of values. Values are names of Python
429- imports that Gazelle should _ not_ include in target dependencies.
430-
431- The annotation can be added multiple times, and all values are combined and
432- de-duplicated.
433-
434- For ` python_generation_mode = "package" ` , the ` ignore ` annotations
435- found across all files included in the generated target are removed from ` deps ` .
436-
437- Example:
438-
439- ``` python
440- import numpy # a pypi package
441-
442- # gazelle:ignore bar.baz.hello,foo
443- import bar.baz.hello
444- import foo
445-
446- # Ignore this import because _reasons_
447- import baz # gazelle:ignore baz
448- ```
449-
450- will cause Gazelle to generate:
451-
452- ``` starlark
453- deps = [" @pypi//numpy" ],
454- ```
455-
456-
457- #### Annotation: ` include_dep `
458-
459- This annotation accepts a comma-separated string of values. Values _ must_
460- be Python targets, but _ no validation is done_ . If a value is not a Python
461- target, building will result in an error saying:
462-
463- ```
464- <target> does not have mandatory providers: 'PyInfo' or 'CcInfo' or 'PyInfo'.
465- ```
466-
467- Adding non-Python targets to the generated target is a feature request being
468- tracked in [ Issue #1865 ] ( https://github.com/bazel-contrib/rules_python/issues/1865 ) .
469-
470- The annotation can be added multiple times, and all values are combined
471- and de-duplicated.
472-
473- For ` python_generation_mode = "package" ` , the ` include_dep ` annotations
474- found across all files included in the generated target are included in ` deps ` .
475-
476- Example:
477-
478- ``` python
479- # gazelle:include_dep //foo:bar,:hello_world,//:abc
480- # gazelle:include_dep //:def,//foo:bar
481- import numpy # a pypi package
482- ```
483-
484- will cause Gazelle to generate:
485-
486- ``` starlark
487- deps = [
488- " :hello_world" ,
489- " //:abc" ,
490- " //:def" ,
491- " //foo:bar" ,
492- " @pypi//numpy" ,
493- ]
494- ```
495-
496- #### Annotation: ` include_pytest_conftest `
497-
498- Added in [ #3080 ] [ gh3080 ] .
499-
500- [ gh3080 ] : https://github.com/bazel-contrib/rules_python/pull/3080
501-
502- This annotation accepts any string that can be parsed by go's
503- [ ` strconv.ParseBool ` ] [ ParseBool ] . If an unparsable string is passed, the
504- annotation is ignored.
505-
506- [ ParseBool ] : https://pkg.go.dev/strconv#ParseBool
507-
508- Starting with [ ` rules_python ` 0.14.0] [ rules-python-0.14.0 ] (specifically [ PR #879 ] [ gh879 ] ),
509- Gazelle will include a ` :conftest ` dependency to an ` py_test ` target that is in
510- the same directory as ` conftest.py ` .
511-
512- [ rules-python-0.14.0 ] : https://github.com/bazel-contrib/rules_python/releases/tag/0.14.0
513- [ gh879 ] : https://github.com/bazel-contrib/rules_python/pull/879
514-
515- This annotation allows users to adjust that behavior. To disable the behavior, set
516- the annotation value to "false":
517-
518- ```
519- # some_file_test.py
520- # gazelle:include_pytest_conftest false
521- ```
522-
523- Example:
524-
525- Given a directory tree like:
526-
527- ```
528- .
529- ├── BUILD.bazel
530- ├── conftest.py
531- └── some_file_test.py
532- ```
533-
534- The default Gazelle behavior would create:
535-
536- ``` starlark
537- py_library(
538- name = " conftest" ,
539- testonly = True ,
540- srcs = [" conftest.py" ],
541- visibility = [" //:__subpackages__" ],
542- )
543-
544- py_test(
545- name = " some_file_test" ,
546- srcs = [" some_file_test.py" ],
547- deps = [" :conftest" ],
548- )
549- ```
550-
551- When ` # gazelle:include_pytest_conftest false ` is found in ` some_file_test.py `
552-
553- ``` python
554- # some_file_test.py
555- # gazelle:include_pytest_conftest false
556- ```
557-
558- Gazelle will generate:
559-
560- ``` starlark
561- py_library(
562- name = " conftest" ,
563- testonly = True ,
564- srcs = [" conftest.py" ],
565- visibility = [" //:__subpackages__" ],
566- )
567-
568- py_test(
569- name = " some_file_test" ,
570- srcs = [" some_file_test.py" ],
571- )
572- ```
573-
574- See [ Issue #3076 ] [ gh3076 ] for more information.
575-
576- [ gh3076 ] : https://github.com/bazel-contrib/rules_python/issues/3076
577-
578393
579394#### Directive: ` python_experimental_allow_relative_imports `
580395Enables experimental support for resolving relative imports in
0 commit comments