File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -254,7 +254,9 @@ async def data(self):
254254 Instances on which a value is to be cached must have a
255255 ``__dict__`` attribute that is a mutable mapping.
256256 """
257- if isinstance (type_or_getter , type ) and issubclass (
257+ if iscoroutinefunction (type_or_getter ):
258+ return CachedProperty (type_or_getter )
259+ elif isinstance (type_or_getter , type ) and issubclass (
258260 type_or_getter , AsyncContextManager
259261 ):
260262
@@ -269,14 +271,9 @@ def decorator(
269271 )
270272
271273 return decorator
272-
273- if not iscoroutinefunction (
274- type_or_getter # pyright: ignore[reportUnknownArgumentType]
275- ):
274+ else :
276275 raise ValueError ("cached_property can only be used with a coroutine function" )
277276
278- return CachedProperty (type_or_getter )
279-
280277
281278__REDUCE_SENTINEL = Sentinel ("<no default>" )
282279
You can’t perform that action at this time.
0 commit comments