cddb07a176
build container image / cpu (push) Waiting to run
build container image / cuda (push) Waiting to run
build container image / rocm (push) Waiting to run
frontend tests / frontend-tests (push) Waiting to run
openapi checks / openapi-checks (push) Waiting to run
python tests / py3.12: macos-default (push) Waiting to run
python tests / py3.11: windows-cpu (push) Waiting to run
python tests / py3.12: windows-cpu (push) Waiting to run
python tests / py3.11: linux-cpu (push) Waiting to run
python tests / py3.12: linux-cpu (push) Waiting to run
typegen checks / typegen-checks (push) Waiting to run
uv lock checks / uv-lock-checks (push) Waiting to run
frontend checks / frontend-checks (push) Waiting to run
lfs checks / lfs-check (push) Waiting to run
python checks / python-checks (push) Waiting to run
python tests / py3.11: macos-default (push) Waiting to run
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
24 lines
678 B
Python
24 lines
678 B
Python
from typing import Any
|
|
|
|
from pydantic import BaseModel
|
|
|
|
"""
|
|
We want to exclude null values from objects that make their way to the client.
|
|
|
|
Unfortunately there is no built-in way to do this in pydantic, so we need to override the default
|
|
dict method to do this.
|
|
|
|
From https://github.com/tiangolo/fastapi/discussions/8882#discussioncomment-5154541
|
|
"""
|
|
|
|
|
|
class BaseModelExcludeNull(BaseModel):
|
|
def model_dump(self, *args, **kwargs) -> dict[str, Any]:
|
|
"""
|
|
Override the default dict method to exclude None values in the response
|
|
"""
|
|
kwargs.pop("exclude_none", None)
|
|
return super().model_dump(*args, exclude_none=True, **kwargs)
|
|
|
|
pass
|