Skip to content

Commit f04b221

Browse files
refactor(robot-server): Fix more Pydantic warnings (#17174)
1 parent 6e43168 commit f04b221

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

robot-server/robot_server/client_data/router.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
Key = Annotated[
2626
str,
2727
fastapi.Path(
28-
regex="^[a-zA-Z0-9-_]*$",
28+
pattern="^[a-zA-Z0-9-_]*$",
2929
description=(
3030
"A key for storing and retrieving the piece of data."
3131
" This should be chosen to avoid colliding with other clients,"

robot-server/tests/runs/test_run_store.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime, timezone
44
from pathlib import Path
55
from typing import List, Optional, Type
6+
import warnings
67

78
import pytest
89
from decoy import Decoy
@@ -689,12 +690,22 @@ def test_get_state_summary_failure(
689690
protocol_id=None,
690691
created_at=datetime(year=2021, month=1, day=1, tzinfo=timezone.utc),
691692
)
692-
subject.update_run_state(
693-
run_id="run-id",
694-
summary=invalid_state_summary,
695-
commands=[],
696-
run_time_parameters=[],
697-
)
693+
694+
with warnings.catch_warnings():
695+
# Pydantic raises a warning because invalid_state_summary (deliberately)
696+
# has a wrongly-typed value in one of its fields. Ignore the warning.
697+
warnings.filterwarnings(
698+
action="ignore",
699+
category=UserWarning,
700+
module="pydantic",
701+
)
702+
subject.update_run_state(
703+
run_id="run-id",
704+
summary=invalid_state_summary,
705+
commands=[],
706+
run_time_parameters=[],
707+
)
708+
698709
result = subject.get_state_summary(run_id="run-id")
699710
assert isinstance(result, BadStateSummary)
700711
assert result.dataError.code == ErrorCodes.INVALID_STORED_DATA

0 commit comments

Comments
 (0)