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

brash-student-40401

11/16/2022, 4:09 PM
I'm having some trouble running a goal after I added sources related to type checking. My
src/services/app/BUILD
currently looks like this:
Copy code
python_sources(
    name="app_sources",
    sources=[
        "mypy-stubs/stub1.pyi",
        "mypy-stubs/stub2.pyi",
    ]
)

pex_binary(
    name="app",
    entry_point="main.py",
    dependencies=[
        "src/vendor/python:reqs#setuptools",
    ],
    restartable=True,
)
With this definition,
./pants run src/services/app:app
, I get
ModuleNotFoundError: No module named 'services'
. When I remove the stubs from
python_sources
, the run command works fine, except then type checking fails. With this definition,
./pants dependencies
also doesn't show anything - it's as if adding the stubs completely negates any other dependencies. Clearly I've defined things wrong, but I can't seem to find how.
b

bitter-ability-32190

11/16/2022, 4:11 PM
By providing sources, you're overriding the default, so you probably wanna add those back in
b

brash-student-40401

11/16/2022, 4:21 PM
Didn't realize it overrode the defaults, thanks!
b

bitter-ability-32190

11/16/2022, 4:22 PM
I've been meaning to PR the defaults as an attribute of the target itself, but havent gotten to it
(e.g.
python_sources.sources.default
(or something)
🙌 1
w

wide-midnight-78598

11/16/2022, 4:27 PM
This is one of those principles of least surprise (ditto for default args). I don't know which is more surprising. In this case, I wouldn't assume defaults to apply, because you're setting the array. But in some of the
args
examples, I'm less certain and am usually surprised by the result
b

bitter-ability-32190

11/16/2022, 4:27 PM
@hundreds-father-404 and I wanna eventually rename
dependencies
as thats the only field where you're augmenting and not overriding
1
w

wide-midnight-78598

11/16/2022, 4:28 PM
? How so
At input time, are there other dependencies?
b

bitter-ability-32190

11/16/2022, 4:28 PM
Well, you're augmenting with the dep inference
It's... fuzzy 🙂
w

wide-midnight-78598

11/16/2022, 4:29 PM
I'd say that's after input time though. You're not overriding defaults, and it's non-destructive. 🤷
h

hundreds-father-404

11/16/2022, 4:30 PM
yeah, I really wanted to rename to
additional_deps
but got stuck on the
overrides
field not being automatically updated via our automated fixers. (Old name would still work, only deprecated)
https://github.com/pantsbuild/pants/issues/15022 if anyone is interested in taking on some AST fun 🙂
w

wide-midnight-78598

11/16/2022, 4:31 PM
I think we use
extra
in other places, but 🤷 I think "additional_deps" would confuse me
b

bitter-ability-32190

11/16/2022, 4:56 PM
I think one proposal was
explicit_deps
2
4 Views