mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-06-24 09:48:39 +08:00
[functools] Allow method override with @cache decorator (#15238)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from functools import cached_property, wraps
|
||||
from functools import cache, cached_property, wraps
|
||||
from typing import Callable, TypeVar
|
||||
from typing_extensions import ParamSpec, assert_type
|
||||
|
||||
@@ -96,3 +96,15 @@ class Y(X):
|
||||
@cached_property
|
||||
def some(self) -> Child: # safe override
|
||||
return Child()
|
||||
|
||||
|
||||
class CachedParent:
|
||||
@cache
|
||||
def method(self) -> Parent:
|
||||
return Parent()
|
||||
|
||||
|
||||
class CachedChild(CachedParent):
|
||||
@cache
|
||||
def method(self) -> Child:
|
||||
return Child()
|
||||
|
||||
Reference in New Issue
Block a user