Skip to content

import itsdangerous.exc errors asking to --install-types even if it is already installed #10645

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

Closed
asottile opened this issue Jun 14, 2021 · 5 comments
Assignees
Labels
bug mypy got something wrong

Comments

@asottile
Copy link
Contributor

Bug Report

import itsdangerous.exc

To Reproduce

virtualenv venv
venv/bin/pip install mypy types-itsdangerous
venv/bin/mypy

Expected Behavior

no error

(Write what you thought would happen.)

Actual Behavior

$ venv/bin/mypy t.py 
t.py:1: error: Library stubs not installed for "itsdangerous.exc" (or incompatible with Python 3.8)
t.py:1: note: Hint: "python3 -m pip install types-itsdangerous"
t.py:1: note: (or run "mypy --install-types" to install all missing stub packages)
t.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.902
  • Mypy command-line flags: none, also tried --ignore-missing-imports
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.8.5
  • Operating system and version: ubuntu 20.04
@asottile asottile added the bug mypy got something wrong label Jun 14, 2021
@srittau
Copy link
Contributor

srittau commented Jun 14, 2021

I assume that's due to the fact that in typeshed, there is no itsdangerous.exc module. (In fact, there's only an itsdangerous.pyi file, not package at all.) So it's both a typeshed problem, but also something that mypy should probably not complain about.

@srittau
Copy link
Contributor

srittau commented Jun 14, 2021

Also: itsdangerous 2.0.0+ ships a py.typed file, so the recommendation to install its stubs makes no sense in that case.

@Zac-HD
Copy link
Contributor

Zac-HD commented Jun 15, 2021

Similarly,

from pytz.tzinfo import StaticTzInfo

complains that I should install types-pytz, even with that stubs package already installed, presumably because the stubs don't include any pytz submodules. I don't mind if typeshed has decided that this submodule is not public API, but mypy shouldn't tell me to install a package which is already installed!

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 15, 2021

There seem to be at least three issues.

First, --ignore-missing-imports not working for missing submodules when stubs are installed is a bug.

Second, since itsdangerous ships with py.typed, we should probably recommend installing the implementation package instead of stubs.

Third, typeshed is missing some submodules of pytz. This should be easy to fix, at least by providing placeholders with module-level __getattr__.

@JukkaL JukkaL self-assigned this Jun 18, 2021
JukkaL added a commit that referenced this issue Jun 18, 2021
If we encounter an import of a submodule of a package with installed
stubs, and the submodule doesn't exist, don't ask to install stubs
since that's not going to help. Also make it possible to ignore this
error using `--ignore-missing-imports`.

Work on #10645.
JukkaL added a commit that referenced this issue Jun 22, 2021
If we encounter an import of a submodule of a package with installed
stubs, and the submodule doesn't exist, don't ask to install stubs
since that's not going to help. Also make it possible to ignore this
error using `--ignore-missing-imports`.

Work on #10645.
JukkaL added a commit that referenced this issue Jun 22, 2021
If we encounter an import of a submodule of a package with installed
stubs, and the submodule doesn't exist, don't ask to install stubs
since that's not going to help. Also make it possible to ignore this
error using `--ignore-missing-imports`.

Work on #10645.
@asottile
Copy link
Contributor Author

seems fixed in 910 -- thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

4 participants