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

Quick fix suggests importing symbol that is not available in pythonVersion #4993

Open
DanielRosenwasser opened this issue Oct 21, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@DanielRosenwasser
Copy link
Member

Environment data

  • Language Server version: 2023.10.40
  • OS and version: Linux
  • Python version: 3.11

Code Snippet

pyrightconfig.json

{
    "typeCheckingMode": "strict",
    "reportImplicitOverride": "error",
    "pythonVersion": "3.11",
    "include": [
        "**/*",
    ],
}

file.py

class A:
    def method(self):
        pass

class B(A):
    @override
    def method(self):
        pass

Repro Steps

  1. Request a quick fixes on override

Actual behavior

Pylance suggests "from typing import override" even though that won't work unless I'm using Python 3.12. The same is true for auto-import completions.

Expected behavior

There should be no provided quick fix.

Alternatively, I'd take the quick fix as long as I can get an error telling me it's not going to work based on the configured version of Python being too old.

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Oct 21, 2023
@DanielRosenwasser
Copy link
Member Author

DanielRosenwasser commented Oct 21, 2023

Note also that if I explicitly have typing-extensions installed, I only get a quick fix from typing not typing_extensions.

@debonte debonte changed the title Quick fix generates invalid import Quick fix suggests importing symbol that is not availble in pythonVersion Dec 1, 2023
@debonte debonte added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Dec 1, 2023
@debonte debonte changed the title Quick fix suggests importing symbol that is not availble in pythonVersion Quick fix suggests importing symbol that is not available in pythonVersion Jan 30, 2024
@debonte debonte assigned bschnurr and unassigned debonte Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants