Skip to content

false negative?: unpacking Iterable to fixed length positional arguments #8618

Answered by erictraut
pinterior asked this question in Q&A
Discussion options

You must be logged in to vote

This behavior is intended, so I don't consider this a bug. The python typing spec does not specify whether a type checker should generate an error when using an unpack operator on an operand of unknown length. This is a behavior that should arguably be specified one way or another in the spec, but currently it is not. Pyright's current behavior is based on two principles:

  1. When code is potentially correct but also potentially a bug, pyright opts to avoid a false positive over a false negative. In this case, there's a false negative, but reporting this condition would result in false positives in valid Python code.
  2. Unless there's good reason to deviate from behaviors established by mypy, p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pinterior
Comment options

Answer selected by pinterior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants