Skip to content

Bug with overloaded property setter #509

@JelleZijlstra

Description

@JelleZijlstra
from typing import overload

class A:
    @property
    def t2(self) -> int:
        return 2

    @t2.setter
    @overload
    def t2(self, value: None) -> None:
        ...

    @t2.setter
    @overload
    def t2(self, value: int) -> None:
        ...

    @t2.setter
    def t2(self, value: int | None) -> None:
        ...

a = A()

a.t2 = None
main.py:24:0: Cannot call overloaded function [incompatible_call]
    In overload (self, value: None) -> None
      In call to main.A.t2: Missing required argument 'value'
    In overload (self, value: int) -> None
      In call to main.A.t2: Missing required argument 'value'

This should be allowed.

Also, if one of the overloads is deprecated, we should report the deprecation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions