From 0db6cc2d1c5cbf6d89d5e785dac30dfe250ba2b8 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 10:37:30 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Fix=20coverage=20gap=20in=20seriali?= =?UTF-8?q?ze=5Fsequence=5Fvalue=20continue=20statement=20(#14933)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tiangolo <1326112+tiangolo@users.noreply.github.com> Co-authored-by: github-actions[bot] --- tests/test_compat.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_compat.py b/tests/test_compat.py index 33b0e1772..27ecf012f 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -120,9 +120,12 @@ def test_serialize_sequence_value_with_optional_list_pipe_union(): def test_serialize_sequence_value_with_none_first_in_union(): """Test that serialize_sequence_value handles Union[None, List[...]] correctly.""" + from typing import Union + from fastapi._compat import v2 - field_info = FieldInfo(annotation=list[str] | None) + # Use Union[None, list[str]] to ensure None comes first in the union args + field_info = FieldInfo(annotation=Union[None, list[str]]) field = v2.ModelField(name="items", field_info=field_info) result = v2.serialize_sequence_value(field=field, value=["x", "y"]) assert result == ["x", "y"]