From b53a31040e21e4199a929cb3a599dfe59a8f5e45 Mon Sep 17 00:00:00 2001 From: JONEMI21 Date: Tue, 27 Jan 2026 16:19:38 +0000 Subject: [PATCH] no cover pydantic lower than 2.6 --- fastapi/_compat/v2.py | 5 +---- tests/test_query.py | 13 +++++++++++++ .../test_query_params/test_tutorial007_py310.py | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/fastapi/_compat/v2.py b/fastapi/_compat/v2.py index f2ee4fcec2..900bbfb541 100644 --- a/fastapi/_compat/v2.py +++ b/fastapi/_compat/v2.py @@ -571,9 +571,6 @@ def get_flat_models_from_fields( return known_models -def get_long_model_name(model: TypeModelOrEnum) -> str: - return f"{model.__module__}__{model.__qualname__}".replace(".", "__") - if shared.PYDANTIC_VERSION_MINOR_TUPLE >= (2, 6): # Omit by default for scalar mapping and scalar sequence mapping annotations @@ -601,7 +598,7 @@ if shared.PYDANTIC_VERSION_MINOR_TUPLE >= (2, 6): ) return new_field_info, {} -else: +else: # pragma: no cover def ignore_invalid(v: Any, handler: Callable[[Any], Any]) -> Any: try: diff --git a/tests/test_query.py b/tests/test_query.py index 45939e0c62..0d48b9c294 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -289,6 +289,19 @@ def test_sequence_mapping_query(): assert response.json() == {"queries": {"foo": [1, 2]}} +def test_mixed_sequence_mapping_query(): + response = client.get("/query/mixed-type-params?query=2&foo=1&bar=3&foo=2&foo=baz") + assert response.status_code == 200 + assert response.json() == { + "queries": { + "mapping_query_int": {"bar": 3}, + "mapping_query_str": {"bar": "3", "foo": "baz"}, + "query": 2, + "sequence_mapping_queries": {"bar": [3], "foo": [1, 2]}, + } + } + + def test_mapping_with_non_mapping_query(): response = client.get("/query/mixed-params/?foo=1&foo=2&bar=3&query=fizz") assert response.status_code == 200 diff --git a/tests/test_tutorial/test_query_params/test_tutorial007_py310.py b/tests/test_tutorial/test_query_params/test_tutorial007_py310.py index fe9827c8ca..7101c00119 100644 --- a/tests/test_tutorial/test_query_params/test_tutorial007_py310.py +++ b/tests/test_tutorial/test_query_params/test_tutorial007_py310.py @@ -26,7 +26,7 @@ def test_foo_needy_very(client: TestClient): @needs_py310 def test_just_string_not_scalar_mapping(client: TestClient): - response = client.get("/query/mixed-type-params?&query=2&foo=1&bar=3&foo=2&foo=baz") + response = client.get("/query/mixed-type-params?query=2&foo=1&bar=3&foo=2&foo=baz") assert response.status_code == 200 assert response.json() == { "query": 2,