🚀 feature request
Relevant Rules
gazelle
Description
Gazelle will automatically add a dep on :conftest to py_test targets if the directory has a conftest.py file.
| } elseiff==conftestFilename { |
| hasConftestFile=true |
| varconftest*rule.Rule |
| ifhasConftestFile { |
| deps, _, annotations, err:=parser.parseSingle(conftestFilename) |
| iferr!=nil { |
| log.Fatalf("ERROR: %v\n", err) |
| } |
| |
| // Check if a target with the same name we are generating already |
| // exists, and if it is of a different kind from the one we are |
| // generating. If so, we have to throw an error since Gazelle won't |
| // generate it correctly. |
| iferr:=ensureNoCollision(args.File, conftestTargetname, actualPyLibraryKind); err!=nil { |
| fqTarget:=label.New("", args.Rel, conftestTargetname) |
| err:=fmt.Errorf("failed to generate target %q of kind %q: %w. ", |
| fqTarget.String(), actualPyLibraryKind, err) |
| collisionErrors.Add(err) |
| } |
| |
| conftestTarget:=newTargetBuilder(pyLibraryKind, conftestTargetname, pythonProjectRoot, args.Rel, pyFileNames). |
| addSrc(conftestFilename). |
| addModuleDependencies(deps). |
| addResolvedDependencies(annotations.includeDeps). |
| addVisibility(visibility). |
| setTestonly(). |
| generateImportsAttribute() |
| |
| conftest=conftestTarget.build() |
| |
| result.Gen=append(result.Gen, conftest) |
| result.Imports=append(result.Imports, conftest.PrivateAttr(config.GazelleImportsKey)) |
| } |
| ifconftest!=nil { |
| pyTestTarget.addModuleDependency(Module{Name: strings.TrimSuffix(conftestFilename, ".py")}) |
| } |
If the file doesn't need conftest.py, this can result in pulling in a large dep tree unnecessarily.
Describe the solution you'd like
Python annotation # gazelle:include_conftest false.
- When
false, force-exclude add the dep. - When
true, force-add the dep. This is equivalent to the # gazelle:include_dep :conftest directive. - Defaults to unset, which is the same as the current behavior
Describe alternatives you've considered
None.
🚀 feature request
Relevant Rules
gazelle
Description
Gazelle will automatically add a dep on
:conftestto py_test targets if the directory has aconftest.pyfile.rules_python/gazelle/python/generate.go
Lines 126 to 127 in 5c68ff9
rules_python/gazelle/python/generate.go
Lines 364 to 394 in 5c68ff9
rules_python/gazelle/python/generate.go
Lines 468 to 470 in 5c68ff9
If the file doesn't need
conftest.py, this can result in pulling in a large dep tree unnecessarily.Describe the solution you'd like
Python annotation
# gazelle:include_conftest false.false, force-exclude add the dep.true, force-add the dep. This is equivalent to the# gazelle:include_dep :conftestdirective.Describe alternatives you've considered
None.