diff --git a/docs_src/query_params_str_validations/tutorial012_an_py310.py b/docs_src/query_params_str_validations/tutorial012_an_py310.py index 9b5a9c2fb2..fb3b1e63ab 100644 --- a/docs_src/query_params_str_validations/tutorial012_an_py310.py +++ b/docs_src/query_params_str_validations/tutorial012_an_py310.py @@ -6,6 +6,8 @@ app = FastAPI() @app.get("/items/") -async def read_items(q: Annotated[list[str], Query()] = ["foo", "bar"]): +async def read_items(q: Annotated[list[str], Query()] = None): + if q is None: + q = [] query_items = {"q": q} return query_items diff --git a/docs_src/query_params_str_validations/tutorial013_an_py310.py b/docs_src/query_params_str_validations/tutorial013_an_py310.py index 602734145d..26e3f1c8a5 100644 --- a/docs_src/query_params_str_validations/tutorial013_an_py310.py +++ b/docs_src/query_params_str_validations/tutorial013_an_py310.py @@ -6,6 +6,8 @@ app = FastAPI() @app.get("/items/") -async def read_items(q: Annotated[list, Query()] = []): +async def read_items(q: Annotated[list, Query()] = None): + if q is None: + q = [] query_items = {"q": q} return query_items diff --git a/fastapi/_compat/v2.py b/fastapi/_compat/v2.py index 79fba93188..8f148fc492 100644 --- a/fastapi/_compat/v2.py +++ b/fastapi/_compat/v2.py @@ -160,10 +160,12 @@ class ModelField: def validate( self, value: Any, - values: dict[str, Any] = {}, # noqa: B006 + values: dict[str, Any] = None, # noqa: B006 *, loc: tuple[int | str, ...] = (), ) -> tuple[Any, list[dict[str, Any]]]: + if values is None: + values = {} try: return ( self._type_adapter.validate_python(value, from_attributes=True), diff --git a/scripts/playwright/cookie_param_models/image01.py b/scripts/playwright/cookie_param_models/image01.py index 77c91bfe22..33231fd8f7 100644 --- a/scripts/playwright/cookie_param_models/image01.py +++ b/scripts/playwright/cookie_param_models/image01.py @@ -29,7 +29,7 @@ process = subprocess.Popen( try: for _ in range(3): try: - response = httpx.get("http://localhost:8000/docs") + response = httpx.get("http://localhost:8000/docs", timeout=10.0) except httpx.ConnectError: time.sleep(1) break diff --git a/scripts/playwright/header_param_models/image01.py b/scripts/playwright/header_param_models/image01.py index 53914251ed..f281ec260e 100644 --- a/scripts/playwright/header_param_models/image01.py +++ b/scripts/playwright/header_param_models/image01.py @@ -28,7 +28,7 @@ process = subprocess.Popen( try: for _ in range(3): try: - response = httpx.get("http://localhost:8000/docs") + response = httpx.get("http://localhost:8000/docs", timeout=10.0) except httpx.ConnectError: time.sleep(1) break diff --git a/scripts/playwright/json_base64_bytes/image01.py b/scripts/playwright/json_base64_bytes/image01.py index 56c57e1c32..45a0220467 100644 --- a/scripts/playwright/json_base64_bytes/image01.py +++ b/scripts/playwright/json_base64_bytes/image01.py @@ -27,7 +27,7 @@ process = subprocess.Popen( try: for _ in range(3): try: - response = httpx.get("http://localhost:8000/docs") + response = httpx.get("http://localhost:8000/docs", timeout=10.0) except httpx.ConnectError: time.sleep(1) break diff --git a/scripts/playwright/query_param_models/image01.py b/scripts/playwright/query_param_models/image01.py index 0ea1d0df4e..dbb6f6b58e 100644 --- a/scripts/playwright/query_param_models/image01.py +++ b/scripts/playwright/query_param_models/image01.py @@ -31,7 +31,7 @@ process = subprocess.Popen( try: for _ in range(3): try: - response = httpx.get("http://localhost:8000/docs") + response = httpx.get("http://localhost:8000/docs", timeout=10.0) except httpx.ConnectError: time.sleep(1) break diff --git a/scripts/playwright/request_form_models/image01.py b/scripts/playwright/request_form_models/image01.py index fe4da32fcb..60261bae41 100644 --- a/scripts/playwright/request_form_models/image01.py +++ b/scripts/playwright/request_form_models/image01.py @@ -28,7 +28,7 @@ process = subprocess.Popen( try: for _ in range(3): try: - response = httpx.get("http://localhost:8000/docs") + response = httpx.get("http://localhost:8000/docs", timeout=10.0) except httpx.ConnectError: time.sleep(1) break diff --git a/scripts/playwright/sql_databases/image01.py b/scripts/playwright/sql_databases/image01.py index 0dd6f25145..c55839206b 100644 --- a/scripts/playwright/sql_databases/image01.py +++ b/scripts/playwright/sql_databases/image01.py @@ -27,7 +27,7 @@ process = subprocess.Popen( try: for _ in range(3): try: - response = httpx.get("http://localhost:8000/docs") + response = httpx.get("http://localhost:8000/docs", timeout=10.0) except httpx.ConnectError: time.sleep(1) break diff --git a/scripts/playwright/sql_databases/image02.py b/scripts/playwright/sql_databases/image02.py index 6c4f685e86..2009989726 100644 --- a/scripts/playwright/sql_databases/image02.py +++ b/scripts/playwright/sql_databases/image02.py @@ -27,7 +27,7 @@ process = subprocess.Popen( try: for _ in range(3): try: - response = httpx.get("http://localhost:8000/docs") + response = httpx.get("http://localhost:8000/docs", timeout=10.0) except httpx.ConnectError: time.sleep(1) break