Skip to content

stubgen misses generated modules #13904

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

Open
Avasam opened this issue Oct 15, 2022 · 0 comments
Open

stubgen misses generated modules #13904

Avasam opened this issue Oct 15, 2022 · 0 comments
Labels
bug mypy got something wrong topic-stubgen

Comments

@Avasam
Copy link
Contributor

Avasam commented Oct 15, 2022

Bug Report

When using stubgen to recursively generate stubs for a package, it misses dynamically generated modules.

To Reproduce
Example using cv2. Every module that doesn't come from a file is not picked-up:

import cv2
import inspect
[print(x) for x in inspect.getmembers(cv2, inspect.ismodule)] 
('', <module 'cv2' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\cv2\\__init__.py'>)
('Error', <module 'cv2.Error'>)
('_native', <module 'cv2.cv2' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\cv2\\cv2.pyd'>)
('cuda', <module 'cv2.cuda'>)
('cv2', <module 'cv2.cv2' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\cv2\\cv2.pyd'>)
('data', <module 'cv2.data' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\cv2\\data\\__init__.py'>)
('detail', <module 'cv2.detail'>)
('dnn', <module 'cv2.dnn'>)
('fisheye', <module 'cv2.fisheye'>)
('flann', <module 'cv2.flann'>)
('gapi', <module 'cv2.gapi' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\cv2\\gapi\\__init__.py'>)
('importlib', <module 'importlib' from 'C:\\Program Files\\Python39\\lib\\importlib\\__init__.py'>)
('ipp', <module 'cv2.ipp'>)
('load_config_py3', <module 'cv2.load_config_py3' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\cv2\\load_config_py3.py'>)
('mat_wrapper', <module 'cv2.mat_wrapper' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\cv2\\mat_wrapper\\__init__.py'>)
('misc', <module 'cv2.misc' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\cv2\\misc\\__init__.py'>)
('ml', <module 'cv2.ml'>)
('numpy', <module 'numpy' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\numpy\\__init__.py'>)
('ocl', <module 'cv2.ocl'>)
('ogl', <module 'cv2.ogl'>)
('os', <module 'os' from 'C:\\Program Files\\Python39\\lib\\os.py'>)
('parallel', <module 'cv2.parallel'>)
('samples', <module 'cv2.samples'>)
('segmentation', <module 'cv2.segmentation'>)
('sys', <module 'sys' (built-in)>)
('utils', <module 'cv2.utils' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\cv2\\utils\\__init__.py'>)
('version', <module 'cv2.version' from 'C:\\Users\\Avasam\\Documents\\Git\\typeshed\\.venv\\lib\\site-packages\\cv2\\version.py'>)
('videoio_registry', <module 'cv2.videoio_registry'>)

Expected Behavior

When running stubgen -p cv2, stubs should be generated for cv2.Error, cv2.cuda, cv2.detail, cv2.dnn, cv2.fisheye, cv2.flann, cv2.ipp, cv2.ml, cv2.ocl, cv2.ogl, cv2.parallel, cv2.samples, cv2.segmentation, and cv2.videoio_registry

Actual Behavior

They're not. The results seem to be what we get from import cv2; iport pkgutil; pkgutil.iter_modules(cv2.__path__)]

Your Environment

  • Mypy version used: 0.982 (compiled: yes)
  • Mypy command-line flags: stubgen -p cv2
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.9.13
@Avasam Avasam added the bug mypy got something wrong label Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-stubgen
Projects
None yet
Development

No branches or pull requests

2 participants