-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Milestone
Description
Bug description
When unpacking while iterating over dict.values() we seem to get a spurious warning about unbalanced dict unpacking.
Here's a test-case, result vs. result1 may require a few changes to the types, but the original code was doing a lot more dynamic things with callbacks and more.
from typing import Dict, Tuple, Callable
Inner = Callable[[int], Dict[str, int]]
def returns_dict(a:int, b:int) -> Dict[str, Tuple[int, int, int]]:
result1 = {
"abcdef": returns_things(a, b, "abcdef"),
"cdef": returns_other_things(a,b, "cdef"),
}
result = {
"abc": (1, 2, 3),
"cde": (1, 2, 3),
}
return result
def returns_things(a:int, b:int, c:str) -> Tuple[str, str, Inner]:
def inner(other: int) -> Dict[str, int]:
return {"called": other}
return f"{a}{b}", c, inner
def returns_other_things(a:int, b:int, c:str) -> Tuple[str, str, Inner]:
def inner(other: int) -> Dict[str, int]:
return {"called": other}
return f"{1}{c}", c, inner
def thing(a:int, b:int) -> None:
bar = returns_dict(a, b)
[print(x) for x in bar.values()]
for x, y, _z in bar.values():
assert x
assert y
if __name__ == "__main__":
thing(1, 2)
Configuration
No response
Command used
pylint pylint_testcase.py
Pylint output
************* Module pylint_testcase
pylint_testcase.py:32:4: W0644: Possible unbalanced dict unpacking with bar.values(): left side has 3 labels, right side has 2 values (unbalanced-dict-unpacking)
Expected behavior
No warning should happen
Pylint version
pylint 2.16.0
astroid 2.14.1
Python 3.11.1 (main, Jan 6 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]
OS / Environment
Fedora 37, x86_64
Additional dependencies
No response
aaron-skydio and thebarbershop
Metadata
Metadata
Assignees
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation