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
8 changes: 0 additions & 8 deletions stubs/PyYAML/@tests/stubtest_allowlist.txt

This file was deleted.

3 changes: 1 addition & 2 deletions stubs/PyYAML/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
version = "5.4.*"
python2 = true
version = "6.0.*"
72 changes: 34 additions & 38 deletions stubs/PyYAML/yaml/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import sys
from typing import IO, Any, Callable, Iterable, Iterator, Pattern, Sequence, Text, Type, TypeVar, Union, overload

from yaml.constructor import BaseConstructor
from yaml.dumper import * # noqa: F403
from yaml.error import * # noqa: F403
from yaml.events import * # noqa: F403
from yaml.loader import * # noqa: F403
from yaml.nodes import * # noqa: F403
from yaml.representer import BaseRepresenter
from yaml.resolver import BaseResolver
from yaml.tokens import * # noqa: F403
from collections.abc import Callable, Iterable, Iterator, Sequence
from typing import IO, Any, Pattern, Type, TypeVar, overload

from . import resolver as resolver # Help mypy a bit; this is implied by loader and dumper
from .constructor import BaseConstructor
from .cyaml import *
from .dumper import *
from .error import *
from .events import *
from .loader import *
from .nodes import *
from .representer import BaseRepresenter
from .resolver import BaseResolver
from .tokens import *

if sys.version_info >= (3, 0):
_Str = str
else:
_Str = Union[Text, str]
# FIXME: the functions really return py2:unicode/py3:str if encoding is None, otherwise py2:str/py3:bytes. Waiting for python/mypy#5621
# FIXME: the functions really return str if encoding is None, otherwise bytes. Waiting for python/mypy#5621
_Yaml = Any

__with_libyaml__: Any
Expand All @@ -28,18 +23,19 @@ _T = TypeVar("_T")
_Constructor = TypeVar("_Constructor", bound=BaseConstructor)
_Representer = TypeVar("_Representer", bound=BaseRepresenter)

def warnings(settings=...): ...
def scan(stream, Loader=...): ...
def parse(stream, Loader=...): ...
def compose(stream, Loader=...): ...
def compose_all(stream, Loader=...): ...
def load(stream: bytes | IO[bytes] | Text | IO[Text], Loader=...) -> Any: ...
def load_all(stream: bytes | IO[bytes] | Text | IO[Text], Loader=...) -> Iterator[Any]: ...
def full_load(stream: bytes | IO[bytes] | Text | IO[Text]) -> Any: ...
def full_load_all(stream: bytes | IO[bytes] | Text | IO[Text]) -> Iterator[Any]: ...
def safe_load(stream: bytes | IO[bytes] | Text | IO[Text]) -> Any: ...
def safe_load_all(stream: bytes | IO[bytes] | Text | IO[Text]) -> Iterator[Any]: ...
def unsafe_load(stream: bytes | IO[bytes] | Text | IO[Text]) -> Any: ...
def unsafe_load_all(stream: bytes | IO[bytes] | Text | IO[Text]) -> Iterator[Any]: ...
def load(stream: bytes | IO[bytes] | str | IO[str], Loader) -> Any: ...
def load_all(stream: bytes | IO[bytes] | str | IO[str], Loader) -> Iterator[Any]: ...
def full_load(stream: bytes | IO[bytes] | str | IO[str]) -> Any: ...
def full_load_all(stream: bytes | IO[bytes] | str | IO[str]) -> Iterator[Any]: ...
def safe_load(stream: bytes | IO[bytes] | str | IO[str]) -> Any: ...
def safe_load_all(stream: bytes | IO[bytes] | str | IO[str]) -> Iterator[Any]: ...
def unsafe_load(stream: bytes | IO[bytes] | str | IO[str]) -> Any: ...
def unsafe_load_all(stream: bytes | IO[bytes] | str | IO[str]) -> Iterator[Any]: ...
def emit(events, stream=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=...): ...
@overload
def serialize_all(
Expand Down Expand Up @@ -67,7 +63,7 @@ def serialize_all(
width=...,
allow_unicode=...,
line_break=...,
encoding: _Str | None = ...,
encoding: str | None = ...,
explicit_start=...,
explicit_end=...,
version=...,
Expand Down Expand Up @@ -101,7 +97,7 @@ def serialize(
width=...,
allow_unicode=...,
line_break=...,
encoding: _Str | None = ...,
encoding: str | None = ...,
explicit_start=...,
explicit_end=...,
version=...,
Expand Down Expand Up @@ -138,7 +134,7 @@ def dump_all(
width=...,
allow_unicode=...,
line_break=...,
encoding: _Str | None = ...,
encoding: str | None = ...,
explicit_start=...,
explicit_end=...,
version=...,
Expand Down Expand Up @@ -178,7 +174,7 @@ def dump(
width=...,
allow_unicode=...,
line_break=...,
encoding: _Str | None = ...,
encoding: str | None = ...,
explicit_start=...,
explicit_end=...,
version=...,
Expand Down Expand Up @@ -216,7 +212,7 @@ def safe_dump_all(
width=...,
allow_unicode=...,
line_break=...,
encoding: _Str | None = ...,
encoding: str | None = ...,
explicit_start=...,
explicit_end=...,
version=...,
Expand Down Expand Up @@ -254,40 +250,40 @@ def safe_dump(
width=...,
allow_unicode=...,
line_break=...,
encoding: _Str | None = ...,
encoding: str | None = ...,
explicit_start=...,
explicit_end=...,
version=...,
tags=...,
sort_keys: bool = ...,
) -> _Yaml: ...
def add_implicit_resolver(
tag: _Str,
tag: str,
regexp: Pattern[str],
first: Iterable[Any] | None = ...,
Loader: Type[BaseResolver] | None = ...,
Dumper: Type[BaseResolver] = ...,
) -> None: ...
def add_path_resolver(
tag: _Str,
tag: str,
path: Iterable[Any],
kind: Type[Any] | None = ...,
Loader: Type[BaseResolver] | None = ...,
Dumper: Type[BaseResolver] = ...,
) -> None: ...
@overload
def add_constructor(
tag: _Str, constructor: Callable[[Loader | FullLoader | UnsafeLoader, Node], Any], Loader: None = ...
tag: str, constructor: Callable[[Loader | FullLoader | UnsafeLoader, Node], Any], Loader: None = ...
) -> None: ...
@overload
def add_constructor(tag: _Str, constructor: Callable[[_Constructor, Node], Any], Loader: Type[_Constructor]) -> None: ...
def add_constructor(tag: str, constructor: Callable[[_Constructor, Node], Any], Loader: Type[_Constructor]) -> None: ...
@overload
def add_multi_constructor(
tag_prefix: _Str, multi_constructor: Callable[[Loader | FullLoader | UnsafeLoader, _Str, Node], Any], Loader: None = ...
tag_prefix: str, multi_constructor: Callable[[Loader | FullLoader | UnsafeLoader, str, Node], Any], Loader: None = ...
) -> None: ...
@overload
def add_multi_constructor(
tag_prefix: _Str, multi_constructor: Callable[[_Constructor, _Str, Node], Any], Loader: Type[_Constructor]
tag_prefix: str, multi_constructor: Callable[[_Constructor, str, Node], Any], Loader: Type[_Constructor]
) -> None: ...
@overload
def add_representer(data_type: Type[_T], representer: Callable[[Dumper, _T], Node]) -> None: ...
Expand All @@ -301,7 +297,7 @@ def add_multi_representer(
) -> None: ...

class YAMLObjectMetaclass(type):
def __init__(self, name, bases, kwds) -> None: ...
def __init__(cls, name, bases, kwds) -> None: ...

class YAMLObject(metaclass=YAMLObjectMetaclass):
yaml_loader: Any
Expand Down
56 changes: 56 additions & 0 deletions stubs/PyYAML/yaml/_yaml.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from _typeshed import SupportsRead
from collections.abc import Mapping, Sequence
from typing import IO, Any

from .events import Event
from .nodes import Node
from .tokens import Token

def get_version_string() -> str: ...
def get_version() -> tuple[int, int, int]: ...

class Mark:
name: Any
index: int
line: int
column: int
buffer: Any
pointer: Any
def __init__(self, name, index: int, line: int, column: int, buffer, pointer) -> None: ...
def get_snippet(self): ...

class CParser:
def __init__(self, stream: str | bytes | SupportsRead[str | bytes]) -> None: ...
def dispose(self) -> None: ...
def get_token(self) -> Token | None: ...
def peek_token(self) -> Token | None: ...
def check_token(self, *choices) -> bool: ...
def get_event(self) -> Event | None: ...
def peek_event(self) -> Event | None: ...
def check_event(self, *choices) -> bool: ...
def check_node(self) -> bool: ...
def get_node(self) -> Node | None: ...
def get_single_node(self) -> Node | None: ...
def raw_parse(self) -> int: ...
def raw_scan(self) -> int: ...

class CEmitter:
def __init__(
self,
stream: IO[Any],
canonical: Any | None = ...,
indent: int | None = ...,
width: int | None = ...,
allow_unicode: Any | None = ...,
line_break: str | None = ...,
encoding: str | None = ...,
explicit_start: Any | None = ...,
explicit_end: Any | None = ...,
version: Sequence[int] | None = ...,
tags: Mapping[str, str] | None = ...,
) -> None: ...
def dispose(self) -> None: ...
def emit(self, event_object) -> None: ...
def open(self) -> None: ...
def close(self) -> None: ...
def serialize(self, node) -> None: ...
12 changes: 6 additions & 6 deletions stubs/PyYAML/yaml/constructor.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import sys
from typing import Any, Text, Union
from typing import Any, Pattern, Union

from yaml.error import MarkedYAMLError
from yaml.nodes import ScalarNode

_Scalar = Union[Text, int, float, bool, None]
_Scalar = Union[str, int, float, bool, None]

class ConstructorError(MarkedYAMLError): ...

Expand All @@ -17,6 +16,7 @@ class BaseConstructor:
deep_construct: Any
def __init__(self) -> None: ...
def check_data(self): ...
def check_state_key(self, key: str) -> None: ...
def get_data(self): ...
def get_single_data(self) -> Any: ...
def construct_document(self, node): ...
Expand Down Expand Up @@ -54,6 +54,8 @@ class SafeConstructor(BaseConstructor):
def construct_undefined(self, node): ...

class FullConstructor(SafeConstructor):
def get_state_keys_blacklist(self) -> list[str]: ...
def get_state_keys_blacklist_regexp(self) -> Pattern[str]: ...
def construct_python_str(self, node): ...
def construct_python_unicode(self, node): ...
def construct_python_bytes(self, node): ...
Expand All @@ -65,7 +67,7 @@ class FullConstructor(SafeConstructor):
def construct_python_name(self, suffix, node): ...
def construct_python_module(self, suffix, node): ...
def make_python_instance(self, suffix, node, args=..., kwds=..., newobj=..., unsafe=...): ...
def set_python_instance_state(self, instance, state): ...
def set_python_instance_state(self, instance, state, unsafe: bool = ...) -> None: ...
def construct_python_object(self, suffix, node): ...
def construct_python_object_apply(self, suffix, node, newobj=...): ...
def construct_python_object_new(self, suffix, node): ...
Expand All @@ -86,8 +88,6 @@ class Constructor(SafeConstructor):
def find_python_name(self, name, mark): ...
def construct_python_name(self, suffix, node): ...
def construct_python_module(self, suffix, node): ...
if sys.version_info < (3, 0):
class classobj: ...
def make_python_instance(self, suffix, node, args=..., kwds=..., newobj=...): ...
def set_python_instance_state(self, instance, state): ...
def construct_python_object(self, suffix, node): ...
Expand Down
48 changes: 19 additions & 29 deletions stubs/PyYAML/yaml/cyaml.pyi
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
from _typeshed import SupportsRead
from typing import IO, Any, Mapping, Sequence, Text, Union
from collections.abc import Mapping, Sequence
from typing import IO, Any, Union

from yaml.constructor import BaseConstructor, FullConstructor, SafeConstructor, UnsafeConstructor
from yaml.events import Event
from yaml.nodes import Node
from yaml.representer import BaseRepresenter, SafeRepresenter
from yaml.resolver import BaseResolver, Resolver
from yaml.tokens import Token
from ._yaml import CEmitter, CParser
from .constructor import BaseConstructor, FullConstructor, SafeConstructor, UnsafeConstructor
from .representer import BaseRepresenter, SafeRepresenter
from .resolver import BaseResolver, Resolver

_Readable = SupportsRead[Union[Text, bytes]]
__all__ = ["CBaseLoader", "CSafeLoader", "CFullLoader", "CUnsafeLoader", "CLoader", "CBaseDumper", "CSafeDumper", "CDumper"]

class CParser:
def __init__(self, stream: str | bytes | _Readable) -> None: ...
def dispose(self) -> None: ...
def get_token(self) -> Token | None: ...
def peek_token(self) -> Token | None: ...
def check_token(self, *choices) -> bool: ...
def get_event(self) -> Event | None: ...
def peek_event(self) -> Event | None: ...
def check_event(self, *choices) -> bool: ...
def check_node(self) -> bool: ...
def get_node(self) -> Node | None: ...
def get_single_node(self) -> Node | None: ...
_Readable = SupportsRead[Union[str, bytes]]

class CBaseLoader(CParser, BaseConstructor, BaseResolver):
def __init__(self, stream: str | bytes | _Readable) -> None: ...
Expand All @@ -38,40 +26,42 @@ class CFullLoader(CParser, FullConstructor, Resolver):
class CUnsafeLoader(CParser, UnsafeConstructor, Resolver):
def __init__(self, stream: str | bytes | _Readable) -> None: ...

class CEmitter(object):
class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver):
def __init__(
self,
stream: IO[Any],
default_style: str | None = ...,
default_flow_style: bool | None = ...,
canonical: Any | None = ...,
indent: int | None = ...,
width: int | None = ...,
allow_unicode: Any | None = ...,
line_break: str | None = ...,
encoding: Text | None = ...,
encoding: str | None = ...,
explicit_start: Any | None = ...,
explicit_end: Any | None = ...,
version: Sequence[int] | None = ...,
tags: Mapping[Text, Text] | None = ...,
tags: Mapping[str, str] | None = ...,
sort_keys: bool = ...,
) -> None: ...

class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver):
class CDumper(CEmitter, SafeRepresenter, Resolver):
def __init__(
self,
stream: IO[Any],
default_style: str | None = ...,
default_flow_style: bool | None = ...,
default_flow_style: bool = ...,
canonical: Any | None = ...,
indent: int | None = ...,
width: int | None = ...,
allow_unicode: Any | None = ...,
line_break: str | None = ...,
encoding: Text | None = ...,
encoding: str | None = ...,
explicit_start: Any | None = ...,
explicit_end: Any | None = ...,
version: Sequence[int] | None = ...,
tags: Mapping[Text, Text] | None = ...,
tags: Mapping[str, str] | None = ...,
sort_keys: bool = ...,
) -> None: ...

class CDumper(CEmitter, SafeRepresenter, Resolver): ...

CSafeDumper = CDumper
Loading