aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/marshmallow/types.py
blob: 599f6b49ed2d3a95d544311ef387f673356a8983 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Type aliases.

.. warning::

    This module is provisional. Types may be modified, added, and removed between minor releases.
"""

from __future__ import annotations

import typing

#: A type that can be either a sequence of strings or a set of strings
StrSequenceOrSet = typing.Union[typing.Sequence[str], typing.AbstractSet[str]]

#: Type for validator functions
Validator = typing.Callable[[typing.Any], typing.Any]


class SchemaValidator(typing.Protocol):
    def __call__(
        self,
        output: typing.Any,
        original_data: typing.Any = ...,
        *,
        partial: bool | StrSequenceOrSet | None = None,
        many: bool = False,
    ) -> None: ...


class RenderModule(typing.Protocol):
    def dumps(
        self, obj: typing.Any, *args: typing.Any, **kwargs: typing.Any
    ) -> str: ...

    def loads(
        self,
        json_data: str | bytes | bytearray,
        *args: typing.Any,
        **kwargs: typing.Any,
    ) -> typing.Any: ...