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

.pyi file not detected for single .py file in site-packages #15817

Closed
brettcannon opened this issue Aug 4, 2023 · 1 comment
Closed

.pyi file not detected for single .py file in site-packages #15817

brettcannon opened this issue Aug 4, 2023 · 1 comment
Labels
bug mypy got something wrong

Comments

@brettcannon
Copy link
Member

brettcannon commented Aug 4, 2023

Bug Report

A .pyi file next to a top-level .py file in site-packages is not being picked up.

P.S.: Docs are also inconsistent on naming of stubs-only packages. https://mypy.readthedocs.io/en/stable/installed_packages.html#installed-packages says types-<name> and then later says <name>-stubs.

To Reproduce

  • Install microvenv
  • Write a microvenv.pyi file in site-packages next to microvenv.py
  • Run mypy with code importing microvenv

Example microvenv.pyi:

import os

def create(env_dir: os.PathLike[str] | str = ...) -> None: ...

Expected Behavior

No error about missing type stubs or py.typed.

Actual Behavior

nox > mypy src/py_pip.py
src/py_pip.py:11: error: Skipping analyzing "microvenv": module is installed, but missing library stubs or py.typed marker  [import]
src/py_pip.py:11: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

I verified the .pyi file worked by copying to the same directory as the code being analyzed.

Your Environment

  • Mypy version used: 1.4.1
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: Python 3.11.4
@brettcannon brettcannon added the bug mypy got something wrong label Aug 4, 2023
@JelleZijlstra
Copy link
Member

This is correct behavior as specified by PEP 561. See python/typing#1333 for discussion of how to change the spec.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2023
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