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

MAINT: mypy imports of Cython "modules" #11686

Closed
tylerjereddy opened this issue Mar 19, 2020 · 2 comments · Fixed by #11688
Closed

MAINT: mypy imports of Cython "modules" #11686

tylerjereddy opened this issue Mar 19, 2020 · 2 comments · Fixed by #11688
Labels
static typing Items related to static typing
Milestone

Comments

@tylerjereddy
Copy link
Contributor

For kicks following the merge of #11678, I checked on a module I'm familiar with by disabling the ignores and I see:

scipy/spatial/_spherical_voronoi.py:17: error: Module 'scipy.spatial' has no attribute '_voronoi'  [attr-defined]
scipy/spatial/_spherical_voronoi.py:18: error: Module 'scipy.spatial' has no attribute 'cKDTree'; maybe "KDTree"?  [attr-defined]

That's because those are Cython extension objects rather than pure Python modules.

Can be suppressed in this way with a simple inline comment--would we want to do this more broadly throughout code base?

diff --git a/scipy/spatial/_spherical_voronoi.py b/scipy/spatial/_spherical_voronoi.py
index f14b894aa..f7f86e540 100644
--- a/scipy/spatial/_spherical_voronoi.py
+++ b/scipy/spatial/_spherical_voronoi.py
@@ -14,8 +14,8 @@ Spherical Voronoi Code
 import warnings
 import numpy as np
 import scipy
-from . import _voronoi
-from scipy.spatial import cKDTree
+from . import _voronoi # type: ignore
+from scipy.spatial import cKDTree # type: ignore
 
 __all__ = ['SphericalVoronoi']
@tylerjereddy tylerjereddy added the static typing Items related to static typing label Mar 19, 2020
@person142
Copy link
Member

Ah-I am actually working on this right now. Currently handling by adding a bunch of

[mypy-scipy.sparse.linalg.dsolve._superlu]
ignore_missing_imports = True

to the conf file.

@person142
Copy link
Member

person142 commented Mar 19, 2020

PR for that soon, as I was working on it mypy found, if not a bug, at least an oddity which I'm making a preliminary PR for...

Edit: the preliminary PR is #11687.

person142 added a commit to person142/scipy that referenced this issue Mar 19, 2020
Closes scipy#11686.

In the first iteration of the ratchet, we just ignored all missing
imports. This:

- Adds a `mypy_requirements.txt` file that will add the latest version
  of the NumPy types and stops ignoring NumPy imports
- Ignores all other third party modules
- Ignores extension modules (for now) since mypy can't find those
  without stubs
@tylerjereddy tylerjereddy added this to the 1.5.0 milestone Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
static typing Items related to static typing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants