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

Python curses module on Windows is never allowed to autocomplete #2763

Closed
lapraswastaken opened this issue May 3, 2022 · 4 comments
Closed
Assignees
Labels
fixed in next version (pyright) A fix has been implemented and will appear in an upcoming version skip-reassign Optional label that tells the issue automation bot to not reassign the owner

Comments

@lapraswastaken
Copy link

Environment data

  • Language Server version: 2022.4.3
  • OS and version: Windows 10 Home, 21H2
  • Python version): 3.10.2

Expected behavior

Autocompletion for the curses module should work on Windows, to support libraries like windows-curses.

Actual behavior

Autocompletion for the curses module doesn't work.

Code Snippet / Additional information

This can be replicated simply by importing the curses module and typing a dot after it:

image

After ctrl+clicking the curses import to get to its __init__.py file, there are multiple problems telling me that things aren't defined:

image
image

After ctrl+clicking the _curses import at the top of the init file, I see that anything in the curses module is only defined if sys.platform is not Windows:

image

I've installed windows-curses via pip and everything runs as it should, but I can't get autocompletion without removing the conditional.

@github-actions github-actions bot added the triage label May 3, 2022
@debonte
Copy link
Contributor

debonte commented May 3, 2022

Although the type stub files for curses that you mention above are shipped with Pylance, they come from https://github.com/python/typeshed. If you believe they should be changed, please file an issue there. If you do that, you might want to reference the PR that added the Windows platform check: python/typeshed#6749.

There's no mention of windows-curses in that PR's discussion, so when typeshed took that change, I'm not sure if they didn't realize that windows-curses existed, or if perhaps they wanted windows-curses to provide it's own dedicated stub file for some reason (ex. because windows-curses is not an official part of the stdlib). In any case, you might also want to open an issue on windows-curses asking them to provide a stub file.

For what it's worth, I'm working on a side-project that uses curses, so I feel your pain. I worked around this by copying _curses.pyi into a typings subdirectory off the root of my project, renaming it to curses.pyi, and then removing the sys.platform check. For more information on the typings directory, see the entry for stubPath here.

@TheStef56
Copy link

TheStef56 commented Apr 6, 2024

Although the type stub files for curses that you mention above are shipped with Pylance, they come from https://github.com/python/typeshed. If you believe they should be changed, please file an issue there. If you do that, you might want to reference the PR that added the Windows platform check: python/typeshed#6749.

There's no mention of windows-curses in that PR's discussion, so when typeshed took that change, I'm not sure if they didn't realize that windows-curses existed, or if perhaps they wanted windows-curses to provide it's own dedicated stub file for some reason (ex. because windows-curses is not an official part of the stdlib). In any case, you might also want to open an issue on windows-curses asking them to provide a stub file.

For what it's worth, I'm working on a side-project that uses curses, so I feel your pain. I worked around this by copying _curses.pyi into a typings subdirectory off the root of my project, renaming it to curses.pyi, and then removing the sys.platform check. For more information on the typings directory, see the entry for stubPath here.

Recently typeshed repo accepted a pull request making a change that lets pylance autocomplete when using curses on Windows. Can you update pylance so that it downloads the last version of typeshed?

@erictraut
Copy link
Contributor

@TheStef56, thanks for the heads up. I just updated the typeshed stubs in pyright. Pylance will pick those up the next time it syncs with pyright.

@debonte debonte added the fixed in next version (pyright) A fix has been implemented and will appear in an upcoming version label Apr 7, 2024
@debonte debonte self-assigned this Apr 7, 2024
@debonte debonte added the skip-reassign Optional label that tells the issue automation bot to not reassign the owner label Apr 7, 2024
@debonte debonte reopened this Apr 7, 2024
@debonte
Copy link
Contributor

debonte commented Apr 11, 2024

This issue has been fixed in prerelease version 2024.4.101, which we've just released. You can find the changelog here: CHANGELOG.md

@debonte debonte closed this as completed Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (pyright) A fix has been implemented and will appear in an upcoming version skip-reassign Optional label that tells the issue automation bot to not reassign the owner
Projects
None yet
Development

No branches or pull requests

4 participants