pre-commit-ci-lite[bot]
2 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
5 additions and
5 deletions
-
fastapi/encoders.py
-
tests/test_encoder_performance.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): |
|
|
|
|
|
|
|
@ -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" |
|
|
|
|
|
|
|
|
|
|
|
|