Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions python/pydantic_core/_pydantic_core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,10 @@ def to_json(
indent: int | None = None,
include: _IncEx | None = None,
exclude: _IncEx | None = None,
by_alias: bool | None = None,
# Note: In Pydantic 2.11, the default value of `by_alias` on `SchemaSerializer` was changed from `True` to `None`,
# to be consistent with the Pydantic "dump" methods. However, the default of `True` was kept here for
# backwards compatibility. In Pydantic V3, `by_alias` is expected to default to `True` everywhere:
by_alias: bool = True,
exclude_none: bool = False,
round_trip: bool = False,
timedelta_mode: Literal['iso8601', 'float'] = 'iso8601',
Expand Down Expand Up @@ -468,7 +471,10 @@ def to_jsonable_python(
*,
include: _IncEx | None = None,
exclude: _IncEx | None = None,
by_alias: bool | None = None,
# Note: In Pydantic 2.11, the default value of `by_alias` on `SchemaSerializer` was changed from `True` to `None`,
# to be consistent with the Pydantic "dump" methods. However, the default of `True` was kept here for
# backwards compatibility. In Pydantic V3, `by_alias` is expected to default to `True` everywhere:
by_alias: bool = True,
exclude_none: bool = False,
round_trip: bool = False,
timedelta_mode: Literal['iso8601', 'float'] = 'iso8601',
Expand Down
12 changes: 6 additions & 6 deletions src/serializers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl SchemaSerializer {

#[allow(clippy::too_many_arguments)]
#[pyfunction]
#[pyo3(signature = (value, *, indent = None, include = None, exclude = None, by_alias = None,
#[pyo3(signature = (value, *, indent = None, include = None, exclude = None, by_alias = true,
exclude_none = false, round_trip = false, timedelta_mode = "iso8601", bytes_mode = "utf8",
inf_nan_mode = "constants", serialize_unknown = false, fallback = None, serialize_as_any = false,
context = None))]
Expand All @@ -249,7 +249,7 @@ pub fn to_json(
indent: Option<usize>,
include: Option<&Bound<'_, PyAny>>,
exclude: Option<&Bound<'_, PyAny>>,
by_alias: Option<bool>,
by_alias: bool,
exclude_none: bool,
round_trip: bool,
timedelta_mode: &str,
Expand All @@ -265,7 +265,7 @@ pub fn to_json(
let extra = state.extra(
py,
&SerMode::Json,
by_alias,
Some(by_alias),
exclude_none,
round_trip,
serialize_unknown,
Expand All @@ -282,15 +282,15 @@ pub fn to_json(

#[allow(clippy::too_many_arguments)]
#[pyfunction]
#[pyo3(signature = (value, *, include = None, exclude = None, by_alias = None, exclude_none = false, round_trip = false,
#[pyo3(signature = (value, *, include = None, exclude = None, by_alias = true, exclude_none = false, round_trip = false,
timedelta_mode = "iso8601", bytes_mode = "utf8", inf_nan_mode = "constants", serialize_unknown = false, fallback = None,
serialize_as_any = false, context = None))]
pub fn to_jsonable_python(
py: Python,
value: &Bound<'_, PyAny>,
include: Option<&Bound<'_, PyAny>>,
exclude: Option<&Bound<'_, PyAny>>,
by_alias: Option<bool>,
by_alias: bool,
exclude_none: bool,
round_trip: bool,
timedelta_mode: &str,
Expand All @@ -306,7 +306,7 @@ pub fn to_jsonable_python(
let extra = state.extra(
py,
&SerMode::Json,
by_alias,
Some(by_alias),
exclude_none,
round_trip,
serialize_unknown,
Expand Down
Loading