You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the past I was seeing the TypedDict editor hints even though my project interpreter was 36. I was surprised that it worked but I liked it. Now it does not type check at all.
Don't know when it last worked, or when it stopped working other than this year.
Actual behavior
(variable) Config: Unknown
Illegal type annotation: variable not allowed unless it is a type aliasPylance[reportGeneralTypeIssues](https://github.com/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md#diagnostic-severity-rules)
Variables are not allowed within type annotations. In this code snippet, Config is considered a variable (as opposed to a type alias) because it is assigned more than one value on different code paths. A static type analyzer cannot determine which of these code paths will be taken at runtime, so it cannot determine which type definition of Config should be used for static analysis purposes.
The recommended approach here is to leverage typing_extensions for backward compatibility.
If, for some reason, you don't want to take a dependency on typing_extensions, then the recommended approach is to use a sys.version_info conditional rather than a try statement.
Ok cool. Again I was surprised it worked at all before, but it did so I went with it. Seems to be broken as intended now then.
A static type analyzer cannot determine which of these code paths will be taken at runtime, so it cannot determine which type definition of Config should be used for static analysis purposes.
It did pick something before though. Unless there was result caching nonsense going on.
Environment data
uname -v
: 138~18.04.1-Ubuntupython3 --version
: Python 3.6.9. (/usr/bin/python3
)Code Snippet
Repro Steps
Expected behavior
No errors or warnings in the file.
In the past I was seeing the TypedDict editor hints even though my project interpreter was 36. I was surprised that it worked but I liked it. Now it does not type check at all.
Don't know when it last worked, or when it stopped working other than this year.
Actual behavior
Logs
The text was updated successfully, but these errors were encountered: