Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running mypy with pdm #811

Closed
gitpushdashf opened this issue Dec 20, 2021 · 8 comments
Closed

Running mypy with pdm #811

gitpushdashf opened this issue Dec 20, 2021 · 8 comments
Labels
⬆️ upstream bug Caused by a bug from the upstream dependencies

Comments

@gitpushdashf
Copy link

  • [*] 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 gitpushdashf added the 🐛 bug Something isn't working label Dec 20, 2021
@gitpushdashf
Copy link
Author

Related: python/mypy#10633

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

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Dec 20, 2021

There's a discussion here as well: #751

@JaviFuentes94
Copy link

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

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Dec 21, 2021

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.

@frostming frostming added ⬆️ upstream bug Caused by a bug from the upstream dependencies and removed 🐛 bug Something isn't working labels Jan 20, 2022
@mferriz
Copy link

mferriz commented Feb 17, 2022

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!

@gitpushdashf
Copy link
Author

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.

@lyz-code
Copy link
Contributor

lyz-code commented Aug 12, 2022

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

@yakMM
Copy link

yakMM commented Jan 15, 2023

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

@pawamoy pawamoy closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⬆️ upstream bug Caused by a bug from the upstream dependencies
Projects
None yet
Development

No branches or pull requests

7 participants