I am trying to add `mypy` to our project by follow...
# general
f
I am trying to add
mypy
to our project by following https://www.pantsbuild.org/docs/python-check-goal . However, whenever I run
./pants check ::
, it fails to find any third party library from our
requirements.txt
, e.g.,:
Copy code
File "/tmp/pants-sandbox-WbBUY8/.cache/pex_root/venvs/6633c908304aa46390e473de2960e553ff125f02/108a3ddc84230ab282ea6312e06cb68f51008ce5/pex", line 244, in <module>
    sys.exit(func())
File "/home/irvan/.cache/pants/named_caches/pex_root/venvs/s/8470873e/venv/lib/python3.9/site-packages/mypy/__main__.py", line 12, in console_entry

...

File "/tmp/pants-sandbox-WbBUY8/apps/solvent/celery/celery.py", line 1, in <module>
    from celery import Celery

ModuleNotFoundError: No module named 'celery'
The
requirements.txt
has the celery library:
Copy code
celery==5.2.7
I've been trying to debug this to no avail. This is what I tried so far: I noticed that the python virtual environment in the trace above (
/home/irvan/.cache/pants/named_caches/pex_root/venvs/s/8470873e/venv/lib/python3.9/site-packages/
) does not have celery installed. I tried the
extra_requirements
field mentioned here , but it does not seem to accept a filename, e.g.,
requirements.txt
. I could paste the entire content of
requirements.txt
into that field (This actually works from what I tried), but this seems very hacky. In case it helps, this is the current
mypy
settings in
pants.toml
. I am following the settings from the example django project.
Copy code
[mypy]
lockfile = "lockfiles/mypy.txt"
version = "mypy>=0.961"
interpreter_constraints = [">=3.9"]
extra_requirements.add = [
  # This is a mypy plugin, as well as a type stubs repository. So it must be mentioned
  # here as well as in requirements.txt.
  "django-stubs>=1.1,<2",
]
Thank you very much!