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

Suggestions for new keywords added in 3.10 appear in older versions #1724

Closed
NCPlayz opened this issue Aug 25, 2021 · 4 comments
Closed

Suggestions for new keywords added in 3.10 appear in older versions #1724

NCPlayz opened this issue Aug 25, 2021 · 4 comments
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@NCPlayz
Copy link

NCPlayz commented Aug 25, 2021

Describe the bug
The match and case soft keywords added with the Structural Pattern Matching PEP 634 seem to be given as suggestions when typing an identifier, even if the current activated Python Environment doesn't accept the keyword. But, Pyright correctly complains that match statements require 3.10 or newer when writing a match statement.

To Reproduce

  1. Type the first letters of match or case
  2. Notice that the keywords are shown high on the list.

Expected behavior
Ideally, I don't think it should suggest keywords that aren't available on versions the Python Environment is using.

Screenshots or Code
Screenshot 2021-08-25 at 14 46 23
Screenshot 2021-08-25 at 14 46 58

VS Code extension or command-line
VS Code - Pylance: v2021.8.2 (Python 3.9.6)

@erictraut
Copy link
Contributor

This is related to a broader discussion about suggesting keywords. See #1712 for a discussion. Currently, we don't perform any filtering of suggested keywords based on context.

In any case, I'm going to transfer this issue to the pylance-release repo because it's not a core type checking issue.

@erictraut erictraut transferred this issue from microsoft/pyright Aug 25, 2021
@jakebailey
Copy link
Member

It's definitely like #1712, but I think that it would make sense to have different lists of keywords per Python version, since we know that already from the config anyway and can just not offer match and case as keywords for <3.10.

@jakebailey jakebailey added the enhancement New feature or request label Aug 25, 2021
@github-actions github-actions bot removed the triage label Aug 25, 2021
@jakebailey
Copy link
Member

The next release will conditionally offer async/await and match/case based on the current Python version.

Further discussion on contextual keywords can go on #1557.

@jakebailey jakebailey added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Aug 26, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.7.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202190-1-september-2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants