pdm
pdm copied to clipboard
Running mypy with pdm
- [*] I have searched the issue tracker and believe that this is not a duplicate.
Steps to reproduce
(Write code that imports a 3rd party library that is typed.)
pdm add --dev mypy
pdm run mypy --strict .
Actual behavior
mypy
can't find the type hints.
Expected behavior
mypy
should be able to find the type hints, like it does with pipenv
, virtualenv
, poetry
, etc.
Related: https://github.com/python/mypy/issues/10633
Maybe not a pdm
bug specifically, but probably worth mentioning.
There's a discussion here as well: https://github.com/pdm-project/pdm/discussions/751
Same issue here. Currently blocking the adoption of pdm
at our team
Keep the upvotes coming on the mypy issue 🙂 I don't think there's anything PDM itself can do. I believe it's on mypy's side. Not sure what their constraints are, and why they can't use sys.path to find stubs.
I started using pdm
with mypy
today. I do not see issues when using pyproject.toml
to configure mypy
:
[tool.mypy]
disallow_untyped_defs = true
disallow_incomplete_defs = true
python_version = "3.8"
strict = true
show_error_codes = true
warn_unused_ignores = true
When the configuration is set as above, command pdm run mypy src/*py
executes as expected.
Hope this helps!
I started using
pdm
withmypy
today. I do not see issues when usingpyproject.toml
to configuremypy
:[tool.mypy] disallow_untyped_defs = true disallow_incomplete_defs = true python_version = "3.8" strict = true show_error_codes = true warn_unused_ignores = true
When the configuration is set as above, command
pdm run mypy src/*py
executes as expected.Hope this helps!
This definitely works, but unfortunately is very partial coverage. It's much better than none, but being able to do mypy --strict
is very helpful.
Looks like they closed the mypy issue, what implications does that have for this issue?
This can be closed imo, mypy is now properly working with __pypackages__