From f5686c7fabe1eb75c4e04d76c85f4b01fcd1310c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Thu, 9 Jul 2026 13:56:19 +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/encoders.py | 3 ++- tests/test_encoder_performance.py | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fastapi/encoders.py b/fastapi/encoders.py index 59d788c89..d660d4642 100644 --- a/fastapi/encoders.py +++ b/fastapi/encoders.py @@ -253,7 +253,8 @@ def jsonable_encoder( if not sqlalchemy_safe: return obj_dict return { - k: v for k, v in obj_dict.items() + k: v + for k, v in obj_dict.items() if not (isinstance(k, str) and k.startswith("_sa")) } if dataclasses.is_dataclass(obj): diff --git a/tests/test_encoder_performance.py b/tests/test_encoder_performance.py index 86f5bc00c..aba3b7805 100644 --- a/tests/test_encoder_performance.py +++ b/tests/test_encoder_performance.py @@ -1,6 +1,5 @@ -from typing import List, Optional -from pydantic import BaseModel from fastapi.encoders import jsonable_encoder +from pydantic import BaseModel class SubModel(BaseModel): @@ -12,8 +11,8 @@ class MainModel(BaseModel): id: int title: str sub: SubModel - items: List[SubModel] - maybe: Optional[str] = None + items: list[SubModel] + maybe: str | None = None _sa_instance_state: str = "should-be-removed"