Skip to content

pylint tracks the wrong return type of an overloaded function #10721

@ziyuang

Description

@ziyuang

Bug description

from typing import overload


@overload
def f(x: int, y: int) -> tuple[int, int]:
    ...


@overload
def f(x: int, y: int, z: int) -> tuple[int, int, int]:
    ...


def f(x: int, y: int, z: int | None = None) -> tuple[int, int] | tuple[int, int, int]:
    return (x, y) if z is None else (x, y, z)


def main():
    _, _ = f(1, 2)
    _, _, _ = f(1, 2, 3)

Configuration

Command used

pylint a.py

Pylint output

************* Module a
a.py:20: W0632 Possible unbalanced tuple unpacking with sequence defined at line 15: left side has 3 labels, right side has 2 values

Expected behavior

No error.

Pylint version

pylint 3.3.8
astroid 3.3.11
Python 3.10.9 (main, May  9 2024, 07:44:19) [GCC 13.2.0]

OS / Environment

$ uname -a
Linux <hostname> 6.8.0-86-generic #87-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 22 18:03:36 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions