-
Notifications
You must be signed in to change notification settings - Fork 767
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
pygame: bundled stubs do not reexport submodules #758
Comments
@Bipul-Harsh I think this was mistriaged. We already ship type stubs for pygame so you should be seeing completions/IntelliSense. Do you have an example of where you weren't seeing IntelliSense? Also are you using the Pylance language server? |
Pylance is installed. actually after creating file import pygame on writing pygame.display. and then <ctrl+space> it says "no suggestions" But with jupyter notebook in vscode so i think it only works when you first import the pygame library in jupter notebook |
please consider checking the above case yourself. |
I've looked at the stub; the ones we bundle do not explicitly export the submodules, but it appears that upstream is implying that they do not need to be imported directly and that importing As a workaround, you can explicitly write |
Should I keep this issue open? Till the bug not get fixed. And thanks, for your suggestion. |
Yes, this is a bug in the stubs we ship, so we'll fix them. |
ok thanks |
@jakebailey pygame has maintained type definitions. I wonder why pylance specific ones necessary? |
Jake, @illume is correct. I just installed the latest version of pygame, it it has built-in type stubs, and they're relatively high-quality stubs at that. The library is marked as "py.typed". When I use pyright's "--verifytypes" command, it indicates that it is 80.2% type complete, which is relatively high.
With a small amount of work, we could probably get it close to 100%. Here's what I managed to achieve after about five minutes of fixing some obvious errors (adding missing imports in some stubs, making examples module private, etc.):
I recommend that we no longer bundle pygame stubs with pylance. We can eliminate our (incomplete) copy of the pygame stubs and contribute any further improvements to the pygame repo. |
Thanks. I believe we wrote and bundled these stubs many months ago, probably before pygame's were mature, so we could drop them if upstream is doing well. |
Hm, I'm testing this with
Were you testing with a dev version? |
Hmm, I installed the latest version from pypi and used that for my test. |
Is it 2.0.1? I tested on Linux and Windows, and got identical results (even with pyright from master, just to really check). Maybe there's some difference on Macs (and I'll pull mine out). EDIT: 2.0.1 on my mac is identical to the above. |
In any case, pygame 2.0 is the first py.typed version and the 70% coverage is much better than the ~6% coverage that the old version had, which I believe is what we had stubbed. |
Pygame 2.0.1 ships with a bunch of tests. I renamed the |
The next release drops the pygame stubs; upgrading to pygame 2.0+ brings in types (and as far as I can tell, 2.0 is backwards compatible with v1 by design). |
This issue has been fixed in version 2021.3.3, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202133-24-march-2021 |
i think intellisense part is still not working as by only importing Please consider doing it yourself. |
And thanks to all of you for your support to my issue. 😊 |
The pygame authors have written their type stubs to indicate that submodules like If you think that these submodules should be re-exported from the top-level module, you should contact the maintainers of pygame and ask them to make that change — or see if they would be willing to accept a PR. Here's the change that you'd need to make within import pygame.display needs to be changed to... from . import display as display PEP 484 indicates that the former statement means a local import only, whereas the second means "import and re-export from this module". |
ok i will do the method you suggested, leaving it here. Thanks |
I needed something to do that wasn't staring at matplotlib stubs, so I fixed all of the issues in pygame and sent over pygame/pygame#2537. |
Requesting for suggestion feature and intellisense for pygame.
A request for IntelliSense for pygame and suggestion feature, which is not currently there for it.
Right now doing ctrl + space didn't give any suggestions for this library.
The text was updated successfully, but these errors were encountered: