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

lively-gpu-26436

05/01/2023, 7:36 PM
Hi, sorry if my mistake is so obvious, but I’m having a lot of trouble to skip mypy on test files using defaults. I was looking at this solution https://pantsbuild.slack.com/archives/C046T6T9U/p1671206395059209?thread_ts=1671196289.409119&cid=C046T6T9U but on my test project I’m not able to make it work: https://github.com/anler/pants-playground
c

curved-television-6568

05/01/2023, 7:48 PM
Try with
Copy code
__defaults__({python_tests: dict(skip_mypy=True)})
more details here https://www.pantsbuild.org/docs/targets#field-default-values sorry for the trouble
l

lively-gpu-26436

05/01/2023, 7:55 PM
oh darn so that was it, thanks a lot @curved-television-6568 I guess is time for me to take a break out from the computer 😅 🤦
c

curved-television-6568

05/01/2023, 7:56 PM
the suggestion from Benjy did have a typo in it, so not that easy to see the mistake when it wasn’t yours I’d say 😅
😓 1
l

lively-gpu-26436

05/01/2023, 7:57 PM
Nah I was reading the docs too but my brain just skipped the part when it mentions the dict and just assumed keywords for everything
🙃 1
c

curved-television-6568

05/01/2023, 7:59 PM
if there’s any tweak we can do to make it clearer also for the end-of-the-day head that would be great 🙂
l

lively-gpu-26436

05/01/2023, 8:04 PM
maybe a special reference page for
__defaults__
just as there is for targets would be useful for people with my weakness 😜
👍 1
I kind of think more in type signatures and tend to deal better with api references rather than other kinds of documentation
👀 1
c

curved-television-6568

05/01/2023, 8:15 PM
the reference pages are generated, but we could at least as a first step include a block with the type signature for it. come to think of it, we do have an help endpoint now (
pants symbols --help
) that we could perhaps incorporate into the generated references section.. 🤔
l

lively-gpu-26436

05/01/2023, 8:24 PM
well, that’s something new I’ve learnt! I’m going to be using it more
e

enough-analyst-54434

05/01/2023, 8:58 PM
Was something like
python_tests.defaults(<has same signature as constructor>)
in a baseclass considered?
c

curved-television-6568

05/01/2023, 9:08 PM
This is the main enhancement issue for the design doc for the
__defaults__
feature. In there, the
target.defaults(…)
was not surfaced as an alternative from what I recall. That syntax is appealing, however it lacks in it’s inability to apply to multiple target types at once.
e

enough-analyst-54434

05/01/2023, 9:09 PM
That lack seems like a feature to me! Easy to grok.
c

curved-television-6568

05/01/2023, 9:16 PM
I’d prefer correctness over easy to grok if having to chose one over the other (ideally I wouldn’t have to). Correctness being for example, I want to set
skip_mypy=True
for all supported target types in some subtree. With
__defaults__(all=dict(skip_mypy=True)
I don’t need to make sure I’ve provided it for all applicable targets (and also don’t have to go back to it in case there’s new target types added in the future be it by enabling another backend or as new features etc nor the other way in case a backend is disabled) that is done for me.
There are some nastyness with it though wrgt generated targets (as is called out in the docs)
e

enough-analyst-54434

05/01/2023, 9:19 PM
Sounds good. I don't grok Pants as I've said before.
c

curved-television-6568

05/01/2023, 9:19 PM
But for single target type defaults I find your suggestion superior.