-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: enable reportMissingImports #43790
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
Conversation
Install Should |
@@ -1,6 +1,7 @@ | |||
import numpy as np | |||
|
|||
import pandas._tying as npt | |||
from pandas._typing import npt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could replace
from pandas._typing import npt
with
import numpy.typing as npt
in stub files, as I think they will not be executed at run-time - cannot fail even if an old version of numpy is installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, since we don't need to guard the import at run-time for stub files sgtm.
One option could be to enable reportMissingImports but add the following pyright comment to
xref #43751 (comment) |
looks fine to me. cc @simonjayhawkins |
Should probably wait until #43799 to not force contributors to install all dependencies. |
if you'd rebase (but lgtm). |
since clipboard is vendored, happy to exclude from all pyright checks and limit the use of module level comment syntax for pyright to pandas code |
in the pip secction of environment.yml we have some typing stubs imports
if the package has stubs we should include it here. if it is a typed library like numpy, then we already have it in environment.yaml so the missing import only becomes an issue if an older version of numpy is installed. I'm not sure what is best for untyped optional libraries without stubs packages. conda solver is already slow for our pandas-dev environment, but otoh happy to add pyxlsb as our dev env should probably have all optional dependencies installed to ensure local testing catches issues. (having some optional dependencies included in I assume that as pyxlsb is not a pytyped library and has no stubs, that the imports will resolve to Any. So we gain nothing from a typing perspective other than silencing the pyright warning by adding pyxlsb to So am also happy not to add. |
Fortunately, pyxlsb does not seem to list any dependencies, so it should be quick to resolve :) But enabling the pyright option would also mean that future potentially difficult to resolve packages will be added.
Unfortunately, pyxlsb has no type annotations.
We can catch some typos in pyi files. I was just trying flake8-pyi, it wouldn't have caught these two typos. Let me know what you think is more important. Happy to remove pyxlsb and not disable MissingImports. |
I'm not against enabling the pyright option so that the typos are caught. We can enable MissingImports without adding to environment.yaml using the module level pyright options syntax to disable MissingImports in just otherwise lgtm. |
thanks @twoertwein happy being strict here. |
reportMissingImports checks whether all libraries can be imported. This requires all dependencies to be installed on the CI that runs pyright.
This flag should probably NOT be enabled, as it would force all contributors to install all dependencies. I'm enabling it temporarily to see whether the CI has all dependencies installed.
edit:
The typing CI has not all packages installed: