I'm running into an error retrieving stubs when ru...
# general
n
I'm running into an error retrieving stubs when running
pants check ::
. I've reproduced the error in a minimal setup. Basically, I have one file which imports a third-party dep and a mypy_stub to include types for that 3rd party dep.
Copy code
# ./modules/validator.py
from email_validator import EmailNotValidError, validate_email
Copy code
# ./mypy_stubs/email_validator/__init__.pyi
... contains some typing info ...
pipenv run mypy
runs successfully on these files. However,
./pants check ::
will give me this error:
Copy code
modules/validator.py:1: error: Skipping analyzing "email_validator": module is installed, but missing library stubs or py.typed marker
My setup also exists here in this repo: https://github.com/chrisplim/pants-check-error-mypy-stub
b
I haven't tried running it yet, but the first thing to be aware of is that pants runs things in a sandbox, so that there's less chance of "works on my machine": if it works on one computer, it'll work on others in the same way. This does mean that pants needs to know about all of the dependencies and files for any given command. For your particular reproducer (which is very handy, thanks!), this would suggest that pants needs to know about the type stubs, by loading them into pants with a
BUILD
file and
python_sources()
target.
Okay, tested locally: I removed the
[tailor]
section entirely (including its
ignore_paths
setting) from
pants.toml
, and then ran
./pants tailor ::
. This generated a
BUILD
file along the lines of the previous comment. And then
./pants check ::
ran successfully So: I think this is fixed by making sure pants is told about any type stubs via
python_sources()
targets. Does that work for you?
h
type stubs are sources...
n
@broad-processor-92400 Thanks Huon, that was exactly it!