-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cannot import packages added using sys.modules.update #3097
Comments
Not sure if this is related, but they also import packages like this:
And that doesn't work either. |
Which package is this? I tried |
Sorry, |
It looks like Are you using all default settings for pyright, or do you have a pyrightconfig.json file that overrides some of the defaults? In particular, do you have When you say "cannot import packages", what behavior are you seeing? Are you seeing the import interpreted as an I tried to repro the problem as reported, and I'm not seeing anything unexpected. |
I do not have stubs for it installed. Looks like there is some additional work going on to generate stubs for the aio aspect of it. While I'd love to have full type stubs, even just not having to ignore it for now would be great. I am using it through Pylance and standalone. Get the error with both. I tried with and without the I'm getting the error message: |
Hmm, I also just realized in a different project I don't have this issue. Let me see if I can sort out why i'm only seeing it in one project. |
Ok now I'm stumped. I can't reproduce this in a standalone project either. Only in this virtual env. I don't believe this to be a pyright bug, but I will report back here for the next time someone runs into this. |
Any debug output I should look at? |
Yeah, I'm pretty sure this isn't a bug in pyright. You could enable |
Ok. So I finally sorted out the problem. I had grpc-stubs installed, which are not compatible with If I remove the Is there a way to annotate that a package should only provide stubs for part of another package, or some other way to maintain the default type inference. Basically, pylance gives me some amount of type info when I don't have the stubs installed, but once the stubs are installed it can't find |
If you believe this is a bug in the stub package, you could contact the maintainer of that package and report the bug. |
Note: if you are reporting a wrong signature of a function or a class in the standard library, then the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues.
Describe the bug
GRPC imports an aio package using the following code in
grpc/__init__.py
:This makes pyright fail to find the package
grpc.aio
To Reproduce
Create a python file like so:
Expected behavior
Pyright should find the import
The text was updated successfully, but these errors were encountered: