Support `@deprecated` on overloaded property setters
Open
Nobody has claimed this yet.
feature
topic-overloads
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Mypy playground reproduction in the issue and compare how the deprecated single setter and overloaded setter are handled. Trace the type-checking entry point for property assignments; done means assigning None to t2 reports the deprecated warning without changing the existing t1 behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 56/100