-
Notifications
You must be signed in to change notification settings - Fork 768
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
Pylance sometimes infers str and int types as Literal
types, which is something I have never wanted
#697
Comments
This is largely a duplicate of this issue: microsoft/pyright#1249. |
thanks, I googled "pylance github" and ended up at this repo, and then I actually searched the issues for "literal" before opening this one, but I didn't know to look in the pyright repo instead |
The fix for that issue will be in this week's Pylance release, so we'll be able to see what happens afterward. |
@jlxgcgcg, no worries. I wouldn't have expected you to know about the other repo. Thanks for submitting the suggestion. |
This issue has been fixed in version 2020.12.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020121-9-december-2020 |
This issue seems to be hot again in the current version (2023.7.30)!
to a function parameter type-hinted as
pylance infers |
@tthommes, this issue was fixed and closed nearly three years ago. If you think that you are experiencing a new bug, please file a new issue and provide a minimal, self-contained code sample. In your code sample above, for example, I don't know what the symbol |
I opened a new issue and fixed the code-example above. |
Environment data
Expected behaviour
This code should be well-typed:
Actual behaviour
I get an error:
If I add a type hint like
then it works, but I shouldn't have to do that. Having the types be
Literal['me']
andLiteral[1]
is something that I've basically never wanted (and I can't believe anyone else wants) and should not be the default inference.--
Here's another instance of the same problem:
The text was updated successfully, but these errors were encountered: