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

Closed
DanielRosenwasser opened this issue Oct 21, 2023 · 3 comments
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

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
@heejaechang heejaechang self-assigned this Jul 8, 2024
@bschnurr bschnurr added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Jul 9, 2024
@heejaechang
Copy link
Contributor

new python.analysis.regenerateStdLibIndices option is added. if enabled, pylance will create stdlib indices per workspace rather than using prebuilt stdlib indices.

@heejaechang
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 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

4 participants