Quick fix suggests importing symbol that is not available in `pythonVersion`
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
- 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.
Note also that if I explicitly have typing-extensions installed, I only get a quick fix from typing not typing_extensions.
new python.analysis.regenerateStdLibIndices option is added. if enabled, pylance will create stdlib indices per workspace rather than using prebuilt stdlib indices.
This issue has been fixed in prerelease version 2024.7.100, which we've just released. You can find the changelog here: CHANGELOG.md