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

Mypy does not find lone module .pyi stubs in site-packages #16987

Closed
pwschaedler opened this issue Mar 5, 2024 · 1 comment
Closed

Mypy does not find lone module .pyi stubs in site-packages #16987

pwschaedler opened this issue Mar 5, 2024 · 1 comment
Labels
bug mypy got something wrong

Comments

@pwschaedler
Copy link

Bug Report

Mypy does not seem to resolve modules that consist of single-file .pyi files that sit directly in site-packages.

For example, the project pyodbc compiles to a single compiled module file, and its accompanying stub file sits with it in site-packages. However, mypy does not recognize this lone .pyi file and instead throws 'Cannot find implementation or library stub for module named "pyodbc" [import-not-found]'.

To Reproduce

python -m venv .venv
source .venv/bin/activate
pip install mypy==1.8.0 pyodbc==5.1.0
mypy -c 'import pyodbc'

Expected Behavior

I expect mypy to recognize the module in the same way Python does.

Actual Behavior

<string>:1: error: Cannot find implementation or library stub for module named "pyodbc"  [import-not-found]
<string>: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: 1.8.0
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.10.12
$ ls .venv/lib/python3.10/site-packages
_distutils_hack       mypy_extensions-1.0.0.dist-info  __pycache__                  tomli                                                        distutils-precedence.pth                typing_extensions.py
mypy                  pip                              pyodbc-5.1.0.dist-info       tomli-2.0.1.dist-info                                        mypy_extensions.py
mypy-1.8.0.dist-info  pip-23.0.1.dist-info             setuptools                   typing_extensions-4.10.0.dist-info                           pyodbc.cpython-310-x86_64-linux-gnu.so
mypyc                 pkg_resources                    setuptools-65.5.0.dist-info  6c7190bc8b55ffe67f57__mypyc.cpython-310-x86_64-linux-gnu.so  pyodbc.pyi
@pwschaedler pwschaedler added the bug mypy got something wrong label Mar 5, 2024
bazaah added a commit to bazaah/aur-ceph that referenced this issue Mar 16, 2024
This mocks out a module for mgr_module.py to 'import' during mypy
type analysis. Previously the ceph_module.pyi was enough for this to
work, but I guess something in the tooling changed.

I cannot figure out why this ever worked before, and why it doesn't
now.

Maybe related to python/mypy#16987 ?
bazaah added a commit to bazaah/aur-ceph that referenced this issue Mar 18, 2024
This mocks out a module for mgr_module.py to 'import' during mypy
type analysis. Previously the ceph_module.pyi was enough for this to
work, but I guess something in the tooling changed.

I cannot figure out why this ever worked before, and why it doesn't
now.

Maybe related to python/mypy#16987 ?
bazaah added a commit to bazaah/aur-ceph that referenced this issue Mar 23, 2024
This mocks out a module for mgr_module.py to 'import' during mypy
type analysis. Previously the ceph_module.pyi was enough for this to
work, but I guess something in the tooling changed.

I cannot figure out why this ever worked before, and why it doesn't
now.

Maybe related to python/mypy#16987 ?
@hauntsaninja
Copy link
Collaborator

Closing in favour of python/typing#1333

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Jun 22, 2024
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

2 participants