Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rouge8 opened this issue Dec 21, 2023 · 2 comments
Open
Labels
bug mypy got something wrong

Comments

@rouge8
Copy link

rouge8 commented Dec 21, 2023

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
@rouge8 rouge8 added the bug mypy got something wrong label Dec 21, 2023
@rouge8
Copy link
Author

rouge8 commented Feb 5, 2024

This was broken by #15926 cc @hauntsaninja

@ego-thales
Copy link

ego-thales commented Apr 15, 2025

+1
Same here:

def decorator(x: object) -> object: ...

class Foo:
    @decorator  # type: ignore[prop-decorator]
    @property
    def foo(self) -> None:
        return

    def bar(self) -> None:
        self.foo
error: "Foo" not callable  [operator]
            self.foo
            ^~~~~~~~

In my case, I wish to use decorator as a simple "wrapper flag" for a metaclass mechanism, that is unwrapped before class creation.

I know that it is explicitly stated that decorated properties are not supported, but it would be great to at least get away with this simple # type: ignore[prop-decorator] comment. Is there any ongoing investigation on this issue?

Thanks!
All the best :)


python 3.13.1
mypy 1.15.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants