Pattern matching list literals yields incorrect type check errors #2475
Labels
bug
Something isn't working
fixed in next version (main)
A fix has been implemented and will appear in an upcoming version
If a list literal is used directly as the argument to a
match
statement, then Pylance seems to want a wildcard case, or else it thinks the match will fall through, even if the other cases cover all possible types.If the list is bound to a variable instead, then no type check error occurs, as expected.
Environment data
Expected behaviour
The code passes the type check with no errors regardless of whether the list is a variable or literal.
Actual behaviour
Pylance reports an error:
Logs
Code Snippet / Additional information
Causes error:
Doesn't cause error:
The text was updated successfully, but these errors were encountered: