Skip to content

Stubtest does not understand functools.cached_property #17625

@hamdanal

Description

@hamdanal

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions