DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
https://docs.basedpyright.com
Other
1.2k stars 22 forks source link

Report error if unpacking an iterable of unknown size #821

Open npip99 opened 3 weeks ago

npip99 commented 3 weeks ago

Currently, if you attempt to unpack a length-3 tuple into 2 variables, we get this error.

image

I believe that if attempting to unpack a length-Unknown tuple into 2 variables, we should get a Tuple Size Mismatch; expected 2 but received unknown length error.


Example:

The following code does not throw a typing error currently,

image

This is because pydantic models have a tuple generator,

image

However, this tuple is of undefined length, so unpacking into (k, _) is inherently unsafe (And does actually crash the program in this case)

DetachHead commented 3 weeks ago

related: #348