-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Error when importing Cython modules #8575
Comments
Hi! Mypy doesn't actually import or interact with C extension code. It can only parse and gain type information from
is because mypy cannot find neither The following should not pass typecheck if
When I try |
Thanks for the explanations @ethanhs!
Yes, you are right. One important information that I forgot to mention is that I was running mypy with the $ mypy --ignore-missing-import -c "from sklearn.manifold import _barnes_hut_tsne"
<string>:1: error: Module 'sklearn.manifold' has no attribute '_barnes_hut_tsne'
Found 1 error in 1 file (checked 1 source file)
$ mypy --ignore-missing-import -c "from sklearn.manifold._barnes_hut_tsne import gradient"
Success: no issues found in 1 source file without the flag, they both error indeed, $ mypy -c "from sklearn.manifold._barnes_hut_tsne import gradient"
<string>:1: error: Skipping analyzing 'sklearn.manifold._barnes_hut_tsne': found module but no type hints or library stubs
<string>:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file) So it looks like it's expected behavior. Closing. Thanks again! |
I'm trying to fix mypy issues in scikit-learn (scikit-learn/scikit-learn#16726) and have a question/observation about C and Cython modules.
Say
package
has a_lib.pyx
Cython extension, which defines a function_lib_func
. The following passes mypy without errors,however,
produces the following error,
Are there any workaround for importing the complete C extension module and not only functions/classes it contains (short of using
type: ignore
at the import line)?Example
Sorry I don't have a minimal reproducible example, I can make one if necessary. An actual example I run into,
sklearn/manifold/_barnes_hut_tsne.pyx
Cython extension module.Versions
The text was updated successfully, but these errors were encountered: