- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 3k
 
Description
Bug Report
type: ignore[import-untyped] leaves a note that must be silenced with type: ignore[import], but only for one of the locations.
To Reproduce
Consider two files, a.py and b.py, both with this content:
import sentencepieceSince sentencepiece is a third-party package without type information, mypy complains:
$ mypy *.py
b.py:1: error: Skipping analyzing "sentencepiece": module is installed, but missing library stubs or py.typed marker  [import-untyped]
a.py:1: error: Skipping analyzing "sentencepiece": module is installed, but missing library stubs or py.typed marker  [import-untyped]
a.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 2 errors in 2 files (checked 2 source files)
So, let's try to shut up mypy, since our project can't do anything to fix that issue internally. First, I tried using disabled_error_codes in mypy.ini, and was met with issue #16002. Then, I tried adding type: ignore comments, like this:
import sentencepiece  # type: ignore[import-untyped]This doesn't really work:
$ mypy *.py
a.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
a.py:1: note: Error code "import" not covered by "type: ignore" comment
Success: no issues found in 2 source files
For one file only, mypy leaves a note providing a link to the documentation, with no associated error message.
This can be worked around by using type: ignore[import] on the line it complains about, but I don't know if that has to be done for just one of the files or all of them, and how mypy decides which one. I also don't want to hide other kinds of import errors, such as a package being missing entirely, or stubs that are available but not installed.
Your Environment
- Mypy version used: 
mypy 1.7.0+dev.9a0aca14724eeef580eefcd3b340678313a1930a (compiled: no) - Python version used: Python 3.11.3
 - Operating system and version: Arch Linux