python / python/mypy

Decorated properties report error: "not callable" in mypy 1.7.1 and master

Open
#16,694 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report

Prior to mypy 1.7, we were able to add decorators on top of properties by adding a # type: ignore comment. In 1.7.1, the decorated attribute now errors on access with not callable [operator].

To Reproduce

https://mypy-play.net/?mypy=1.7.1&python=3.11&gist=12b3add6be6394238695b9b42c79d425

Expected Behavior

No errors.
Actual Behavior

main.py:20: error: "MyObj" not callable  [operator]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.7.1, master
  • Python version used: 3.11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the linked mypy-play example with mypy 1.7.1 or master and inspect the decorated property access reported at main.py:20. Trace how mypy handles the decorator, property, and call diagnostic, then verify that the example produces no errors while preserving the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.