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

plain-carpet-73994

05/10/2021, 11:50 PM
Unfortunately if I now get:
Copy code
16:45:19.88 [WARN] Ignoring `[python_setup].resolve_all_constraints` option because constraints file does not cover all requirements.
which I think means my
constraints.txt
is being ignored (I didn't quite grok the docs). That seems unfortunate. Note that the stubs are
git+http
style so I can't freeze them even if I did put them in the
<http://requirements.in|requirements.in>
. Is there no way to get these 3rd party type stubs but also keep the
constraints.txt
working?
h

hundreds-father-404

05/11/2021, 12:00 AM
Try 2.5.0rc0 if you're on 2.4. I think https://github.com/pantsbuild/pants/pull/11907 is mean to handle this case
p

plain-carpet-73994

05/11/2021, 12:13 AM
Thanks @hundreds-father-404. So putting this all together I think if we move to 2.5.0rc0 we can put the
git+https
requirements in our
<http://requirements.in|requirements.in>
but we'd still need to add an explicit dependency on any type stubs on any targets that use `numpy`; that part can't be made automatic. Is that correct?
It'd be really nice to have the equivalent of
module_mapping
like
stubs_mapping
so that it could be made automatic and not cause ambiguity.
h

hundreds-father-404

05/11/2021, 12:24 AM
Oh that's an interesting idea! Right now, we have special cased code so that we are fine with ambiguity when the type stub is first-party, like a
.pyi
file checked into your repo. I like the idea of allowing that for 3rd party code too Would you mind opening a GitHub issue with this idea please? https://github.com/pantsbuild/pants/issues
like a
.pyi
file checked into your repo
Which btw, you could use this as a workaround for now
👍 1
p

plain-carpet-73994

05/11/2021, 12:27 AM
h

hundreds-father-404

05/11/2021, 12:32 AM
Thank you! Would you have an interest in implementing this? If so, I'm happy to write some detailed instructions on how to go about it
p

plain-carpet-73994

05/11/2021, 12:37 AM
I'm afraid I don't have time at the moment, but some other time.
👍 1
h

hundreds-father-404

05/12/2021, 1:14 AM
@plain-carpet-73994 I'm starting work on this as a fun side project. One thing that would help me a lot if you have a few minutes to spare...research what are some common type stub libraries out there so that we can define a default
stubs_mapping
. For example,
{"numpy-stubs": ["numpy"]}
Or perhaps we don't even need that, it's enough to use the heuristic of the project name with
-stubs
removed, e.g.
numpy-stubs
defaults to the module
numpy
The special mapping is only relevant if there's a stubs library which doesn't follow that naming scheme
p

plain-carpet-73994

05/12/2021, 3:43 PM
That's great to hear! Not sure if a default makes sense. For example, there's more than 1 numpy type hinting library that I found. I think the really common stubs are already in typeshed so this would only be for less common libraries. For those I'm not sure there's much of a convention. Though I haven't had a reason to look for a lot of stubs until now. If I do detect a pattern I'll let you know.
👍 1
h

hundreds-father-404

06/09/2021, 5:42 AM
4 Views