Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ dev = [
"pytest~=9.0",
"pytest-asyncio>=0.21,<0.22",
"pytest-timeout~=2.2",
"ruff>=0.5.0,<0.6",
"ruff>=0.15.12,<0.16",
"toml>=0.10.2,<0.11",
"twine>=4.0.1,<5",
"maturin>=1.8.2",
Expand Down Expand Up @@ -239,7 +239,7 @@ exclude = [
]

[tool.ruff]
target-version = "py39"
target-version = "py310"

[build-system]
requires = ["maturin>=1.0,<2.0"]
Expand Down
2 changes: 1 addition & 1 deletion scripts/gen_bridge_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def generate_python_services(
''')

def service_name(s):
return f"import {sanitize_proto_name(s.full_name)[:-len(s.name)-1]}"
return f"import {sanitize_proto_name(s.full_name)[: -len(s.name) - 1]}"

service_imports = [
service_name(service_descriptor)
Expand Down
12 changes: 6 additions & 6 deletions scripts/gen_protos.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ def check_proto_toolchain_versions():
_, _, proto_version = line.partition("==")
elif line.startswith("grpcio-tools"):
_, _, grpcio_tools_version = line.partition("==")
assert proto_version.startswith(
"3."
), f"expected 3.x protobuf, found {proto_version}"
assert grpcio_tools_version.startswith(
"1.48."
), f"expected 1.48.x grpcio-tools, found {grpcio_tools_version}"
assert proto_version.startswith("3."), (
f"expected 3.x protobuf, found {proto_version}"
)
assert grpcio_tools_version.startswith("1.48."), (
f"expected 1.48.x grpcio-tools, found {grpcio_tools_version}"
)


def generate_protos(output_dir: Path):
Expand Down
2 changes: 1 addition & 1 deletion temporalio/worker/workflow_sandbox/_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def _calc___package__(globals: Mapping[str, object]) -> str:
if package is not None:
if spec is not None and package != spec.parent:
warnings.warn(
"__package__ != __spec__.parent " f"({package!r} != {spec.parent!r})",
f"__package__ != __spec__.parent ({package!r} != {spec.parent!r})",
DeprecationWarning,
stacklevel=3,
)
Expand Down
18 changes: 9 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@
# If there is an integration test environment variable set, we must remove the
# first path from the sys.path so we can import the wheel instead
if os.getenv("TEMPORAL_INTEGRATION_TEST"):
assert (
sys.path[0] == os.getcwd()
), "Expected first sys.path to be the current working dir"
assert sys.path[0] == os.getcwd(), (
"Expected first sys.path to be the current working dir"
)
sys.path.pop(0)
# Import temporalio and confirm it is prefixed with virtual env
import temporalio

assert temporalio.__file__.startswith(
sys.prefix
), f"Expected {temporalio.__file__} to be in {sys.prefix}"
assert temporalio.__file__.startswith(sys.prefix), (
f"Expected {temporalio.__file__} to be in {sys.prefix}"
)

# Unless specifically overridden, we expect tests to run under protobuf 4.x/5.x lib
import google.protobuf

protobuf_version = google.protobuf.__version__
if os.getenv("TEMPORAL_TEST_PROTO3"):
assert protobuf_version.startswith(
"3."
), f"Expected protobuf 3.x, got {protobuf_version}"
assert protobuf_version.startswith("3."), (
f"Expected protobuf 3.x, got {protobuf_version}"
)
else:
assert (
protobuf_version.startswith("4.")
Expand Down
12 changes: 7 additions & 5 deletions tests/contrib/aws/lambda_worker/test_lambda_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,13 @@ def fake_create_worker(_client: Any, **kwargs: Any) -> Any:
load_config=lambda: ClientConfigProfile(),
getenv={"TEMPORAL_TASK_QUEUE": "test-queue"}.get, # type: ignore[arg-type]
extract_lambda_ctx=lambda ctx: (
ctx.aws_request_id,
ctx.invoked_function_arn,
)
if hasattr(ctx, "aws_request_id")
else None,
(
ctx.aws_request_id,
ctx.invoked_function_arn,
)
if hasattr(ctx, "aws_request_id")
else None
),
)


Expand Down
18 changes: 9 additions & 9 deletions tests/contrib/aws/s3driver/test_s3driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ async def test_skips_upload_when_key_exists(
assert counting_driver_client.put_object_count == 1

await driver.store(make_store_context(), [payload])
assert (
counting_driver_client.put_object_count == 1
), "put_object should not be called for an existing key"
assert counting_driver_client.put_object_count == 1, (
"put_object should not be called for an existing key"
)

async def test_skips_upload_preserves_data(
self, driver_client: S3StorageDriverClient
Expand Down Expand Up @@ -812,9 +812,9 @@ async def test_store_cancels_remaining_on_failure(

assert isinstance(exc_info.value.__cause__, ConnectionError)
assert str(exc_info.value.__cause__) == "S3 connection lost"
assert (
len(faulty_client.cancelled) == 2
), "Expected 2 remaining tasks to be cancelled"
assert len(faulty_client.cancelled) == 2, (
"Expected 2 remaining tasks to be cancelled"
)

async def test_retrieve_cancels_remaining_on_failure(
self, driver_client: S3StorageDriverClient
Expand All @@ -838,9 +838,9 @@ async def test_retrieve_cancels_remaining_on_failure(

assert isinstance(exc_info.value.__cause__, ConnectionError)
assert str(exc_info.value.__cause__) == "S3 connection lost"
assert (
len(faulty_client.cancelled) == 2
), "Expected 2 remaining tasks to be cancelled"
assert len(faulty_client.cancelled) == 2, (
"Expected 2 remaining tasks to be cancelled"
)


# ---------------------------------------------------------------------------
Expand Down
18 changes: 9 additions & 9 deletions tests/contrib/langgraph/test_continue_as_new_cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ async def test_graph_continue_as_new_cached(client: Client):
assert result == {"value": 260}

# Each node should execute exactly once — phases 2 and 3 use cached results.
assert (
_execution_counts.get("multiply", 0) == 1
), f"multiply executed {_execution_counts.get('multiply', 0)} times, expected 1"
assert (
_execution_counts.get("add", 0) == 1
), f"add executed {_execution_counts.get('add', 0)} times, expected 1"
assert (
_execution_counts.get("double", 0) == 1
), f"double executed {_execution_counts.get('double', 0)} times, expected 1"
assert _execution_counts.get("multiply", 0) == 1, (
f"multiply executed {_execution_counts.get('multiply', 0)} times, expected 1"
)
assert _execution_counts.get("add", 0) == 1, (
f"add executed {_execution_counts.get('add', 0)} times, expected 1"
)
assert _execution_counts.get("double", 0) == 1, (
f"double executed {_execution_counts.get('double', 0)} times, expected 1"
)
24 changes: 12 additions & 12 deletions tests/contrib/langgraph/test_e2e_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ async def test_continue_as_new_with_checkpoint(self, client: Client) -> None:
assert result["result"] == 260

counts = get_task_execution_counts()
assert (
counts.get("task_a", 0) == 1
), f"task_a executed {counts.get('task_a', 0)} times, expected 1"
assert (
counts.get("task_b", 0) == 1
), f"task_b executed {counts.get('task_b', 0)} times, expected 1"
assert (
counts.get("task_c", 0) == 1
), f"task_c executed {counts.get('task_c', 0)} times, expected 1"
assert counts.get("task_a", 0) == 1, (
f"task_a executed {counts.get('task_a', 0)} times, expected 1"
)
assert counts.get("task_b", 0) == 1, (
f"task_b executed {counts.get('task_b', 0)} times, expected 1"
)
assert counts.get("task_c", 0) == 1, (
f"task_c executed {counts.get('task_c', 0)} times, expected 1"
)


class TestFunctionalAPIPartialExecution:
Expand Down Expand Up @@ -266,9 +266,9 @@ async def test_partial_execution_five_tasks(self, client: Client) -> None:

counts = get_task_execution_counts()
for i in range(1, 6):
assert (
counts.get(f"step_{i}", 0) == 1
), f"step_{i} executed {counts.get(f'step_{i}', 0)} times, expected 1"
assert counts.get(f"step_{i}", 0) == 1, (
f"step_{i} executed {counts.get(f'step_{i}', 0)} times, expected 1"
)


class TestFunctionalAPIInterruptV2:
Expand Down
72 changes: 36 additions & 36 deletions tests/contrib/langsmith/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,27 +367,27 @@ async def test_workflow_activity_trace_hierarchy(
" RunActivity:simple_activity",
" simple_activity",
]
assert (
hierarchy == expected
), f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
assert hierarchy == expected, (
f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
)

# Verify run_type: RunActivity is "tool", others are "chain"
for run in collector.runs:
if run.name == "RunActivity:simple_activity":
assert (
run.run_type == "tool"
), f"Expected RunActivity run_type='tool', got '{run.run_type}'"
assert run.run_type == "tool", (
f"Expected RunActivity run_type='tool', got '{run.run_type}'"
)
else:
assert (
run.run_type == "chain"
), f"Expected {run.name} run_type='chain', got '{run.run_type}'"
assert run.run_type == "chain", (
f"Expected {run.name} run_type='chain', got '{run.run_type}'"
)

# Verify successful runs have outputs == {"status": "ok"}
for run in collector.runs:
if ":" in run.name: # Interceptor runs use "Type:Name" format
assert run.outputs == {
"status": "ok"
}, f"Expected {run.name} outputs={{'status': 'ok'}}, got {run.outputs}"
assert run.outputs == {"status": "ok"}, (
f"Expected {run.name} outputs={{'status': 'ok'}}, got {run.outputs}"
)


# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -475,9 +475,9 @@ async def test_activity_failure_marked(
" RunActivity:failing_activity",
" failing_activity",
]
assert (
hierarchy == expected
), f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
assert hierarchy == expected, (
f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
)
# Verify the RunActivity run has an error
activity_runs = [
r for r in collector.runs if r.name == "RunActivity:failing_activity"
Expand Down Expand Up @@ -514,9 +514,9 @@ async def test_workflow_failure_marked(
"StartWorkflow:FailingWorkflow",
"RunWorkflow:FailingWorkflow",
]
assert (
hierarchy == expected
), f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
assert hierarchy == expected, (
f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
)
# Verify the RunWorkflow run has an error
wf_runs = [r for r in collector.runs if r.name == "RunWorkflow:FailingWorkflow"]
assert len(wf_runs) == 1
Expand Down Expand Up @@ -555,9 +555,9 @@ async def test_benign_error_not_marked(
" RunActivity:benign_failing_activity",
" benign_failing_activity",
]
assert (
hierarchy == expected
), f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
assert hierarchy == expected, (
f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
)
# The RunActivity run for benign error should NOT have error set
activity_runs = [
r for r in collector.runs if r.name == "RunActivity:benign_failing_activity"
Expand Down Expand Up @@ -988,15 +988,15 @@ async def test_factory_traceable_no_external_context(
" outer_chain",
" inner_llm_call",
]
assert (
hierarchy == expected
), f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
assert hierarchy == expected, (
f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
)

# Verify no duplicate run IDs (replay safety with max_cached_workflows=0)
run_ids = [r.id for r in collector.runs]
assert len(run_ids) == len(
set(run_ids)
), f"Duplicate run IDs found (replay issue): {run_ids}"
assert len(run_ids) == len(set(run_ids)), (
f"Duplicate run IDs found (replay issue): {run_ids}"
)

async def test_factory_passes_project_name_to_children(
self,
Expand Down Expand Up @@ -1081,15 +1081,15 @@ async def test_mixed_sync_async_traceable_with_temporal_runs(
" outer_chain",
" inner_llm_call",
]
assert (
hierarchy == expected
), f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
assert hierarchy == expected, (
f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
)

# Verify no duplicate run IDs (replay safety with max_cached_workflows=0)
run_ids = [r.id for r in collector.runs]
assert len(run_ids) == len(
set(run_ids)
), f"Duplicate run IDs found (replay issue): {run_ids}"
assert len(run_ids) == len(set(run_ids)), (
f"Duplicate run IDs found (replay issue): {run_ids}"
)


# --- Nexus service with direct @traceable call in handler ---
Expand Down Expand Up @@ -1190,9 +1190,9 @@ async def test_nexus_direct_traceable_without_temporal_runs(
"nexus_direct_traceable",
" inner_llm_call",
]
assert (
hierarchy == expected
), f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
assert hierarchy == expected, (
f"Hierarchy mismatch.\nExpected:\n{expected}\nActual:\n{hierarchy}"
)


# ---------------------------------------------------------------------------
Expand Down
Loading
Loading