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
The observed behavior is a consequence of pyright's inference behavior for tuples. It retains literal values for "bare" tuple expressions but does not for tuple expressions that are nested within another container like a list expression.
Normally, bidirectional type inference would help here, but pyright's bidirectional inference logic doesn't currently handle overloaded __setitem__ methods like the one found in the list class.
Adding bidirectional type inference support for overloaded __setitem__ will be a moderate amount of work, but I think it's a reasonable enhancement request.
In the meantime, you can work around this limitation by using a temporary variable with an explicit type declaration.
Describe the bug
Assigning to a slice of a list fails to retain literal values
Code or Screenshots
Code sample in pyright playground
VS Code extension or command-line
Are you running pyright as a VS Code extension, a language server in another editor, integrated into Pylance, or the command-line tool? Which version?
I'm running it as a VS Code extension (the code package on Arch Linux). The version is v1.1.390
The text was updated successfully, but these errors were encountered: