@@ -104,6 +104,10 @@ const (
104104 // separate pyi_deps attribute or merge type-checking dependencies into deps.
105105 // Defaults to false for backward compatibility.
106106 GeneratePyiDeps = "python_generate_pyi_deps"
107+ // GeneratePyiSrcs represents the directive that controls whether to include
108+ // a pyi_srcs attribute if a sibling .pyi file is found.
109+ // Defaults to false for backward compatibility.
110+ GeneratePyiSrcs = "python_generate_pyi_srcs"
107111 // GenerateProto represents the directive that controls whether to generate
108112 // python_generate_proto targets.
109113 GenerateProto = "python_generate_proto"
@@ -202,6 +206,7 @@ type Config struct {
202206 labelNormalization LabelNormalizationType
203207 experimentalAllowRelativeImports bool
204208 generatePyiDeps bool
209+ generatePyiSrcs bool
205210 generateProto bool
206211 resolveSiblingImports bool
207212}
@@ -242,6 +247,7 @@ func New(
242247 labelNormalization : DefaultLabelNormalizationType ,
243248 experimentalAllowRelativeImports : false ,
244249 generatePyiDeps : false ,
250+ generatePyiSrcs : false ,
245251 generateProto : false ,
246252 resolveSiblingImports : false ,
247253 }
@@ -279,6 +285,7 @@ func (c *Config) NewChild() *Config {
279285 labelNormalization : c .labelNormalization ,
280286 experimentalAllowRelativeImports : c .experimentalAllowRelativeImports ,
281287 generatePyiDeps : c .generatePyiDeps ,
288+ generatePyiSrcs : c .generatePyiSrcs ,
282289 generateProto : c .generateProto ,
283290 resolveSiblingImports : c .resolveSiblingImports ,
284291 }
@@ -590,6 +597,18 @@ func (c *Config) GeneratePyiDeps() bool {
590597 return c .generatePyiDeps
591598}
592599
600+ // SetGeneratePyiSrcs sets whether pyi_srcs attribute should be generated if a sibling
601+ // .pyi file is found.
602+ func (c * Config ) SetGeneratePyiSrcs (generatePyiSrcs bool ) {
603+ c .generatePyiSrcs = generatePyiSrcs
604+ }
605+
606+ // GeneratePyiSrcs returns whether pyi_srcs attribute should be generated if a sibling
607+ // .pyi file is found.
608+ func (c * Config ) GeneratePyiSrcs () bool {
609+ return c .generatePyiSrcs
610+ }
611+
593612// SetGenerateProto sets whether py_proto_library should be generated for proto_library.
594613func (c * Config ) SetGenerateProto (generateProto bool ) {
595614 c .generateProto = generateProto
0 commit comments