From f8b9a65869ee35b72f798e61c4ca51ddb8b8ea71 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Wed, 15 Apr 2026 17:55:42 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Auto=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/routing.py | 6 ++---- tests/test_background_tasks_merge.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index a13763535d..7fd1dd283c 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -73,9 +73,9 @@ from fastapi.utils import ( is_body_allowed_for_status_code, ) from starlette import routing -from starlette.background import BackgroundTasks from starlette._exception_handler import wrap_app_handling_exceptions from starlette._utils import is_async_callable +from starlette.background import BackgroundTasks from starlette.concurrency import iterate_in_threadpool, run_in_threadpool from starlette.datastructures import FormData from starlette.exceptions import HTTPException @@ -684,9 +684,7 @@ def get_request_handler( # Merge injected BackgroundTasks with the Response's # own background task so neither set is lost. original = raw_response.background - merged = BackgroundTasks( - solved_result.background_tasks.tasks - ) + merged = BackgroundTasks(solved_result.background_tasks.tasks) if isinstance(original, BackgroundTasks): merged.tasks.extend(original.tasks) else: diff --git a/tests/test_background_tasks_merge.py b/tests/test_background_tasks_merge.py index 89e640f3ef..3bfff385f4 100644 --- a/tests/test_background_tasks_merge.py +++ b/tests/test_background_tasks_merge.py @@ -8,7 +8,7 @@ injected tasks. See: https://github.com/fastapi/fastapi/issues/11215 """ -from fastapi import FastAPI, BackgroundTasks +from fastapi import BackgroundTasks, FastAPI from fastapi.testclient import TestClient from starlette.background import BackgroundTask from starlette.background import BackgroundTasks as StarletteBackgroundTasks