Skip to content

Commit fc616a6

Browse files
committed
Improve docstring
1 parent b226d90 commit fc616a6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

temporalio/activity.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,23 @@ def wait_sync(self, timeout: Optional[float] = None) -> None:
279279
def client() -> Client:
280280
"""Return a Temporal Client for use in the current activity.
281281
282+
The client is only available in `async def` activities.
283+
284+
In tests it is not available automatically, but you can pass a client when creating a
285+
:py:class:`temporalio.testing.ActivityEnvironment`.
286+
282287
Returns:
283288
:py:class:`temporalio.client.Client` for use in the current activity.
284289
285290
Raises:
286-
RuntimeError: When not in an activity.
291+
RuntimeError: When the client is not available.
287292
"""
288293
client = _Context.current().client
289294
if not client:
290295
raise RuntimeError(
291-
"No client available. The client is only available in async "
292-
"(i.e. `async def`) activities; not in sync (i.e. `def`) activities. "
293-
"In tests you can pass a client when creating ActivityEnvironment."
296+
"No client available. The client is only available in `async def` "
297+
"activities; not in `def` activities. In tests you can pass a "
298+
"client when creating ActivityEnvironment."
294299
)
295300
return client
296301

0 commit comments

Comments
 (0)