https://pantsbuild.org/ logo
#general
Title
# general
a

ambitious-actor-36781

11/04/2021, 1:06 AM
is there a way to keep the
sources
field default, but w/ some extras?
h

hundreds-father-404

11/04/2021, 1:07 AM
there is not. Which target type?
a

ambitious-actor-36781

11/04/2021, 1:07 AM
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

hundreds-father-404

11/04/2021, 1:26 AM
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

ambitious-actor-36781

11/04/2021, 1:28 AM
oh, yeah, can do it that way
h

hundreds-father-404

11/04/2021, 1:31 AM
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
4 Views