File: marshal.pyi

package info (click to toggle)
typeshed 0.0~git20241223.ea91db2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 28,756 kB
  • sloc: python: 7,741; makefile: 20; sh: 18
file content (41 lines) | stat: -rw-r--r-- 1,292 bytes parent folder | download | duplicates (3)
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
41
import builtins
import sys
import types
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
from typing import Any
from typing_extensions import TypeAlias

version: int

_Marshallable: TypeAlias = (
    # handled in w_object() in marshal.c
    None
    | type[StopIteration]
    | builtins.ellipsis
    | bool
    # handled in w_complex_object() in marshal.c
    | int
    | float
    | complex
    | bytes
    | str
    | tuple[_Marshallable, ...]
    | list[Any]
    | dict[Any, Any]
    | set[Any]
    | frozenset[_Marshallable]
    | types.CodeType
    | ReadableBuffer
)

if sys.version_info >= (3, 13):
    def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 4, /, *, allow_code: bool = True) -> None: ...
    def load(file: SupportsRead[bytes], /, *, allow_code: bool = True) -> Any: ...
    def dumps(value: _Marshallable, version: int = 4, /, *, allow_code: bool = True) -> bytes: ...
    def loads(bytes: ReadableBuffer, /, *, allow_code: bool = True) -> Any: ...

else:
    def dump(value: _Marshallable, file: SupportsWrite[bytes], version: int = 4, /) -> None: ...
    def load(file: SupportsRead[bytes], /) -> Any: ...
    def dumps(value: _Marshallable, version: int = 4, /) -> bytes: ...
    def loads(bytes: ReadableBuffer, /) -> Any: ...