pdm icon indicating copy to clipboard operation
pdm copied to clipboard

Running mypy with pdm

Open gitpushdashf opened this issue 3 years ago • 7 comments

  • [*] 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.

gitpushdashf avatar Dec 20 '21 20:12 gitpushdashf

Related: https://github.com/python/mypy/issues/10633

Maybe not a pdm bug specifically, but probably worth mentioning.

gitpushdashf avatar Dec 20 '21 20:12 gitpushdashf

There's a discussion here as well: https://github.com/pdm-project/pdm/discussions/751

pawamoy avatar Dec 20 '21 20:12 pawamoy

Same issue here. Currently blocking the adoption of pdm at our team

JaviFuentes94 avatar Dec 21 '21 11:12 JaviFuentes94

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.

pawamoy avatar Dec 21 '21 14:12 pawamoy

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!

mferriz avatar Feb 17 '22 02:02 mferriz

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!

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.

gitpushdashf avatar Jun 06 '22 17:06 gitpushdashf

Looks like they closed the mypy issue, what implications does that have for this issue?

lyz-code avatar Aug 12 '22 16:08 lyz-code

This can be closed imo, mypy is now properly working with __pypackages__

yakMM avatar Jan 15 '23 16:01 yakMM