False negative with property and decorator
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Relates to #5858 (fixed in #15926)
from typing import Callable
class something_callable:
def __init__(self, fn):
self.fn = fn
def __call__(self, decorated_self, extra1, extra2, extra3) -> str:
return self.fn(decorated_self)
# def __call__(self) is also bad
def decorator(fn: Callable[..., int]) -> something_callable:
return something_callable(fn)
class A:
@property
@decorator
def f(self) -> int:
return 42
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 by running the supplied Python example through mypy and record the diagnostics for the property and decorator combination. Trace how mypy handles the callable decorator and property, then add or update a regression test so the false-negative behavior is covered and the intended diagnostic is produced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100