freezing-appointment-41336
06/09/2026, 4:48 PMpython_sources-like target, with some additional custom fields, and with a hardcoded resolve , non-overridable value.
I've set up a custom target class which uses the python_sources target's fields, but hardcodes the resolve field. When I run pants check pants-plugins/my_plugin:: , I get the following error indicating that pants is not distinguishing between my custom target, and the regular python_sources target. Is there a way to avoid this situation? In other words, how can I define my target so pants knows the difference between it and the python_sources target?
InvalidFieldChoiceException: Values for the 'resolve' field in target pants-plugins/my_plugin#__defaults__ must be one of ["hardcoded-resolve-value"], but "my_plugin" was provided.freezing-appointment-41336
06/09/2026, 4:52 PMclass MyCustomTarget(Target):
alias = "my_custom_target"
core_fields = (
*(FrozenOrderedSet(PythonSourcesGeneratorTarget.core_fields) - {PythonResolveField}),
MyHardcodedResolveField,
SomeOtherCustomField,
)freezing-appointment-41336
06/09/2026, 4:52 PMclass MyHardcodedResolveField(PythonResolveField):
default = "hardcoded-resolve-value"
valid_choices = ("hardcoded-resolve-value,)wide-midnight-78598
06/09/2026, 5:46 PMwide-midnight-78598
06/09/2026, 5:47 PMfreezing-appointment-41336
06/09/2026, 6:04 PMpython_sources target, but with some additional, non-python files attached as extra_sources. (Concretely, but likely way too in the weeds answer: I'm trying to define a custom target which will define an Airflow dag bundle, which is basically a collection of python files along with peripheral non-python/non-resource files).
I'm defining this target in a multi-resolve mono-repo, and we only allow for Airflow code to run within a dedicated resolve, hence the need for hardcoding and validating the resolve value.wide-midnight-78598
06/09/2026, 6:05 PMwide-midnight-78598
06/09/2026, 6:05 PMfreezing-appointment-41336
06/09/2026, 6:14 PMwide-midnight-78598
06/09/2026, 6:31 PMAh I see now. Is that the recommended approach when dealing with a "plural" target? I wasn't seeing examples of that in the plugins docs, so I didn't know if that was an internal pattern.That's the one I've seen/used myself. But that doesn't mean much other than I likely cargo culted it
we will have dag files scattered across arbitrary directoriesAh, got it. There are ways to do work recursively, but maybe a plugin isn't the worst idea, given that it feels like there will be "more" to do once you get this out of the way
freezing-appointment-41336
06/10/2026, 2:46 PMfreezing-appointment-41336
06/10/2026, 3:02 PMcore_fields of the existing target (like this doc section recommends)?
I'd like to create a target that is very nearly the same as pants' PythonSourceTarget , but with some custom dependency gathering logic along with extra fields, and some hardcoded core fields. To me it seems subclassing is the cleaner, clearer approach.worried-painter-31382
06/10/2026, 3:08 PMfreezing-appointment-41336
06/16/2026, 12:36 PM