Skip to content

Find library stubs in __pypackages__ #10633

Closed
@pawamoy

Description

@pawamoy

Feature

It seems mypy cannot find library stubs when developing a project using PEP582, for example through PDM. Not opening as a bug but rather as a feature request because PEP582 is still quite recent and therefore expected not to be supported everywhere.

$ pdm add -ds typing types-Jinja2
Adding packages to typing dev-dependencies: types-jinja2
✔ 🔒 Lock successful
Changes are written to pdm.lock.
Changes are written to pyproject.toml.
Synchronizing working set with lock file: 2 to add, 0 to update, 0 to remove

  ✔ Install types-Jinja2 2.11.0 successful
  ✔ Install types-MarkupSafe 1.1.0 successful

🎉 All complete!

$ ls __pypackages__/3.6/lib/jinja2-stubs/
bccache.pyi  compiler.pyi   debug.pyi     environment.pyi  ext.pyi      __init__.pyi  loaders.pyi    meta.pyi   optimizer.pyi  runtime.pyi  _stringdefs.pyi  utils.pyi
_compat.pyi  constants.pyi  defaults.pyi  exceptions.pyi   filters.pyi  lexer.pyi     METADATA.toml  nodes.pyi  parser.pyi     sandbox.pyi  tests.pyi        visitor.pyi

$ pdm run  mypy --config-file config/mypy.ini src/project tests duties.py
src/project/redacted.py:8: error: Library stubs not installed for "jinja2.sandbox" (or incompatible with Python 3.6)
src/project/redacted.py:8: note: Hint: "python3 -m pip install types-Jinja2"
src/project/redacted.py:8: note: (or run "mypy --install-types" to install all missing stub packages)
src/project/redacted.py:8: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 16 source files)

Pitch

Support running mypy in projects managed by tools like PDM that take advantage of PEP582.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions