mysterious-secretary-27586
06/28/2022, 10:07 AMmysterious-secretary-27586
06/28/2022, 10:07 AMmypy setup.
Within the repo we have several venvs managed by poetry. If a package does not include stubs, we add it as a dev dependency, e.g.
[tool.poetry.dev-dependencies]
types-ujson = "^5.3.0"
in one of our venv’s pyproject.toml file.
So far I have not been able to configure pants to pick up these stubs. Initially I thought I would be able to do so by including it in the BUILD like this:
poetry_requirements(
...
type_stubs_module_mapping={
"types-ujson": ["some_venv:poetry#ujson"]
}
}
but this did not help, I get an error
foo/bar.py:5: error: Library stubs not installed for "ujson" (or incompatible with Python 3.9)
foo/bar.py:5: note: Hint: "python3 -m pip install types-ujson"
The only way I managed to remove the error is to add something like ["types-ujson==5.3.0"] to [mypy].extra_type_stubs in pants.toml.
I am not a fan of this approach, because now I have to keep track of this package’s version in both pyproject.toml and pants.toml.
Is there a better way to do this?
Thanks!rhythmic-morning-87313
06/28/2022, 1:43 PMmysterious-secretary-27586
06/28/2022, 3:14 PMpython_requirements as we use poetry for venv. From my understanding python_requirements require a source field value, eg. requirements.txt.rhythmic-morning-87313
06/28/2022, 3:25 PMmysterious-secretary-27586
06/29/2022, 7:44 AM