Skip to content

Support @deprecated on overloaded property setters #21593

Open

Description

@Viicos

Code sample in Mypy playground

from typing import overload
from warnings import deprecated

class A:
    @property
    def t1(self) -> int:
        ...

    @t1.setter
    @deprecated("Setting t is deprecated")
    def t1(self, value: int) -> None:
        ...

    @property
    def t2(self) -> int:
        ...

    @t2.setter
    @overload
    @deprecated("Setting t to None is deprecated")
    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.t1 = 1  # reported
a.t2 = None  # not reported

See also: https://discuss.python.org/t/107604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions