pylint icon indicating copy to clipboard operation
pylint copied to clipboard

New checker - `unbalanced-dictionary-unpacking`

Open mbyrnepr2 opened this issue 2 years ago • 3 comments

Bug description

Also mentioned in discussion in https://github.com/PyCQA/pylint/issues/5113.

The following situation does not issue a message from Pylint: a.py:

for a, b, c, d, e, f, g in {1: 2}.items():
    pass

On the other hand, Python gives:

Traceback (most recent call last):
  File "a.py", line 1, in <module>
    for a, b, c, d, e, f, g in {1: 2}.items():
ValueError: not enough values to unpack (expected 7, got 2)

Configuration

No response

Command used

pylint a.py

Pylint output

No output

Expected behavior

Emit a message indicating the unpacking error.

Pylint version

pylint 2.13.0-dev0
astroid 2.9.3
Python 3.10.0b2 (v3.10.0b2:317314165a, May 31 2021, 10:02:22) [Clang 12.0.5 (clang-1205.0.22.9)]

OS / Environment

No response

Additional dependencies

No response

mbyrnepr2 avatar Feb 11 '22 22:02 mbyrnepr2

Is this a false negative or a new message? And if the latter, can we come up with a good name for a good message?

DanielNoord avatar Feb 12 '22 00:02 DanielNoord

Good point @DanielNoord - I thought one of the existing unpacking checkers could cover it but perhaps not.

Perhaps unbalanced-dictionary-unpacking?

mbyrnepr2 avatar Feb 12 '22 08:02 mbyrnepr2

Yeah that works for me!

DanielNoord avatar Feb 12 '22 18:02 DanielNoord