is there a way to keep the `sources` field default...
# general
a
is there a way to keep the
sources
field default, but w/ some extras?
h
there is not. Which target type?
a
python_sources
👍 1
would be cool if it was available in macros or something. so you could do
Copy code
def a_macro(...):
  python_sources(
    sources=python_sources.sources.default + ['!the_devil.py'],
  )
h
It is possible to do that via the Target API! Which is pretty light-weight and declarative, no need to use Rules etc See the tool tip "Using the fields of a pre-existing target type". https://www.pantsbuild.org/v2.8/docs/target-api-new-targets#step-1-define-the-target-type. You'd use all the same fields except for subclassing
PythonSourcesGeneratingSourcesField
w/ a different
default
class property
It does require that you use a new symbol in your BUILD files rather than
python_sources
tho, just like macros
a
oh, yeah, can do it that way
h
There's a gotcha that "PluginFields" will not be registered on your new target type, which are all the fields like
skip_flake8
and
skip_mypy
If you need those, *you'll have to include them in the
core_fields
of your target. They're not in the
PythonSourcesGeneratorTarget.core_fields