Skip to content

Commit 4b6d933

Browse files
use positive logic
1 parent 4d5cc71 commit 4b6d933

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

asyncstdlib/functools.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)