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
2 changes: 1 addition & 1 deletion src/marshmallow/class_registry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""A registry of :class:`Schema <marshmallow.Schema>` classes. This allows for string
lookup of schemas, which may be used with
class:`fields.Nested <marshmallow.fields.Nested>`.
:class:`fields.Nested <marshmallow.fields.Nested>`.

.. warning::

Expand Down
4 changes: 2 additions & 2 deletions src/marshmallow/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def pre_dump(
argument passed to the `Schema <marshmallow.Schema>`'s :func:`~marshmallow.Schema.dump` call.
If ``pass_collection=True``, the raw data (which may be a collection) is passed.

.. versionchanged:: 3.0.0 ``many`` is always passed as a keyword arguments to the decorated method.
.. versionchanged:: 3.0.0 ``many`` is always passed as a keyword argument to the decorated method.
.. versionchanged:: 4.0.0 ``pass_many`` is renamed to ``pass_collection``.
.. versionchanged:: 4.0.0 ``pass_collection`` is a keyword-only argument.
"""
Expand All @@ -165,7 +165,7 @@ def post_dump(
If ``pass_original=True``, the original data (before serializing) will be passed as
an additional argument to the method.

.. versionchanged:: 3.0.0 ``many`` is always passed as a keyword arguments to the decorated method.
.. versionchanged:: 3.0.0 ``many`` is always passed as a keyword argument to the decorated method.
.. versionchanged:: 4.0.0 ``pass_many`` is renamed to ``pass_collection``.
.. versionchanged:: 4.0.0 ``pass_collection`` and ``pass_original`` are keyword-only arguments.
"""
Expand Down
30 changes: 15 additions & 15 deletions src/marshmallow/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Field(typing.Generic[_InternalT]):
:param metadata: Extra information to be stored as field metadata.

.. versionchanged:: 3.0.0b8
Add ``data_key`` parameter for the specifying the key in the input and
Add ``data_key`` parameter for specifying the key in the input and
output data. This parameter replaced both ``load_from`` and ``dump_to``.
.. versionchanged:: 3.13.0
Replace ``missing`` and ``default`` parameters with ``load_default`` and ``dump_default``.
Expand Down Expand Up @@ -402,7 +402,7 @@ def deserialize(

def _bind_to_schema(self, field_name: str, parent: Schema | Field) -> None:
"""Update field with values from its parent schema. Called by
`Schema._bind_field <marshmallow.Schema._bind_field>`.
`Schema._bind_field <marshmallow.Schema._bind_field>`.

:param field_name: Field name set in schema.
:param parent: Parent object.
Expand Down Expand Up @@ -523,7 +523,7 @@ class ParentSchema(Schema):
:param many: Whether the field is a collection of objects.
If `None` (default), and nested `Schema` instance is provided, ``many`` is not overridden.
If `None` (default), and `Schema` subclass is provided, schema instance sets ``many`` as False.
If `True | False` nested `[nested_field].schema.many` is overridden.
If `True | False`, nested `[nested_field].schema.many` is overridden.
:param unknown: Whether to exclude, include, or raise an error for unknown
fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
:param kwargs: The same keyword arguments that :class:`Field` receives.
Expand Down Expand Up @@ -797,7 +797,7 @@ def _deserialize(self, value, attr, data, **kwargs) -> list[_InternalT | None]:

class Tuple(Field[tuple]):
"""A tuple field, composed of a fixed number of other `Field` classes or
instances
instances.

Example: ::

Expand Down Expand Up @@ -1395,7 +1395,7 @@ class AwareDateTime(DateTime):

:param format: See :class:`DateTime`.
:param default_timezone: Used on deserialization. If `None`, naive
datetimes are rejected. If not `None`, naive datetimes are set this
datetimes are rejected. If not `None`, naive datetimes are set to this
timezone.
:param kwargs: The same keyword arguments that :class:`Field` receives.

Expand Down Expand Up @@ -1505,7 +1505,7 @@ class TimeDelta(Field[dt.timedelta]):
Float Caveats
-------------
Precision loss may occur when serializing a highly precise :class:`datetime.timedelta`
object using a big ``precision`` unit due to floating point arithmetics.
object using a big ``precision`` unit due to floating-point arithmetic.

When necessary, the :class:`datetime.timedelta` constructor rounds `float` inputs
to whole microseconds during initialization of the object. As a result, deserializing
Expand Down Expand Up @@ -1805,7 +1805,7 @@ def __init__(self, **kwargs: Unpack[_BaseFieldKwargs]) -> None:


class IP(Field[ipaddress.IPv4Address | ipaddress.IPv6Address]):
"""A IP address field.
"""An IP address field.

:param exploded: If `True`, serialize ipv6 address in long form, ie. with groups
consisting entirely of zeros included.
Expand Down Expand Up @@ -1840,7 +1840,7 @@ def _deserialize(


class IPv4(IP):
"""A IPv4 address field.
"""An IPv4 address field.

.. versionadded:: 3.8.0
"""
Expand All @@ -1851,7 +1851,7 @@ class IPv4(IP):


class IPv6(IP):
"""A IPv6 address field.
"""An IPv6 address field.

.. versionadded:: 3.8.0
"""
Expand All @@ -1862,7 +1862,7 @@ class IPv6(IP):


class IPInterface(Field[ipaddress.IPv4Interface | ipaddress.IPv6Interface]):
"""A IPInterface field.
"""An IPInterface field.

IP interface is the non-strict form of the IPNetwork type where arbitrary host
addresses are always accepted.
Expand Down Expand Up @@ -1902,15 +1902,15 @@ def _deserialize(


class IPv4Interface(IPInterface):
"""A IPv4 Network Interface field."""
"""An IPv4 Network Interface field."""

default_error_messages = {"invalid_ip_interface": "Not a valid IPv4 interface."}

DESERIALIZATION_CLASS = ipaddress.IPv4Interface


class IPv6Interface(IPInterface):
"""A IPv6 Network Interface field."""
"""An IPv6 Network Interface field."""

default_error_messages = {"invalid_ip_interface": "Not a valid IPv6 interface."}

Expand Down Expand Up @@ -2008,7 +2008,7 @@ class Method(Field):
to retrieve the value. The method must take an argument ``obj``
(in addition to self) that is the object to be serialized.
:param deserialize: Optional name of the Schema method for deserializing
a value The method must take a single argument ``value``, which is the
a value. The method must take a single argument ``value``, which is the
value to deserialize.

.. versionchanged:: 3.0.0
Expand Down Expand Up @@ -2062,12 +2062,12 @@ class Function(Field):
:param serialize: A callable from which to retrieve the value.
The function must take a single argument ``obj`` which is the object
to be serialized.
If no callable is provided then the ```load_only``` flag will be set
If no callable is provided then the ``load_only`` flag will be set
to True.
:param deserialize: A callable from which to retrieve the value.
The function must take a single argument ``value`` which is the value
to be deserialized.
If no callable is provided then ```value``` will be passed through
If no callable is provided then ``value`` will be passed through
unchanged.

.. versionchanged:: 3.0.0a1
Expand Down
8 changes: 4 additions & 4 deletions src/marshmallow/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_declared_fields(
:param cls_fields: The fields declared on the class, including those added
by the ``include`` `class Meta <marshmallow.Schema.Meta>` option.
:param inherited_fields: Inherited fields.
:param dict_cls: dict-like class to use for dict output Default to ``dict``.
:param dict_cls: dict-like class to use for dict output. Defaults to ``dict``.
"""
return dict_cls(inherited_fields + cls_fields)

Expand Down Expand Up @@ -855,13 +855,13 @@ def _do_load(
:param many: Whether to deserialize `data` as a collection. If `None`, the
value for `self.many` is used.
:param partial: Whether to validate required fields. If its
value is an iterable, only fields listed in that iterable will be
ignored will be allowed missing. If `True`, all fields will be allowed missing.
value is an iterable, only fields listed in that iterable
will be allowed missing. If `True`, all fields will be allowed missing.
If `None`, the value for `self.partial` is used.
:param unknown: Whether to exclude, include, or raise an error for unknown
fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
If `None`, the value for `self.unknown` is used.
:param postprocess: Whether to run post_load methods..
:param postprocess: Whether to run post_load methods.
:return: Deserialized data
"""
error_store = ErrorStore()
Expand Down
6 changes: 3 additions & 3 deletions src/marshmallow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def is_generator(obj) -> typing.TypeGuard[typing.Generator]:
"""Return True if ``obj`` is a generator"""
"""Return True if ``obj`` is a generator."""
return inspect.isgeneratorfunction(obj) or inspect.isgenerator(obj)


Expand All @@ -26,7 +26,7 @@ def is_sequence_but_not_string(obj) -> typing.TypeGuard[Sequence]:


def is_collection(obj) -> typing.TypeGuard[typing.Iterable]:
"""Return True if ``obj`` is a collection type, e.g list, tuple, queryset."""
"""Return True if ``obj`` is a collection type, e.g. list, tuple, queryset."""
return is_iterable_but_not_string(obj) and not isinstance(obj, Mapping)


Expand Down Expand Up @@ -125,7 +125,7 @@ def _get_value_for_key(obj, key, default):

def set_value(dct: dict[str, typing.Any], key: str, value: typing.Any):
"""Set a value in a dict. If `key` contains a '.', it is assumed
be a path (i.e. dot-delimited string) to the value's location.
to be a path (i.e. dot-delimited string) to the value's location.

::

Expand Down
Loading