@@ -112,6 +112,8 @@ const (
112112 // like "import a" can be resolved to sibling modules. When disabled, they
113113 // can only be resolved as an absolute import.
114114 PythonResolveSiblingImports = "python_resolve_sibling_imports"
115+ // PythonIgnoreTarget represents the directive that controls whether to ignore the specific target.
116+ PythonIgnoreTarget = "python_ignore_target"
115117)
116118
117119// GenerationModeType represents one of the generation modes for the Python
@@ -204,6 +206,7 @@ type Config struct {
204206 generatePyiDeps bool
205207 generateProto bool
206208 resolveSiblingImports bool
209+ ignoredTargets map [string ]struct {}
207210}
208211
209212type LabelNormalizationType int
@@ -244,6 +247,7 @@ func New(
244247 generatePyiDeps : false ,
245248 generateProto : false ,
246249 resolveSiblingImports : false ,
250+ ignoredTargets : make (map [string ]struct {}),
247251 }
248252}
249253
@@ -281,6 +285,7 @@ func (c *Config) NewChild() *Config {
281285 generatePyiDeps : c .generatePyiDeps ,
282286 generateProto : c .generateProto ,
283287 resolveSiblingImports : c .resolveSiblingImports ,
288+ ignoredTargets : make (map [string ]struct {}),
284289 }
285290}
286291
@@ -610,6 +615,17 @@ func (c *Config) ResolveSiblingImports() bool {
610615 return c .resolveSiblingImports
611616}
612617
618+ // SetIgnoreTarget sets the target to be ignored.
619+ func (c * Config ) AddIgnoreTarget (target string ) {
620+ c .ignoredTargets [target ] = struct {}{}
621+ }
622+
623+ // IgnoreTarget returns whether the target should be ignored.
624+ func (c * Config ) IgnoreTarget (target string ) bool {
625+ _ , ignores := c .ignoredTargets [target ]
626+ return ignores
627+ }
628+
613629// FormatThirdPartyDependency returns a label to a third-party dependency performing all formating and normalization.
614630func (c * Config ) FormatThirdPartyDependency (repositoryName string , distributionName string ) label.Label {
615631 conventionalDistributionName := strings .ReplaceAll (c .labelConvention , distributionNameLabelConventionSubstitution , distributionName )
0 commit comments