Skip to content
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

Stubtest does not understand functools.cached_property #17625

Closed
hamdanal opened this issue Aug 3, 2024 · 0 comments · Fixed by #17626
Closed

Stubtest does not understand functools.cached_property #17625

hamdanal opened this issue Aug 3, 2024 · 0 comments · Fixed by #17626
Assignees
Labels
bug mypy got something wrong topic-stubtest

Comments

@hamdanal
Copy link
Collaborator

hamdanal commented Aug 3, 2024

Bug Report

Stubtest reports cannot reconcile @property on stub with runtime object on functions decorated with cached_property.

To Reproduce

$ cat t.py
from functools import cached_property
class C:
    @cached_property
    def p(self):
        return 1

$ cat t.pyi
from functools import cached_property
class C:
    @cached_property
    def p(self) -> int: ...

$ PYTHONPATH=. stubtest t
error: t.C.p is inconsistent, cannot reconcile @property on stub with runtime object
Stub: in file /tmp/t.pyi:3
def (self: t.C) -> builtins.int
Runtime:
<functools.cached_property object at 0x7fa3228ce0f0>

Found 1 error (checked 1 module)

Expected Behavior

no error

Actual Behavior

error

Your Environment

  • Mypy version used: 1.11.1 and github master
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.12

Related: python/typeshed#12153

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

Successfully merging a pull request may close this issue.

1 participant