mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-28 14:46:55 +08:00
Add __set__ to functools.cached_property (#9762)
This commit is contained in:
committed by
GitHub
parent
7b975dc144
commit
40d853cbe2
28
test_cases/stdlib/check_functools.py
Normal file
28
test_cases/stdlib/check_functools.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from functools import cached_property
|
||||
from typing_extensions import assert_type
|
||||
|
||||
class A:
|
||||
def __init__(self, x: int):
|
||||
self.x = x
|
||||
|
||||
@cached_property
|
||||
def x(self) -> int:
|
||||
return 0
|
||||
|
||||
assert_type(A(x=1).x, int)
|
||||
|
||||
class B:
|
||||
@cached_property
|
||||
def x(self) -> int:
|
||||
return 0
|
||||
|
||||
def check_cached_property_settable(x: int) -> None:
|
||||
b = B()
|
||||
assert_type(b.x, int)
|
||||
b.x = x
|
||||
assert_type(b.x, int)
|
||||
Reference in New Issue
Block a user