Skip to content

Commit 96e2dab

Browse files
Doc fixes (#1241)
* Upgrade pydoctor and fix nexus docs * Fix pydoctor warnings and raise warnings as errors when generating docs * run formatter
1 parent 3400d8c commit 96e2dab

File tree

19 files changed

+73
-56
lines changed

19 files changed

+73
-56
lines changed

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dev = [
4444
"mypy-protobuf>=3.3.0,<4",
4545
"psutil>=5.9.3,<6",
4646
"pydocstyle>=6.3.0,<7",
47-
"pydoctor>=24.11.1,<25",
47+
"pydoctor>=25.10.1,<26",
4848
"pyright==1.1.403",
4949
"pytest~=7.4",
5050
"pytest-asyncio>=0.21,<0.22",
@@ -158,6 +158,7 @@ intersphinx = [
158158
"https://docs.python.org/3/objects.inv",
159159
"https://googleapis.dev/python/protobuf/latest/objects.inv",
160160
"https://opentelemetry-python.readthedocs.io/en/latest/objects.inv",
161+
"https://nexus-rpc.github.io/sdk-python/objects.inv",
161162
]
162163
privacy = [
163164
"PRIVATE:temporalio.bridge",
@@ -177,6 +178,7 @@ privacy = [
177178
]
178179
project-name = "Temporal Python"
179180
sidebar-expand-depth = 2
181+
warnings-as-errors = true
180182

181183
[tool.pyright]
182184
enableTypeIgnoreComments = true

temporalio/activity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def wait_sync(self, timeout: Optional[float] = None) -> None:
288288
def client() -> Client:
289289
"""Return a Temporal Client for use in the current activity.
290290
291-
The client is only available in `async def` activities.
291+
The client is only available in ``async def`` activities.
292292
293293
In tests it is not available automatically, but you can pass a client when creating a
294294
:py:class:`temporalio.testing.ActivityEnvironment`.

temporalio/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ def to_canonical_string(self) -> str:
10881088
@staticmethod
10891089
def from_canonical_string(canonical: str) -> WorkerDeploymentVersion:
10901090
"""Parse a version from a canonical string, which must be in the format
1091-
`<deployment_name>.<build_id>`. Deployment name must not have a `.` in it.
1091+
`<deployment_name>.<build_id>`. Deployment name must not have a ``.`` in it.
10921092
"""
10931093
parts = canonical.split(".", maxsplit=1)
10941094
if len(parts) != 2:

temporalio/contrib/openai_agents/workflow.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ def activity_as_tool(
6060
of inputs and outputs between the agent and the activity. Note that if you take a context,
6161
mutation will not be persisted, as the activity may not be running in the same location.
6262
63+
For undocumented arguments, refer to :py:mod:`workflow` and :py:meth:`start_activity`
64+
6365
Args:
6466
fn: A Temporal activity function to convert to a tool.
6567
strict_json_schema: Whether the tool should follow a strict schema.
6668
See https://openai.github.io/openai-agents-python/ref/tool/#agents.tool.FunctionTool.strict_json_schema
67-
For other arguments, refer to :py:mod:`workflow` :py:meth:`start_activity`
69+
6870
6971
Returns:
7072
An OpenAI agent tool that wraps the provided activity.
@@ -178,7 +180,7 @@ def nexus_operation_as_tool(
178180
of inputs and outputs between the agent and the operation.
179181
180182
Args:
181-
fn: A Nexus operation to convert into a tool.
183+
operation: A Nexus operation to convert into a tool.
182184
service: The Nexus service class that contains the operation.
183185
endpoint: The Nexus endpoint to use for the operation.
184186
strict_json_schema: Whether the tool should follow a strict schema

temporalio/envconfig.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class ClientConfigProfile:
184184
"""Represents a client configuration profile.
185185
186186
This class holds the configuration as loaded from a file or environment.
187-
See `to_connect_config` to transform the profile to `ClientConnectConfig`,
187+
See `to_client_connect_config` to transform the profile to `ClientConnectConfig`,
188188
which can be used to create a client.
189189
190190
.. warning::
@@ -304,8 +304,8 @@ class ClientConfig:
304304
"""Client configuration loaded from TOML and environment variables.
305305
306306
This contains a mapping of profile names to client profiles. Use
307-
`ClientConfigProfile.to_connect_config` to create a `ClientConnectConfig`
308-
from a profile. See `load_profile` to load an individual profile.
307+
`ClientConfigProfile.to_client_connect_config` to create a `ClientConnectConfig`
308+
from a profile. See `ClientConfigProfile.load` to load an individual profile.
309309
310310
.. warning::
311311
Experimental API.

temporalio/nexus/__init__.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,28 @@
66
See https://github.com/temporalio/sdk-python/tree/main#nexus
77
"""
88

9-
from ._decorators import workflow_run_operation as workflow_run_operation
10-
from ._operation_context import Info as Info
11-
from ._operation_context import LoggerAdapter as LoggerAdapter
12-
from ._operation_context import NexusCallback as NexusCallback
9+
from ._decorators import workflow_run_operation
1310
from ._operation_context import (
14-
WorkflowRunOperationContext as WorkflowRunOperationContext,
11+
Info,
12+
LoggerAdapter,
13+
NexusCallback,
14+
WorkflowRunOperationContext,
15+
client,
16+
in_operation,
17+
info,
18+
logger,
19+
)
20+
from ._token import WorkflowHandle
21+
22+
__all__ = (
23+
"workflow_run_operation",
24+
"Info",
25+
"LoggerAdapter",
26+
"NexusCallback",
27+
"WorkflowRunOperationContext",
28+
"client",
29+
"in_operation",
30+
"info",
31+
"logger",
32+
"WorkflowHandle",
1533
)
16-
from ._operation_context import client as client
17-
from ._operation_context import in_operation as in_operation
18-
from ._operation_context import info as info
19-
from ._operation_context import logger as logger
20-
from ._token import WorkflowHandle as WorkflowHandle

temporalio/nexus/_operation_context.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import temporalio.api.common.v1
2424
import temporalio.api.workflowservice.v1
2525
import temporalio.common
26-
from temporalio.nexus import _link_conversion
27-
from temporalio.nexus._token import WorkflowHandle
2826
from temporalio.types import (
2927
MethodAsyncNoParam,
3028
MethodAsyncSingleParam,
@@ -34,6 +32,13 @@
3432
SelfType,
3533
)
3634

35+
from ._link_conversion import (
36+
nexus_link_to_workflow_event,
37+
workflow_event_to_nexus_link,
38+
workflow_execution_started_event_link_from_workflow_handle,
39+
)
40+
from ._token import WorkflowHandle
41+
3742
if TYPE_CHECKING:
3843
import temporalio.client
3944

@@ -162,7 +167,7 @@ def _get_workflow_event_links(
162167
) -> list[temporalio.api.common.v1.Link.WorkflowEvent]:
163168
event_links = []
164169
for inbound_link in self.nexus_context.inbound_links:
165-
if link := _link_conversion.nexus_link_to_workflow_event(inbound_link):
170+
if link := nexus_link_to_workflow_event(inbound_link):
166171
event_links.append(link)
167172
return event_links
168173

@@ -182,14 +187,13 @@ def _add_outbound_links(
182187
wf_event_links.append(link.workflow_event)
183188
if not wf_event_links:
184189
wf_event_links = [
185-
_link_conversion.workflow_execution_started_event_link_from_workflow_handle(
190+
workflow_execution_started_event_link_from_workflow_handle(
186191
workflow_handle,
187192
self.nexus_context.request_id,
188193
)
189194
]
190195
self.nexus_context.outbound_links.extend(
191-
_link_conversion.workflow_event_to_nexus_link(link)
192-
for link in wf_event_links
196+
workflow_event_to_nexus_link(link) for link in wf_event_links
193197
)
194198
except Exception as e:
195199
logger.warning(

temporalio/nexus/_operation_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async def _cancel_workflow(
9191
9292
Args:
9393
token: The token of the workflow to cancel. kwargs: Additional keyword arguments
94-
to pass to the workflow cancel method.
94+
to pass to the workflow cancel method.
9595
"""
9696
try:
9797
nexus_workflow_handle = WorkflowHandle[Any].from_token(token)

temporalio/nexus/_util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_workflow_run_start_method_input_and_output_type_annotations(
3939
]:
4040
"""Return operation input and output types.
4141
42-
`start` must be a type-annotated start method that returns a
42+
``start`` must be a type-annotated start method that returns a
4343
:py:class:`temporalio.nexus.WorkflowHandle`.
4444
"""
4545
input_type, output_type = _get_start_method_input_and_output_type_annotations(start)
@@ -125,7 +125,7 @@ def get_operation_factory(
125125
Optional[Callable[[Any], Any]],
126126
Optional[nexusrpc.Operation[Any, Any]],
127127
]:
128-
"""Return the :py:class:`Operation` for the object along with the factory function.
128+
"""Return the :py:class:`nexusrpc.Operation` for the object along with the factory function.
129129
130130
``obj`` should be a decorated operation start method.
131131
"""
@@ -145,7 +145,7 @@ def set_operation_factory(
145145
obj: Any,
146146
operation_factory: Callable[[Any], Any],
147147
) -> None:
148-
"""Set the :py:class:`OperationHandler` factory for this object.
148+
"""Set the :py:class:`nexusrpc.handler.OperationHandler` factory for this object.
149149
150150
``obj`` should be an operation start method.
151151
"""
@@ -158,7 +158,7 @@ def set_operation_factory(
158158
#
159159
# This file is licensed under the MIT License.
160160
def is_async_callable(obj: Any) -> bool:
161-
"""Return True if `obj` is an async callable.
161+
"""Return True if ``obj`` is an async callable.
162162
163163
Supports partials of async callable class instances.
164164
"""

temporalio/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Runtime:
6969
thread pool is created.
7070
7171
Runtimes do not work across forks. Advanced users should consider using
72-
:py:meth:`prevent_default` and `:py:meth`set_default` to ensure each
72+
:py:meth:`prevent_default` and :py:meth:`set_default` to ensure each
7373
fork creates it's own runtime.
7474
7575
"""

0 commit comments

Comments
 (0)