From 0437ed257d25b4c8906c037546db07351a6f63ec Mon Sep 17 00:00:00 2001 From: stevenlele Date: Wed, 21 Aug 2024 22:03:44 +0000 Subject: [PATCH 01/15] Auto generate --- pyrightconfig.stricter.json | 1 + stubs/ruamel.yaml/METADATA.toml | 1 + stubs/ruamel.yaml/ruamel/yaml/__init__.pyi | 9 + stubs/ruamel.yaml/ruamel/yaml/anchor.pyi | 9 + stubs/ruamel.yaml/ruamel/yaml/comments.pyi | 187 +++++++++++++ stubs/ruamel.yaml/ruamel/yaml/compat.pyi | 61 +++++ stubs/ruamel.yaml/ruamel/yaml/composer.pyi | 28 ++ .../ruamel/yaml/configobjwalker.pyi | 3 + stubs/ruamel.yaml/ruamel/yaml/constructor.pyi | 117 ++++++++ stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi | 87 ++++++ stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi | 30 +++ stubs/ruamel.yaml/ruamel/yaml/dumper.pyi | 93 +++++++ stubs/ruamel.yaml/ruamel/yaml/emitter.pyi | 184 +++++++++++++ stubs/ruamel.yaml/ruamel/yaml/error.pyi | 105 ++++++++ stubs/ruamel.yaml/ruamel/yaml/events.pyi | 114 ++++++++ stubs/ruamel.yaml/ruamel/yaml/loader.pyi | 35 +++ stubs/ruamel.yaml/ruamel/yaml/main.pyi | 249 ++++++++++++++++++ stubs/ruamel.yaml/ruamel/yaml/nodes.pyi | 61 +++++ stubs/ruamel.yaml/ruamel/yaml/parser.pyi | 67 +++++ stubs/ruamel.yaml/ruamel/yaml/reader.pyi | 44 ++++ stubs/ruamel.yaml/ruamel/yaml/representer.pyi | 91 +++++++ stubs/ruamel.yaml/ruamel/yaml/resolver.pyi | 46 ++++ stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi | 10 + stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi | 22 ++ stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi | 30 +++ .../ruamel.yaml/ruamel/yaml/scalarstring.pyi | 43 +++ stubs/ruamel.yaml/ruamel/yaml/scanner.pyi | 176 +++++++++++++ stubs/ruamel.yaml/ruamel/yaml/serializer.pyi | 42 +++ stubs/ruamel.yaml/ruamel/yaml/tag.pyi | 21 ++ stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi | 19 ++ stubs/ruamel.yaml/ruamel/yaml/tokens.pyi | 113 ++++++++ stubs/ruamel.yaml/ruamel/yaml/util.pyi | 30 +++ 32 files changed, 2128 insertions(+) create mode 100644 stubs/ruamel.yaml/METADATA.toml create mode 100644 stubs/ruamel.yaml/ruamel/yaml/__init__.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/anchor.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/comments.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/compat.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/composer.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/constructor.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/dumper.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/emitter.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/error.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/events.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/loader.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/main.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/nodes.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/parser.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/reader.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/representer.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/resolver.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/scanner.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/serializer.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/tag.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/tokens.pyi create mode 100644 stubs/ruamel.yaml/ruamel/yaml/util.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 7b4da3f9d84b..2441e2140d16 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -91,6 +91,7 @@ "stubs/reportlab", "stubs/requests", "stubs/requests-oauthlib", + "stubs/ruamel.yaml", "stubs/seaborn", "stubs/setuptools/setuptools", "stubs/shapely", diff --git a/stubs/ruamel.yaml/METADATA.toml b/stubs/ruamel.yaml/METADATA.toml new file mode 100644 index 000000000000..9550463d6ca4 --- /dev/null +++ b/stubs/ruamel.yaml/METADATA.toml @@ -0,0 +1 @@ +version = "0.18.*" diff --git a/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi b/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi new file mode 100644 index 000000000000..d240323343f7 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +from ruamel.yaml.main import * + +from .cyaml import * + +version_info: Incomplete +__version__: Incomplete +__with_libyaml__: bool diff --git a/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi b/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi new file mode 100644 index 000000000000..2f61c1540e61 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +anchor_attrib: str + +class Anchor: + attrib = anchor_attrib + value: Incomplete + always_dump: bool + def __init__(self) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi new file mode 100644 index 000000000000..61e32e060f9a --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi @@ -0,0 +1,187 @@ +from _typeshed import Incomplete +from collections.abc import Mapping, MutableSet, Set as AbstractSet, Sized +from typing import Any, Iterator + +from ruamel.yaml.compat import MutableSliceableSequence, ordereddict +from ruamel.yaml.tag import Tag + +__all__ = [ + "CommentedSeq", + "CommentedKeySeq", + "CommentedMap", + "CommentedOrderedMap", + "CommentedSet", + "comment_attrib", + "merge_attrib", + "TaggedScalar", + "C_POST", + "C_PRE", + "C_SPLIT_ON_FIRST_BLANK", + "C_BLANK_LINE_PRESERVE_SPACE", +] + +C_POST: int +C_PRE: int +C_SPLIT_ON_FIRST_BLANK: int +C_BLANK_LINE_PRESERVE_SPACE: int + +class IDX: + def __init__(self) -> None: ... + def __call__(self) -> Any: ... + +comment_attrib: str +merge_attrib: str + +class Comment: + attrib = comment_attrib + comment: Incomplete + def __init__(self, old: bool = True) -> None: ... + @property + def items(self) -> Any: ... + @property + def end(self) -> Any: ... + @end.setter + def end(self, value: Any) -> None: ... + @property + def pre(self) -> Any: ... + @pre.setter + def pre(self, value: Any) -> None: ... + def get(self, item: Any, pos: Any) -> Any: ... + def set(self, item: Any, pos: Any, value: Any) -> Any: ... + def __contains__(self, x: Any) -> Any: ... + +class NotNone: ... + +class Format: + attrib = format_attrib + def __init__(self) -> None: ... + def set_flow_style(self) -> None: ... + def set_block_style(self) -> None: ... + def flow_style(self, default: Any | None = None) -> Any: ... + +class LineCol: + attrib = line_col_attrib + line: Incomplete + col: Incomplete + data: Incomplete + def __init__(self) -> None: ... + def add_kv_line_col(self, key: Any, data: Any) -> None: ... + def key(self, k: Any) -> Any: ... + def value(self, k: Any) -> Any: ... + def item(self, idx: Any) -> Any: ... + def add_idx_line_col(self, key: Any, data: Any) -> None: ... + +class CommentedBase: + @property + def ca(self) -> Any: ... + def yaml_end_comment_extend(self, comment: Any, clear: bool = False) -> None: ... + def yaml_key_comment_extend(self, key: Any, comment: Any, clear: bool = False) -> None: ... + def yaml_value_comment_extend(self, key: Any, comment: Any, clear: bool = False) -> None: ... + def yaml_set_start_comment(self, comment: Any, indent: Any = 0) -> None: ... + def yaml_set_comment_before_after_key( + self, key: Any, before: Any = None, indent: Any = 0, after: Any = None, after_indent: Any = None + ) -> None: ... + @property + def fa(self) -> Any: ... + def yaml_add_eol_comment(self, comment: Any, key: Any | None = ..., column: Any | None = None) -> None: ... + @property + def lc(self) -> Any: ... + @property + def anchor(self) -> Any: ... + def yaml_anchor(self) -> Any: ... + def yaml_set_anchor(self, value: Any, always_dump: bool = False) -> None: ... + @property + def tag(self) -> Any: ... + def yaml_set_ctag(self, value: Tag) -> None: ... + def copy_attributes(self, t: Any, memo: Any = None) -> Any: ... + +class CommentedSeq(MutableSliceableSequence, list, CommentedBase): + def __init__(self, *args: Any, **kw: Any) -> None: ... + def __getsingleitem__(self, idx: Any) -> Any: ... + def __setsingleitem__(self, idx: Any, value: Any) -> None: ... + def __delsingleitem__(self, idx: Any = None) -> Any: ... + def __len__(self) -> int: ... + def insert(self, idx: Any, val: Any) -> None: ... + def extend(self, val: Any) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __deepcopy__(self, memo: Any) -> Any: ... + def __add__(self, other: Any) -> Any: ... + def sort(self, key: Any = None, reverse: bool = False) -> None: ... + +class CommentedKeySeq(tuple, CommentedBase): ... + +class CommentedMapView(Sized): + def __init__(self, mapping: Any) -> None: ... + def __len__(self) -> int: ... + +class CommentedMapKeysView(CommentedMapView, AbstractSet): + def __contains__(self, key: Any) -> Any: ... + def __iter__(self) -> Any: ... + +class CommentedMapItemsView(CommentedMapView, AbstractSet): + def __contains__(self, item: Any) -> Any: ... + def __iter__(self) -> Any: ... + +class CommentedMapValuesView(CommentedMapView): + def __contains__(self, value: Any) -> Any: ... + def __iter__(self) -> Any: ... + +class CommentedMap(ordereddict, CommentedBase): + def __init__(self, *args: Any, **kw: Any) -> None: ... + def update(self, *vals: Any, **kw: Any) -> None: ... + def insert(self, pos: Any, key: Any, value: Any, comment: Any | None = None) -> None: ... + def mlget(self, key: Any, default: Any = None, list_ok: Any = False) -> Any: ... + def __getitem__(self, key: Any) -> Any: ... + def __setitem__(self, key: Any, value: Any) -> None: ... + def __contains__(self, key: Any) -> bool: ... + def get(self, key: Any, default: Any = None) -> Any: ... + def non_merged_items(self) -> Any: ... + def __delitem__(self, key: Any) -> None: ... + def __iter__(self) -> Any: ... + def pop(self, key: Any, default: Any = ...) -> Any: ... + def __len__(self) -> int: ... + def __eq__(self, other: object) -> bool: ... + def keys(self) -> Any: ... + def values(self) -> Any: ... + def items(self) -> Any: ... + @property + def merge(self) -> Any: ... + def copy(self) -> Any: ... + def add_referent(self, cm: Any) -> None: ... + def add_yaml_merge(self, value: Any) -> None: ... + def update_key_value(self, key: Any) -> None: ... + def __deepcopy__(self, memo: Any) -> Any: ... + +class CommentedKeyMap(CommentedBase, Mapping): + def __init__(self, *args: Any, **kw: Any) -> None: ... + __delitem__ = raise_immutable + __setitem__ = raise_immutable + clear = raise_immutable + pop = raise_immutable + popitem = raise_immutable + setdefault = raise_immutable + update = raise_immutable + def __getitem__(self, index: Any) -> Any: ... + def __iter__(self) -> Iterator[Any]: ... + def __len__(self) -> int: ... + def __hash__(self) -> Any: ... + @classmethod + def fromkeys(keys: Any, v: Any = None) -> Any: ... + +class CommentedOrderedMap(CommentedMap): ... + +class CommentedSet(MutableSet, CommentedBase): + odict: Incomplete + def __init__(self, values: Any = None) -> None: ... + def add(self, value: Any) -> None: ... + def discard(self, value: Any) -> None: ... + def __contains__(self, x: Any) -> Any: ... + def __iter__(self) -> Any: ... + def __len__(self) -> int: ... + +class TaggedScalar(CommentedBase): + value: Incomplete + style: Incomplete + def __init__(self, value: Any = None, style: Any = None, tag: Any = None) -> None: ... + def count(self, s: str, start: int | None = None, end: int | None = None) -> Any: ... + def __getitem__(self, pos: int) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi new file mode 100644 index 000000000000..e794acb7da94 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi @@ -0,0 +1,61 @@ +import abc +import collections.abc +import io +from _typeshed import Incomplete +from abc import abstractmethod +from typing import Any + +from ordereddict import OrderedDict +from ruamel.yaml.docinfo import Version + +SupportsIndex = int +StreamType = Any +StreamTextType = StreamType +VersionType = str | tuple[int, int] | list[int] | Version | None + +class ordereddict(OrderedDict): + def insert(self, pos: int, key: Any, value: Any) -> None: ... + +StringIO = io.StringIO +BytesIO = io.BytesIO +builtins_module: str + +def with_metaclass(meta: Any, *bases: Any) -> Any: ... + +DBG_TOKEN: int +DBG_EVENT: int +DBG_NODE: int + +class ObjectCounter: + map: Incomplete + def __init__(self) -> None: ... + def __call__(self, k: Any) -> None: ... + def dump(self) -> None: ... + +object_counter: Incomplete + +def dbg(val: Any = None) -> Any: ... + +class Nprint: + def __init__(self, file_name: Any = None) -> None: ... + def __call__(self, *args: Any, **kw: Any) -> None: ... + def set_max_print(self, i: int) -> None: ... + def fp(self, mode: str = "a") -> Any: ... + +nprint: Incomplete +nprintf: Incomplete + +def check_namespace_char(ch: Any) -> bool: ... +def check_anchorname_char(ch: Any) -> bool: ... +def version_tnf(t1: Any, t2: Any = None) -> Any: ... + +class MutableSliceableSequence(collections.abc.MutableSequence, metaclass=abc.ABCMeta): + def __getitem__(self, index: Any) -> Any: ... + def __setitem__(self, index: Any, value: Any) -> None: ... + def __delitem__(self, index: Any) -> None: ... + @abstractmethod + def __getsingleitem__(self, index: Any) -> Any: ... + @abstractmethod + def __setsingleitem__(self, index: Any, value: Any) -> None: ... + @abstractmethod + def __delsingleitem__(self, index: Any) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi new file mode 100644 index 000000000000..83cf5143ad12 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi @@ -0,0 +1,28 @@ +from _typeshed import Incomplete +from typing import Any + +from ruamel.yaml.error import MarkedYAMLError + +__all__ = ["Composer", "ComposerError"] + +class ComposerError(MarkedYAMLError): ... + +class Composer: + loader: Incomplete + anchors: Incomplete + warn_double_anchors: bool + def __init__(self, loader: Any = None) -> None: ... + @property + def parser(self) -> Any: ... + @property + def resolver(self) -> Any: ... + def check_node(self) -> Any: ... + def get_node(self) -> Any: ... + def get_single_node(self) -> Any: ... + def compose_document(self) -> Any: ... + def return_alias(self, a: Any) -> Any: ... + def compose_node(self, parent: Any, index: Any) -> Any: ... + def compose_scalar_node(self, anchor: Any) -> Any: ... + def compose_sequence_node(self, anchor: Any) -> Any: ... + def compose_mapping_node(self, anchor: Any) -> Any: ... + def check_end_doc_comment(self, end_event: Any, node: Any) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi b/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi new file mode 100644 index 000000000000..82e056e33a89 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def configobj_walker(cfg: Any) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi new file mode 100644 index 000000000000..c71f11bed154 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi @@ -0,0 +1,117 @@ +import datetime +from _typeshed import Incomplete +from typing import Any, Iterator + +from ruamel.yaml.comments import * +from ruamel.yaml.comments import CommentedMap, CommentedOrderedMap, CommentedSeq, CommentedSet, TaggedScalar +from ruamel.yaml.error import MarkedYAMLError, MarkedYAMLFutureWarning +from ruamel.yaml.nodes import * +from ruamel.yaml.scalarbool import ScalarBoolean +from ruamel.yaml.timestamp import TimeStamp +from ruamel.yaml.util import timestamp_regexp + +__all__ = ["BaseConstructor", "SafeConstructor", "Constructor", "ConstructorError", "RoundTripConstructor"] + +class ConstructorError(MarkedYAMLError): ... +class DuplicateKeyFutureWarning(MarkedYAMLFutureWarning): ... +class DuplicateKeyError(MarkedYAMLError): ... + +class BaseConstructor: + yaml_constructors: dict[Any, Any] + yaml_multi_constructors: dict[Any, Any] + loader: Incomplete + yaml_base_dict_type: Incomplete + yaml_base_list_type: Incomplete + constructed_objects: Incomplete + recursive_objects: Incomplete + state_generators: Incomplete + deep_construct: bool + allow_duplicate_keys: Incomplete + def __init__(self, preserve_quotes: bool | None = None, loader: Any = None) -> None: ... + @property + def composer(self) -> Any: ... + @property + def resolver(self) -> Any: ... + @property + def scanner(self) -> Any: ... + def check_data(self) -> Any: ... + def get_data(self) -> Any: ... + def get_single_data(self) -> Any: ... + def construct_document(self, node: Any) -> Any: ... + def construct_object(self, node: Any, deep: bool = False) -> Any: ... + def construct_non_recursive_object(self, node: Any, tag: str | None = None) -> Any: ... + def construct_scalar(self, node: Any) -> Any: ... + def construct_sequence(self, node: Any, deep: bool = False) -> Any: ... + def construct_mapping(self, node: Any, deep: bool = False) -> Any: ... + def check_mapping_key(self, node: Any, key_node: Any, mapping: Any, key: Any, value: Any) -> bool: ... + def check_set_key(self, node: Any, key_node: Any, setting: Any, key: Any) -> None: ... + def construct_pairs(self, node: Any, deep: bool = False) -> Any: ... + @classmethod + def add_constructor(cls, tag: Any, constructor: Any) -> Any: ... + @classmethod + def add_multi_constructor(cls, tag_prefix: Any, multi_constructor: Any) -> None: ... + @classmethod + def add_default_constructor(cls, tag: str, method: Any = None, tag_base: str = "tag:yaml.org,2002:") -> None: ... + +class SafeConstructor(BaseConstructor): + def construct_scalar(self, node: Any) -> Any: ... + def flatten_mapping(self, node: Any) -> Any: ... + def construct_mapping(self, node: Any, deep: bool = False) -> Any: ... + def construct_yaml_null(self, node: Any) -> Any: ... + bool_values: Incomplete + def construct_yaml_bool(self, node: Any) -> bool: ... + def construct_yaml_int(self, node: Any) -> int: ... + inf_value: float + nan_value: Incomplete + def construct_yaml_float(self, node: Any) -> float: ... + def construct_yaml_binary(self, node: Any) -> Any: ... + timestamp_regexp = timestamp_regexp + def construct_yaml_timestamp(self, node: Any, values: Any = None) -> Any: ... + def construct_yaml_omap(self, node: Any) -> Any: ... + def construct_yaml_pairs(self, node: Any) -> Any: ... + def construct_yaml_set(self, node: Any) -> Any: ... + def construct_yaml_str(self, node: Any) -> Any: ... + def construct_yaml_seq(self, node: Any) -> Any: ... + def construct_yaml_map(self, node: Any) -> Any: ... + def construct_yaml_object(self, node: Any, cls: Any) -> Any: ... + def construct_undefined(self, node: Any) -> None: ... + +class Constructor(SafeConstructor): + def construct_python_str(self, node: Any) -> Any: ... + def construct_python_unicode(self, node: Any) -> Any: ... + def construct_python_bytes(self, node: Any) -> Any: ... + def construct_python_long(self, node: Any) -> int: ... + def construct_python_complex(self, node: Any) -> Any: ... + def construct_python_tuple(self, node: Any) -> Any: ... + def find_python_module(self, name: Any, mark: Any) -> Any: ... + def find_python_name(self, name: Any, mark: Any) -> Any: ... + def construct_python_name(self, suffix: Any, node: Any) -> Any: ... + def construct_python_module(self, suffix: Any, node: Any) -> Any: ... + def make_python_instance(self, suffix: Any, node: Any, args: Any = None, kwds: Any = None, newobj: bool = False) -> Any: ... + def set_python_instance_state(self, instance: Any, state: Any) -> None: ... + def construct_python_object(self, suffix: Any, node: Any) -> Any: ... + def construct_python_object_apply(self, suffix: Any, node: Any, newobj: bool = False) -> Any: ... + def construct_python_object_new(self, suffix: Any, node: Any) -> Any: ... + @classmethod + def add_default_constructor(cls, tag: str, method: Any = None, tag_base: str = "tag:yaml.org,2002:python/") -> None: ... + +class RoundTripConstructor(SafeConstructor): + def comment(self, idx: Any) -> Any: ... + def comments(self, list_of_comments: Any, idx: Any | None = None) -> Any: ... + def construct_scalar(self, node: Any) -> Any: ... + def construct_yaml_int(self, node: Any) -> Any: ... + def construct_yaml_float(self, node: Any) -> Any: ... + def construct_yaml_str(self, node: Any) -> Any: ... + def construct_rt_sequence(self, node: Any, seqtyp: Any, deep: bool = False) -> Any: ... + def flatten_mapping(self, node: Any) -> Any: ... + def construct_mapping(self, node: Any, maptyp: Any, deep: bool = False) -> Any: ... + def construct_setting(self, node: Any, typ: Any, deep: bool = False) -> Any: ... + def construct_yaml_seq(self, node: Any) -> Iterator[CommentedSeq]: ... + def construct_yaml_map(self, node: Any) -> Iterator[CommentedMap]: ... + def set_collection_style(self, data: Any, node: Any) -> None: ... + def construct_yaml_object(self, node: Any, cls: Any) -> Any: ... + def construct_yaml_omap(self, node: Any) -> Iterator[CommentedOrderedMap]: ... + def construct_yaml_set(self, node: Any) -> Iterator[CommentedSet]: ... + def construct_unknown(self, node: Any) -> Iterator[CommentedMap | TaggedScalar | CommentedSeq]: ... + def construct_yaml_timestamp(self, node: Any, values: Any = None) -> datetime.date | datetime.datetime | TimeStamp: ... + def construct_yaml_sbool(self, node: Any) -> bool | ScalarBoolean: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi b/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi new file mode 100644 index 000000000000..88107d8989cd --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi @@ -0,0 +1,87 @@ +from typing import Any + +from _ruamel_yaml import CEmitter, CParser +from ruamel.yaml.compat import StreamTextType, VersionType +from ruamel.yaml.constructor import BaseConstructor, Constructor, SafeConstructor +from ruamel.yaml.representer import BaseRepresenter, Representer, SafeRepresenter +from ruamel.yaml.resolver import BaseResolver, Resolver + +__all__ = ["CBaseLoader", "CSafeLoader", "CLoader", "CBaseDumper", "CSafeDumper", "CDumper"] + +class CBaseLoader(CParser, BaseConstructor, BaseResolver): + def __init__( + self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None + ) -> None: ... + +class CSafeLoader(CParser, SafeConstructor, Resolver): + def __init__( + self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None + ) -> None: ... + +class CLoader(CParser, Constructor, Resolver): + def __init__( + self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None + ) -> None: ... + +class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver): + def __init__( + self, + stream: Any, + default_style: Any = None, + default_flow_style: Any = None, + canonical: bool | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: Any = None, + tags: Any = None, + block_seq_indent: Any = None, + top_level_colon_align: Any = None, + prefix_colon: Any = None, + ) -> None: ... + +class CSafeDumper(CEmitter, SafeRepresenter, Resolver): + def __init__( + self, + stream: Any, + default_style: Any = None, + default_flow_style: Any = None, + canonical: bool | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: Any = None, + tags: Any = None, + block_seq_indent: Any = None, + top_level_colon_align: Any = None, + prefix_colon: Any = None, + ) -> None: ... + +class CDumper(CEmitter, Representer, Resolver): + def __init__( + self, + stream: Any, + default_style: Any = None, + default_flow_style: Any = None, + canonical: bool | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: Any = None, + tags: Any = None, + block_seq_indent: Any = None, + top_level_colon_align: Any = None, + prefix_colon: Any = None, + ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi b/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi new file mode 100644 index 000000000000..8188a24d3837 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi @@ -0,0 +1,30 @@ +from _typeshed import Incomplete + +class Version: + def __init__(self, major: int, minor: int) -> None: ... + @property + def major(self) -> int: ... + @property + def minor(self) -> int: ... + def __eq__(self, v: object) -> bool: ... + def __lt__(self, v: Version) -> bool: ... + def __le__(self, v: Version) -> bool: ... + def __gt__(self, v: Version) -> bool: ... + def __ge__(self, v: Version) -> bool: ... + +def version(major: int | str | tuple[int, int] | None, minor: int | None = None) -> Version | None: ... + +class Tag: + def __init__(self, handle: str, prefix: str) -> None: ... + @property + def handle(self) -> str: ... + @property + def prefix(self) -> str: ... + +class DocInfo: + requested_version: Incomplete + doc_version: Incomplete + tags: Incomplete + def __init__( + self, requested_version: Version | None = None, doc_version: Version | None = None, tags: list[Tag] | None = None + ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi new file mode 100644 index 000000000000..c09a06a7af71 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi @@ -0,0 +1,93 @@ +from typing import Any + +from ruamel.yaml.compat import StreamType +from ruamel.yaml.emitter import Emitter +from ruamel.yaml.representer import BaseRepresenter, Representer, RoundTripRepresenter, SafeRepresenter +from ruamel.yaml.resolver import BaseResolver, Resolver, VersionedResolver +from ruamel.yaml.serializer import Serializer + +__all__ = ["BaseDumper", "SafeDumper", "Dumper", "RoundTripDumper"] + +class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): + def __init__( + self, + stream: StreamType, + default_style: Any = None, + default_flow_style: Any = None, + canonical: bool | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: Any = None, + tags: Any = None, + block_seq_indent: Any = None, + top_level_colon_align: Any = None, + prefix_colon: Any = None, + ) -> None: ... + +class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): + def __init__( + self, + stream: StreamType, + default_style: Any = None, + default_flow_style: Any = None, + canonical: bool | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: Any = None, + tags: Any = None, + block_seq_indent: Any = None, + top_level_colon_align: Any = None, + prefix_colon: Any = None, + ) -> None: ... + +class Dumper(Emitter, Serializer, Representer, Resolver): + def __init__( + self, + stream: StreamType, + default_style: Any = None, + default_flow_style: Any = None, + canonical: bool | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: Any = None, + tags: Any = None, + block_seq_indent: Any = None, + top_level_colon_align: Any = None, + prefix_colon: Any = None, + ) -> None: ... + +class RoundTripDumper(Emitter, Serializer, RoundTripRepresenter, VersionedResolver): + def __init__( + self, + stream: StreamType, + default_style: Any = None, + default_flow_style: bool | None = None, + canonical: int | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: Any = None, + tags: Any = None, + block_seq_indent: Any = None, + top_level_colon_align: Any = None, + prefix_colon: Any = None, + ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi new file mode 100644 index 000000000000..6a455cff4611 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi @@ -0,0 +1,184 @@ +from _typeshed import Incomplete +from typing import Any + +from ruamel.yaml.compat import StreamType +from ruamel.yaml.error import YAMLError +from ruamel.yaml.events import * + +__all__ = ["Emitter", "EmitterError"] + +class EmitterError(YAMLError): ... + +class ScalarAnalysis: + scalar: Incomplete + empty: Incomplete + multiline: Incomplete + allow_flow_plain: Incomplete + allow_block_plain: Incomplete + allow_single_quoted: Incomplete + allow_double_quoted: Incomplete + allow_block: Incomplete + def __init__( + self, + scalar: Any, + empty: Any, + multiline: Any, + allow_flow_plain: bool, + allow_block_plain: bool, + allow_single_quoted: bool, + allow_double_quoted: bool, + allow_block: bool, + ) -> None: ... + +class Indents: + values: Incomplete + def __init__(self) -> None: ... + def append(self, val: Any, seq: Any) -> None: ... + def pop(self) -> Any: ... + def seq_seq(self) -> bool: ... + def last_seq(self) -> bool: ... + def seq_flow_align(self, seq_indent: int, column: int, pre_comment: bool | None = False) -> int: ... + def __len__(self) -> int: ... + +class Emitter: + DEFAULT_TAG_PREFIXES: Incomplete + MAX_SIMPLE_KEY_LENGTH: int + flow_seq_start: str + flow_seq_end: str + flow_seq_separator: str + flow_map_start: str + flow_map_end: str + flow_map_separator: str + dumper: Incomplete + encoding: Incomplete + allow_space_break: Incomplete + states: Incomplete + state: Incomplete + events: Incomplete + event: Incomplete + indents: Incomplete + indent: Incomplete + flow_context: Incomplete + root_context: bool + sequence_context: bool + mapping_context: bool + simple_key_context: bool + line: int + column: int + whitespace: bool + indention: bool + compact_seq_seq: bool + compact_seq_map: bool + no_newline: Incomplete + open_ended: bool + colon: str + prefixed_colon: Incomplete + brace_single_entry_mapping_in_flow_sequence: Incomplete + canonical: Incomplete + allow_unicode: Incomplete + unicode_supplementary: Incomplete + sequence_dash_offset: Incomplete + top_level_colon_align: Incomplete + best_sequence_indent: int + requested_indent: Incomplete + best_map_indent: Incomplete + best_width: int + best_line_break: str + tag_prefixes: Incomplete + prepared_anchor: Incomplete + prepared_tag: Incomplete + analysis: Incomplete + style: Incomplete + scalar_after_indicator: bool + alt_null: str + def __init__( + self, + stream: StreamType, + canonical: Any = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + block_seq_indent: int | None = None, + top_level_colon_align: bool | None = None, + prefix_colon: Any = None, + brace_single_entry_mapping_in_flow_sequence: bool | None = None, + dumper: Any = None, + ) -> None: ... + @property + def stream(self) -> Any: ... + @stream.setter + def stream(self, val: Any) -> None: ... + @property + def serializer(self) -> Any: ... + @property + def flow_level(self) -> int: ... + def dispose(self) -> None: ... + def emit(self, event: Any) -> None: ... + def need_more_events(self) -> bool: ... + def need_events(self, count: int) -> bool: ... + def increase_indent(self, flow: bool = False, sequence: bool | None = None, indentless: bool = False) -> None: ... + def expect_stream_start(self) -> None: ... + def expect_nothing(self) -> None: ... + def expect_first_document_start(self) -> Any: ... + def expect_document_start(self, first: bool = False) -> None: ... + def expect_document_end(self) -> None: ... + def expect_document_root(self) -> None: ... + def expect_node( + self, root: bool = False, sequence: bool = False, mapping: bool = False, simple_key: bool = False + ) -> None: ... + def expect_alias(self) -> None: ... + def expect_scalar(self) -> None: ... + def expect_flow_sequence(self, force_flow_indent: bool | None = False) -> None: ... + def expect_first_flow_sequence_item(self) -> None: ... + def expect_flow_sequence_item(self) -> None: ... + def expect_flow_mapping(self, single: bool | None = False, force_flow_indent: bool | None = False) -> None: ... + def expect_first_flow_mapping_key(self) -> None: ... + def expect_flow_mapping_key(self) -> None: ... + def expect_flow_mapping_simple_value(self) -> None: ... + def expect_flow_mapping_value(self) -> None: ... + def expect_block_sequence(self) -> None: ... + def expect_first_block_sequence_item(self) -> Any: ... + def expect_block_sequence_item(self, first: bool = False) -> None: ... + def expect_block_mapping(self) -> None: ... + def expect_first_block_mapping_key(self) -> None: ... + def expect_block_mapping_key(self, first: Any = False) -> None: ... + def expect_block_mapping_simple_value(self) -> None: ... + def expect_block_mapping_value(self) -> None: ... + def check_empty_sequence(self) -> bool: ... + def check_empty_mapping(self) -> bool: ... + def check_empty_document(self) -> bool: ... + def check_simple_key(self) -> bool: ... + def process_anchor(self, indicator: Any) -> bool: ... + def process_tag(self) -> None: ... + def choose_scalar_style(self) -> Any: ... + def process_scalar(self) -> None: ... + def prepare_version(self, version: Any) -> Any: ... + def prepare_tag_handle(self, handle: Any) -> Any: ... + def prepare_tag_prefix(self, prefix: Any) -> Any: ... + def prepare_tag(self, tag: Any) -> Any: ... + def prepare_anchor(self, anchor: Any) -> Any: ... + def analyze_scalar(self, scalar: Any) -> Any: ... + def flush_stream(self) -> None: ... + def write_stream_start(self) -> None: ... + def write_stream_end(self) -> None: ... + def write_indicator( + self, indicator: Any, need_whitespace: Any, whitespace: bool = False, indention: bool = False + ) -> None: ... + def write_indent(self) -> None: ... + def write_line_break(self, data: Any = None) -> None: ... + def write_version_directive(self, version_text: Any) -> None: ... + def write_tag_directive(self, handle_text: Any, prefix_text: Any) -> None: ... + def write_single_quoted(self, text: Any, split: Any = True) -> None: ... + ESCAPE_REPLACEMENTS: Incomplete + def write_double_quoted(self, text: Any, split: Any = True) -> None: ... + def determine_block_hints(self, text: Any) -> Any: ... + def write_folded(self, text: Any, comment: Any) -> None: ... + def write_literal(self, text: Any, comment: Any = None) -> None: ... + def write_plain(self, text: Any, split: Any = True) -> None: ... + def write_comment(self, comment: Any, pre: bool = False) -> None: ... + def write_pre_comment(self, event: Any) -> bool: ... + def write_post_comment(self, event: Any) -> bool: ... + +class RoundTripEmitter(Emitter): + def prepare_tag(self, ctag: Any) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/error.pyi b/stubs/ruamel.yaml/ruamel/yaml/error.pyi new file mode 100644 index 000000000000..36a80851d683 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/error.pyi @@ -0,0 +1,105 @@ +from _typeshed import Incomplete +from typing import Any + +__all__ = [ + "FileMark", + "StringMark", + "CommentMark", + "YAMLError", + "MarkedYAMLError", + "ReusedAnchorWarning", + "UnsafeLoaderWarning", + "MarkedYAMLWarning", + "MarkedYAMLFutureWarning", +] + +class StreamMark: + name: Incomplete + index: Incomplete + line: Incomplete + column: Incomplete + def __init__(self, name: Any, index: int, line: int, column: int) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... + +class FileMark(StreamMark): ... + +class StringMark(StreamMark): + buffer: Incomplete + pointer: Incomplete + def __init__(self, name: Any, index: int, line: int, column: int, buffer: Any, pointer: Any) -> None: ... + def get_snippet(self, indent: int = 4, max_length: int = 75) -> Any: ... + +class CommentMark: + column: Incomplete + def __init__(self, column: Any) -> None: ... + +class YAMLError(Exception): ... + +class MarkedYAMLError(YAMLError): + context: Incomplete + context_mark: Incomplete + problem: Incomplete + problem_mark: Incomplete + note: Incomplete + def __init__( + self, + context: Any = None, + context_mark: Any = None, + problem: Any = None, + problem_mark: Any = None, + note: Any = None, + warn: Any = None, + ) -> None: ... + def check_append(self, lines: list[str], val: str | None) -> None: ... + +class YAMLStreamError(Exception): ... +class YAMLWarning(Warning): ... + +class MarkedYAMLWarning(YAMLWarning): + context: Incomplete + context_mark: Incomplete + problem: Incomplete + problem_mark: Incomplete + note: Incomplete + warn: Incomplete + def __init__( + self, + context: Any = None, + context_mark: Any = None, + problem: Any = None, + problem_mark: Any = None, + note: Any = None, + warn: Any = None, + ) -> None: ... + def check_append(self, lines: list[str], val: str | None) -> None: ... + +class ReusedAnchorWarning(YAMLWarning): ... + +class UnsafeLoaderWarning(YAMLWarning): + text: str + +class MantissaNoDotYAML1_1Warning(YAMLWarning): + node: Incomplete + flt: Incomplete + def __init__(self, node: Any, flt_str: Any) -> None: ... + +class YAMLFutureWarning(Warning): ... + +class MarkedYAMLFutureWarning(YAMLFutureWarning): + context: Incomplete + context_mark: Incomplete + problem: Incomplete + problem_mark: Incomplete + note: Incomplete + warn: Incomplete + def __init__( + self, + context: Any = None, + context_mark: Any = None, + problem: Any = None, + problem_mark: Any = None, + note: Any = None, + warn: Any = None, + ) -> None: ... + def check_append(self, lines: list[str], val: str | None) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/events.pyi b/stubs/ruamel.yaml/ruamel/yaml/events.pyi new file mode 100644 index 000000000000..118f053e703d --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/events.pyi @@ -0,0 +1,114 @@ +from _typeshed import Incomplete +from typing import Any + +SHOW_LINES: bool + +def CommentCheck() -> None: ... + +class Event: + crepr: str + start_mark: Incomplete + end_mark: Incomplete + comment: Incomplete + def __init__(self, start_mark: Any = None, end_mark: Any = None, comment: Any = ...) -> None: ... + def compact_repr(self) -> str: ... + +class NodeEvent(Event): + anchor: Incomplete + def __init__(self, anchor: Any, start_mark: Any = None, end_mark: Any = None, comment: Any = None) -> None: ... + +class CollectionStartEvent(NodeEvent): + ctag: Incomplete + implicit: Incomplete + flow_style: Incomplete + nr_items: Incomplete + def __init__( + self, + anchor: Any, + tag: Any, + implicit: Any, + start_mark: Any = None, + end_mark: Any = None, + flow_style: Any = None, + comment: Any = None, + nr_items: int | None = None, + ) -> None: ... + @property + def tag(self) -> str | None: ... + +class CollectionEndEvent(Event): ... + +class StreamStartEvent(Event): + crepr: str + encoding: Incomplete + def __init__(self, start_mark: Any = None, end_mark: Any = None, encoding: Any = None, comment: Any = None) -> None: ... + +class StreamEndEvent(Event): + crepr: str + +class DocumentStartEvent(Event): + crepr: str + explicit: Incomplete + version: Incomplete + tags: Incomplete + def __init__( + self, + start_mark: Any = None, + end_mark: Any = None, + explicit: Any = None, + version: Any = None, + tags: Any = None, + comment: Any = None, + ) -> None: ... + def compact_repr(self) -> str: ... + +class DocumentEndEvent(Event): + crepr: str + explicit: Incomplete + def __init__(self, start_mark: Any = None, end_mark: Any = None, explicit: Any = None, comment: Any = None) -> None: ... + def compact_repr(self) -> str: ... + +class AliasEvent(NodeEvent): + crepr: str + style: Incomplete + def __init__( + self, anchor: Any, start_mark: Any = None, end_mark: Any = None, style: Any = None, comment: Any = None + ) -> None: ... + def compact_repr(self) -> str: ... + +class ScalarEvent(NodeEvent): + crepr: str + ctag: Incomplete + implicit: Incomplete + value: Incomplete + style: Incomplete + def __init__( + self, + anchor: Any, + tag: Any, + implicit: Any, + value: Any, + start_mark: Any = None, + end_mark: Any = None, + style: Any = None, + comment: Any = None, + ) -> None: ... + @property + def tag(self) -> str | None: ... + @tag.setter + def tag(self, val: Any) -> None: ... + def compact_repr(self) -> str: ... + +class SequenceStartEvent(CollectionStartEvent): + crepr: str + def compact_repr(self) -> str: ... + +class SequenceEndEvent(CollectionEndEvent): + crepr: str + +class MappingStartEvent(CollectionStartEvent): + crepr: str + def compact_repr(self) -> str: ... + +class MappingEndEvent(CollectionEndEvent): + crepr: str diff --git a/stubs/ruamel.yaml/ruamel/yaml/loader.pyi b/stubs/ruamel.yaml/ruamel/yaml/loader.pyi new file mode 100644 index 000000000000..3272a5a9d18b --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/loader.pyi @@ -0,0 +1,35 @@ +from _typeshed import Incomplete + +from ruamel.yaml.compat import StreamTextType, VersionType +from ruamel.yaml.composer import Composer +from ruamel.yaml.constructor import BaseConstructor, Constructor, RoundTripConstructor, SafeConstructor +from ruamel.yaml.parser import Parser, RoundTripParser +from ruamel.yaml.reader import Reader +from ruamel.yaml.resolver import VersionedResolver +from ruamel.yaml.scanner import RoundTripScanner, Scanner + +__all__ = ["BaseLoader", "SafeLoader", "Loader", "RoundTripLoader"] + +class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, VersionedResolver): + comment_handling: Incomplete + def __init__( + self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None + ) -> None: ... + +class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, VersionedResolver): + comment_handling: Incomplete + def __init__( + self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None + ) -> None: ... + +class Loader(Reader, Scanner, Parser, Composer, Constructor, VersionedResolver): + comment_handling: Incomplete + def __init__( + self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None + ) -> None: ... + +class RoundTripLoader(Reader, RoundTripScanner, RoundTripParser, Composer, RoundTripConstructor, VersionedResolver): + comment_handling: Incomplete + def __init__( + self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None + ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/main.pyi b/stubs/ruamel.yaml/ruamel/yaml/main.pyi new file mode 100644 index 000000000000..77a4780868a6 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/main.pyi @@ -0,0 +1,249 @@ +from _typeshed import Incomplete +from pathlib import Path +from types import TracebackType +from typing import Any + +from ruamel.yaml.compat import ( + StreamTextType as StreamTextType, + StreamType as StreamType, + VersionType as VersionType, + nprintf as nprintf, +) +from ruamel.yaml.constructor import Constructor +from ruamel.yaml.error import UnsafeLoaderWarning as UnsafeLoaderWarning +from ruamel.yaml.events import * +from ruamel.yaml.nodes import * +from ruamel.yaml.representer import Representer +from ruamel.yaml.resolver import VersionedResolver as VersionedResolver +from ruamel.yaml.tokens import * + +class YAML: + typ: Incomplete + pure: Incomplete + plug_ins: Incomplete + Resolver: Incomplete + allow_unicode: bool + Reader: Incomplete + Representer: Incomplete + Constructor: Incomplete + Scanner: Incomplete + Serializer: Incomplete + default_flow_style: Incomplete + comment_handling: Incomplete + Emitter: Incomplete + Parser: Incomplete + Composer: Incomplete + stream: Incomplete + canonical: Incomplete + old_indent: Incomplete + width: Incomplete + line_break: Incomplete + map_indent: Incomplete + sequence_indent: Incomplete + sequence_dash_offset: int + compact_seq_seq: Incomplete + compact_seq_map: Incomplete + sort_base_mapping_type_on_output: Incomplete + top_level_colon_align: Incomplete + prefix_colon: Incomplete + preserve_quotes: Incomplete + allow_duplicate_keys: bool + encoding: str + explicit_start: Incomplete + explicit_end: Incomplete + doc_infos: Incomplete + default_style: Incomplete + top_level_block_style_scalar_no_indent_error_1_1: bool + scalar_after_indicator: Incomplete + brace_single_entry_mapping_in_flow_sequence: bool + def __init__( + self, *, typ: list[str] | str | None = None, pure: Any = False, output: Any = None, plug_ins: Any = None + ) -> None: ... + @property + def reader(self) -> Any: ... + @property + def scanner(self) -> Any: ... + @property + def parser(self) -> Any: ... + @property + def composer(self) -> Any: ... + @property + def constructor(self) -> Any: ... + @property + def resolver(self) -> Any: ... + @property + def emitter(self) -> Any: ... + @property + def serializer(self) -> Any: ... + @property + def representer(self) -> Any: ... + def scan(self, stream: StreamTextType) -> Any: ... + def parse(self, stream: StreamTextType) -> Any: ... + def compose(self, stream: Path | StreamTextType) -> Any: ... + def compose_all(self, stream: Path | StreamTextType) -> Any: ... + def load(self, stream: Path | StreamTextType) -> Any: ... + def load_all(self, stream: Path | StreamTextType) -> Any: ... + def get_constructor_parser(self, stream: StreamTextType) -> Any: ... + def emit(self, events: Any, stream: Any) -> None: ... + def serialize(self, node: Any, stream: StreamType | None) -> Any: ... + def serialize_all(self, nodes: Any, stream: StreamType | None) -> Any: ... + def dump(self, data: Path | StreamType, stream: Any = None, *, transform: Any = None) -> Any: ... + def dump_all(self, documents: Any, stream: Path | StreamType, *, transform: Any = None) -> Any: ... + def Xdump_all(self, documents: Any, stream: Any, *, transform: Any = None) -> Any: ... + def get_serializer_representer_emitter(self, stream: StreamType, tlca: Any) -> Any: ... + def map(self, **kw: Any) -> Any: ... + def seq(self, *args: Any) -> Any: ... + def official_plug_ins(self) -> Any: ... + def register_class(self, cls: Any) -> Any: ... + def __enter__(self) -> Any: ... + def __exit__(self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None) -> None: ... + @property + def version(self) -> tuple[int, int] | None: ... + @version.setter + def version(self, val: VersionType) -> None: ... + @property + def tags(self) -> Any: ... + @tags.setter + def tags(self, val: Any) -> None: ... + @property + def indent(self) -> Any: ... + @indent.setter + def indent(self, val: Any) -> None: ... + @property + def block_seq_indent(self) -> Any: ... + @block_seq_indent.setter + def block_seq_indent(self, val: Any) -> None: ... + def compact(self, seq_seq: Any = None, seq_map: Any = None) -> None: ... + +class YAMLContextManager: + def __init__(self, yaml: Any, transform: Any = None) -> None: ... + def teardown_output(self) -> None: ... + def init_output(self, first_data: Any) -> None: ... + def dump(self, data: Any) -> None: ... + +def yaml_object(yml: Any) -> Any: ... +def warn_deprecation(fun: Any, method: Any, arg: str = "") -> None: ... +def error_deprecation(fun: Any, method: Any, arg: str = "", comment: str = "instead of") -> None: ... +def scan(stream: StreamTextType, Loader: Any = ...) -> Any: ... +def parse(stream: StreamTextType, Loader: Any = ...) -> Any: ... +def compose(stream: StreamTextType, Loader: Any = ...) -> Any: ... +def compose_all(stream: StreamTextType, Loader: Any = ...) -> Any: ... +def load(stream: Any, Loader: Any = None, version: Any = None, preserve_quotes: Any = None) -> Any: ... +def load_all(stream: Any, Loader: Any = None, version: Any = None, preserve_quotes: Any = None) -> Any: ... +def safe_load(stream: StreamTextType, version: VersionType | None = None) -> Any: ... +def safe_load_all(stream: StreamTextType, version: VersionType | None = None) -> Any: ... +def round_trip_load(stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None) -> Any: ... +def round_trip_load_all( + stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None +) -> Any: ... +def emit( + events: Any, + stream: StreamType | None = None, + Dumper: Any = ..., + canonical: bool | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, +) -> Any: ... + +enc: Incomplete + +def serialize_all( + nodes: Any, + stream: StreamType | None = None, + Dumper: Any = ..., + canonical: Any = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: VersionType | None = None, + tags: Any = None, +) -> Any: ... +def serialize(node: Any, stream: StreamType | None = None, Dumper: Any = ..., **kwds: Any) -> Any: ... +def dump_all( + documents: Any, + stream: StreamType | None = None, + Dumper: Any = ..., + default_style: Any = None, + default_flow_style: Any = None, + canonical: bool | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: Any = None, + tags: Any = None, + block_seq_indent: Any = None, + top_level_colon_align: Any = None, + prefix_colon: Any = None, +) -> Any: ... +def dump( + data: Any, + stream: StreamType | None = None, + Dumper: Any = ..., + default_style: Any = None, + default_flow_style: Any = None, + canonical: bool | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: VersionType | None = None, + tags: Any = None, + block_seq_indent: Any = None, +) -> Any: ... +def safe_dump(data: Any, stream: StreamType | None = None, **kwds: Any) -> Any: ... +def round_trip_dump( + data: Any, + stream: StreamType | None = None, + Dumper: Any = ..., + default_style: Any = None, + default_flow_style: Any = None, + canonical: bool | None = None, + indent: int | None = None, + width: int | None = None, + allow_unicode: bool | None = None, + line_break: Any = None, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: VersionType | None = None, + tags: Any = None, + block_seq_indent: Any = None, + top_level_colon_align: Any = None, + prefix_colon: Any = None, +) -> Any: ... +def add_implicit_resolver( + tag: Any, regexp: Any, first: Any = None, Loader: Any = None, Dumper: Any = None, resolver: Any = ... +) -> None: ... +def add_path_resolver( + tag: Any, path: Any, kind: Any = None, Loader: Any = None, Dumper: Any = None, resolver: Any = ... +) -> None: ... +def add_constructor(tag: Any, object_constructor: Any, Loader: Any = None, constructor: Any = ...) -> None: ... +def add_multi_constructor(tag_prefix: Any, multi_constructor: Any, Loader: Any = None, constructor: Any = ...) -> None: ... +def add_representer(data_type: Any, object_representer: Any, Dumper: Any = None, representer: Any = ...) -> None: ... +def add_multi_representer(data_type: Any, multi_representer: Any, Dumper: Any = None, representer: Any = ...) -> None: ... + +class YAMLObjectMetaclass(type): + def __init__(cls, name: Any, bases: Any, kwds: Any) -> None: ... + +class YAMLObject(Incomplete): + yaml_constructor = Constructor + yaml_representer = Representer + yaml_tag: Any + yaml_flow_style: Any + @classmethod + def from_yaml(cls, constructor: Any, node: Any) -> Any: ... + @classmethod + def to_yaml(cls, representer: Any, data: Any) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi new file mode 100644 index 000000000000..425c60acebdb --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi @@ -0,0 +1,61 @@ +from _typeshed import Incomplete +from typing import Any + +class Node: + ctag: Incomplete + value: Incomplete + start_mark: Incomplete + end_mark: Incomplete + comment: Incomplete + anchor: Incomplete + def __init__(self, tag: Any, value: Any, start_mark: Any, end_mark: Any, comment: Any = None, anchor: Any = None) -> None: ... + @property + def tag(self) -> str | None: ... + @tag.setter + def tag(self, val: Any) -> None: ... + def dump(self, indent: int = 0) -> None: ... + +class ScalarNode(Node): + id: str + style: Incomplete + def __init__( + self, + tag: Any, + value: Any, + start_mark: Any = None, + end_mark: Any = None, + style: Any = None, + comment: Any = None, + anchor: Any = None, + ) -> None: ... + +class CollectionNode(Node): + flow_style: Incomplete + anchor: Incomplete + def __init__( + self, + tag: Any, + value: Any, + start_mark: Any = None, + end_mark: Any = None, + flow_style: Any = None, + comment: Any = None, + anchor: Any = None, + ) -> None: ... + +class SequenceNode(CollectionNode): + id: str + +class MappingNode(CollectionNode): + id: str + merge: Incomplete + def __init__( + self, + tag: Any, + value: Any, + start_mark: Any = None, + end_mark: Any = None, + flow_style: Any = None, + comment: Any = None, + anchor: Any = None, + ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/parser.pyi b/stubs/ruamel.yaml/ruamel/yaml/parser.pyi new file mode 100644 index 000000000000..79ff2dd0b1de --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/parser.pyi @@ -0,0 +1,67 @@ +from _typeshed import Incomplete +from typing import Any + +from ruamel.yaml.error import MarkedYAMLError +from ruamel.yaml.events import * +from ruamel.yaml.tag import Tag +from ruamel.yaml.tokens import * + +__all__ = ["Parser", "RoundTripParser", "ParserError"] + +class ParserError(MarkedYAMLError): ... + +class Parser: + DEFAULT_TAGS: Incomplete + loader: Incomplete + def __init__(self, loader: Any) -> None: ... + current_event: Incomplete + tag_handles: Incomplete + states: Incomplete + marks: Incomplete + state: Incomplete + def reset_parser(self) -> None: ... + def dispose(self) -> None: ... + @property + def scanner(self) -> Any: ... + @property + def resolver(self) -> Any: ... + def check_event(self, *choices: Any) -> bool: ... + def peek_event(self) -> Any: ... + last_event: Incomplete + def get_event(self) -> Any: ... + def parse_stream_start(self) -> Any: ... + def parse_implicit_document_start(self) -> Any: ... + def parse_document_start(self) -> Any: ... + def parse_document_end(self) -> Any: ... + def parse_document_content(self) -> Any: ... + def process_directives(self) -> Any: ... + def parse_block_node(self) -> Any: ... + def parse_flow_node(self) -> Any: ... + def parse_block_node_or_indentless_sequence(self) -> Any: ... + def select_tag_transform(self, tag: Tag) -> None: ... + def parse_node(self, block: bool = False, indentless_sequence: bool = False) -> Any: ... + def parse_block_sequence_first_entry(self) -> Any: ... + def parse_block_sequence_entry(self) -> Any: ... + def parse_indentless_sequence_entry(self) -> Any: ... + def parse_block_mapping_first_key(self) -> Any: ... + def parse_block_mapping_key(self) -> Any: ... + def parse_block_mapping_value(self) -> Any: ... + def parse_flow_sequence_first_entry(self) -> Any: ... + def parse_flow_sequence_entry(self, first: bool = False) -> Any: ... + def parse_flow_sequence_entry_mapping_key(self) -> Any: ... + def parse_flow_sequence_entry_mapping_value(self) -> Any: ... + def parse_flow_sequence_entry_mapping_end(self) -> Any: ... + def parse_flow_mapping_first_key(self) -> Any: ... + def parse_flow_mapping_key(self, first: Any = False) -> Any: ... + def parse_flow_mapping_value(self) -> Any: ... + def parse_flow_mapping_empty_value(self) -> Any: ... + def process_empty_scalar(self, mark: Any, comment: Any = None) -> Any: ... + def move_token_comment(self, token: Any, nt: Any | None = None, empty: bool | None = False) -> Any: ... + +class RoundTripParser(Parser): + def select_tag_transform(self, tag: Tag) -> None: ... + def move_token_comment(self, token: Any, nt: Any | None = None, empty: bool | None = False) -> Any: ... + +class RoundTripParserSC(RoundTripParser): + def move_token_comment(self, token: Any, nt: Any = None, empty: bool | None = False) -> None: ... + def distribute_comment(self, comment: Any, line: Any) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/reader.pyi b/stubs/ruamel.yaml/ruamel/yaml/reader.pyi new file mode 100644 index 000000000000..e0bbe7f5bba4 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/reader.pyi @@ -0,0 +1,44 @@ +from _typeshed import Incomplete +from typing import Any + +from ruamel.yaml.error import YAMLError + +__all__ = ["Reader", "ReaderError"] + +class ReaderError(YAMLError): + name: Incomplete + character: Incomplete + position: Incomplete + encoding: Incomplete + reason: Incomplete + def __init__(self, name: Any, position: Any, character: Any, encoding: Any, reason: Any) -> None: ... + +class Reader: + loader: Incomplete + def __init__(self, stream: Any, loader: Any = None) -> None: ... + name: Incomplete + stream_pointer: int + eof: bool + buffer: str + pointer: int + raw_buffer: Incomplete + raw_decode: Incomplete + encoding: Incomplete + index: int + line: int + column: int + def reset_reader(self) -> None: ... + @property + def stream(self) -> Any: ... + @stream.setter + def stream(self, val: Any) -> None: ... + def peek(self, index: int = 0) -> str: ... + def prefix(self, length: int = 1) -> Any: ... + def forward_1_1(self, length: int = 1) -> None: ... + def forward(self, length: int = 1) -> None: ... + def get_mark(self) -> Any: ... + def determine_encoding(self) -> None: ... + NON_PRINTABLE: Incomplete + def check_printable(self, data: Any) -> None: ... + def update(self, length: int) -> None: ... + def update_raw(self, size: int | None = None) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi new file mode 100644 index 000000000000..802c57ccaaf1 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi @@ -0,0 +1,91 @@ +from _typeshed import Incomplete +from typing import Any + +from ruamel.yaml.error import * +from ruamel.yaml.nodes import * + +__all__ = ["BaseRepresenter", "SafeRepresenter", "Representer", "RepresenterError", "RoundTripRepresenter"] + +class RepresenterError(YAMLError): ... + +class BaseRepresenter: + yaml_representers: dict[Any, Any] + yaml_multi_representers: dict[Any, Any] + dumper: Incomplete + default_style: Incomplete + default_flow_style: Incomplete + represented_objects: Incomplete + object_keeper: Incomplete + alias_key: Incomplete + sort_base_mapping_type_on_output: bool + def __init__(self, default_style: Any = None, default_flow_style: Any = None, dumper: Any = None) -> None: ... + @property + def serializer(self) -> Any: ... + def represent(self, data: Any) -> None: ... + def represent_data(self, data: Any) -> Any: ... + def represent_key(self, data: Any) -> Any: ... + @classmethod + def add_representer(cls, data_type: Any, representer: Any) -> None: ... + @classmethod + def add_multi_representer(cls, data_type: Any, representer: Any) -> None: ... + def represent_scalar(self, tag: Any, value: Any, style: Any = None, anchor: Any = None) -> ScalarNode: ... + def represent_sequence(self, tag: Any, sequence: Any, flow_style: Any = None) -> SequenceNode: ... + def represent_omap(self, tag: Any, omap: Any, flow_style: Any = None) -> SequenceNode: ... + def represent_mapping(self, tag: Any, mapping: Any, flow_style: Any = None) -> MappingNode: ... + def ignore_aliases(self, data: Any) -> bool: ... + +class SafeRepresenter(BaseRepresenter): + def ignore_aliases(self, data: Any) -> bool: ... + def represent_none(self, data: Any) -> ScalarNode: ... + def represent_str(self, data: Any) -> Any: ... + def represent_binary(self, data: Any) -> ScalarNode: ... + def represent_bool(self, data: Any, anchor: Any | None = None) -> ScalarNode: ... + def represent_int(self, data: Any) -> ScalarNode: ... + inf_value: float + def represent_float(self, data: Any) -> ScalarNode: ... + def represent_list(self, data: Any) -> SequenceNode: ... + def represent_dict(self, data: Any) -> MappingNode: ... + def represent_ordereddict(self, data: Any) -> SequenceNode: ... + def represent_set(self, data: Any) -> MappingNode: ... + def represent_date(self, data: Any) -> ScalarNode: ... + def represent_datetime(self, data: Any) -> ScalarNode: ... + def represent_yaml_object(self, tag: Any, data: Any, cls: Any, flow_style: Any = None) -> MappingNode: ... + def represent_undefined(self, data: Any) -> None: ... + +class Representer(SafeRepresenter): + def represent_complex(self, data: Any) -> Any: ... + def represent_tuple(self, data: Any) -> SequenceNode: ... + def represent_name(self, data: Any) -> ScalarNode: ... + def represent_module(self, data: Any) -> ScalarNode: ... + def represent_object(self, data: Any) -> SequenceNode | MappingNode: ... + +class RoundTripRepresenter(SafeRepresenter): + def __init__(self, default_style: Any = None, default_flow_style: Any = None, dumper: Any = None) -> None: ... + def ignore_aliases(self, data: Any) -> bool: ... + def represent_none(self, data: Any) -> ScalarNode: ... + def represent_literal_scalarstring(self, data: Any) -> ScalarNode: ... + represent_preserved_scalarstring = represent_literal_scalarstring + def represent_folded_scalarstring(self, data: Any) -> ScalarNode: ... + def represent_single_quoted_scalarstring(self, data: Any) -> ScalarNode: ... + def represent_double_quoted_scalarstring(self, data: Any) -> ScalarNode: ... + def represent_plain_scalarstring(self, data: Any) -> ScalarNode: ... + def insert_underscore(self, prefix: Any, s: Any, underscore: Any, anchor: Any = None) -> ScalarNode: ... + def represent_scalar_int(self, data: Any) -> ScalarNode: ... + def represent_binary_int(self, data: Any) -> ScalarNode: ... + def represent_octal_int(self, data: Any) -> ScalarNode: ... + def represent_hex_int(self, data: Any) -> ScalarNode: ... + def represent_hex_caps_int(self, data: Any) -> ScalarNode: ... + def represent_scalar_float(self, data: Any) -> ScalarNode: ... + def represent_sequence(self, tag: Any, sequence: Any, flow_style: Any = None) -> SequenceNode: ... + def merge_comments(self, node: Any, comments: Any) -> Any: ... + alias_key: Incomplete + def represent_key(self, data: Any) -> Any: ... + def represent_mapping(self, tag: Any, mapping: Any, flow_style: Any = None) -> MappingNode: ... + def represent_omap(self, tag: Any, omap: Any, flow_style: Any = None) -> SequenceNode: ... + def represent_set(self, setting: Any) -> MappingNode: ... + def represent_dict(self, data: Any) -> MappingNode: ... + def represent_list(self, data: Any) -> SequenceNode: ... + def represent_datetime(self, data: Any) -> ScalarNode: ... + def represent_tagged_scalar(self, data: Any) -> ScalarNode: ... + def represent_scalar_bool(self, data: Any) -> ScalarNode: ... + def represent_yaml_object(self, tag: Any, data: Any, cls: Any, flow_style: Any | None = None) -> MappingNode: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi new file mode 100644 index 000000000000..ea35ef3472dc --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi @@ -0,0 +1,46 @@ +from _typeshed import Incomplete +from typing import Any + +from ruamel.yaml.compat import VersionType +from ruamel.yaml.error import * + +__all__ = ["BaseResolver", "Resolver", "VersionedResolver"] + +class ResolverError(YAMLError): ... + +class BaseResolver: + DEFAULT_SCALAR_TAG: Incomplete + DEFAULT_SEQUENCE_TAG: Incomplete + DEFAULT_MAPPING_TAG: Incomplete + yaml_implicit_resolvers: dict[Any, Any] + yaml_path_resolvers: dict[Any, Any] + loadumper: Incomplete + resolver_exact_paths: Incomplete + resolver_prefix_paths: Incomplete + def __init__(self, loadumper: Any = None) -> None: ... + @property + def parser(self) -> Any: ... + @classmethod + def add_implicit_resolver_base(cls, tag: Any, regexp: Any, first: Any) -> None: ... + @classmethod + def add_implicit_resolver(cls, tag: Any, regexp: Any, first: Any) -> None: ... + @classmethod + def add_path_resolver(cls, tag: Any, path: Any, kind: Any = None) -> None: ... + def descend_resolver(self, current_node: Any, current_index: Any) -> None: ... + def ascend_resolver(self) -> None: ... + def check_resolver_prefix(self, depth: int, path: Any, kind: Any, current_node: Any, current_index: Any) -> bool: ... + def resolve(self, kind: Any, value: Any, implicit: Any) -> Any: ... + @property + def processing_version(self) -> Any: ... + +class Resolver(BaseResolver): ... + +class VersionedResolver(BaseResolver): + def __init__(self, version: VersionType | None = None, loader: Any = None, loadumper: Any = None) -> None: ... + def add_version_implicit_resolver(self, version: VersionType, tag: Any, regexp: Any, first: Any) -> None: ... + def get_loader_version(self, version: VersionType | None) -> Any: ... + @property + def versioned_resolver(self) -> Any: ... + def resolve(self, kind: Any, value: Any, implicit: Any) -> Any: ... + @property + def processing_version(self) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi new file mode 100644 index 000000000000..b16a4cb1e41d --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi @@ -0,0 +1,10 @@ +from typing import Any + +__all__ = ["ScalarBoolean"] + +class ScalarBoolean(int): + def __new__(cls, *args: Any, **kw: Any) -> Any: ... + @property + def anchor(self) -> Any: ... + def yaml_anchor(self, any: bool = False) -> Any: ... + def yaml_set_anchor(self, value: Any, always_dump: bool = False) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi new file mode 100644 index 000000000000..a5f40cba62b6 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi @@ -0,0 +1,22 @@ +from typing import Any + +__all__ = ["ScalarFloat", "ExponentialFloat", "ExponentialCapsFloat"] + +class ScalarFloat(float): + def __new__(cls, *args: Any, **kw: Any) -> Any: ... + def __iadd__(self, a: Any) -> Any: ... + def __ifloordiv__(self, a: Any) -> Any: ... + def __imul__(self, a: Any) -> Any: ... + def __ipow__(self, a: Any) -> Any: ... + def __isub__(self, a: Any) -> Any: ... + @property + def anchor(self) -> Any: ... + def yaml_anchor(self, any: bool = False) -> Any: ... + def yaml_set_anchor(self, value: Any, always_dump: bool = False) -> None: ... + def dump(self, out: Any = ...) -> None: ... + +class ExponentialFloat(ScalarFloat): + def __new__(cls, value: Any, width: Any = None, underscore: Any = None) -> Any: ... + +class ExponentialCapsFloat(ScalarFloat): + def __new__(cls, value: Any, width: Any = None, underscore: Any = None) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi new file mode 100644 index 000000000000..9ae877b7040d --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi @@ -0,0 +1,30 @@ +from typing import Any + +__all__ = ["ScalarInt", "BinaryInt", "OctalInt", "HexInt", "HexCapsInt", "DecimalInt"] + +class ScalarInt(int): + def __new__(cls, *args: Any, **kw: Any) -> Any: ... + def __iadd__(self, a: Any) -> Any: ... + def __ifloordiv__(self, a: Any) -> Any: ... + def __imul__(self, a: Any) -> Any: ... + def __ipow__(self, a: Any) -> Any: ... + def __isub__(self, a: Any) -> Any: ... + @property + def anchor(self) -> Any: ... + def yaml_anchor(self, any: bool = False) -> Any: ... + def yaml_set_anchor(self, value: Any, always_dump: bool = False) -> None: ... + +class BinaryInt(ScalarInt): + def __new__(cls, value: Any, width: Any = None, underscore: Any = None, anchor: Any = None) -> Any: ... + +class OctalInt(ScalarInt): + def __new__(cls, value: Any, width: Any = None, underscore: Any = None, anchor: Any = None) -> Any: ... + +class HexInt(ScalarInt): + def __new__(cls, value: Any, width: Any = None, underscore: Any = None, anchor: Any = None) -> Any: ... + +class HexCapsInt(ScalarInt): + def __new__(cls, value: Any, width: Any = None, underscore: Any = None, anchor: Any = None) -> Any: ... + +class DecimalInt(ScalarInt): + def __new__(cls, value: Any, width: Any = None, underscore: Any = None, anchor: Any = None) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi new file mode 100644 index 000000000000..4513ecda53ae --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi @@ -0,0 +1,43 @@ +from typing import Any + +from ruamel.yaml.compat import SupportsIndex + +__all__ = [ + "ScalarString", + "LiteralScalarString", + "FoldedScalarString", + "SingleQuotedScalarString", + "DoubleQuotedScalarString", + "PlainScalarString", + "PreservedScalarString", +] + +class ScalarString(str): + def __new__(cls, *args: Any, **kw: Any) -> Any: ... + def replace(self, old: Any, new: Any, maxreplace: SupportsIndex = -1) -> Any: ... + @property + def anchor(self) -> Any: ... + def yaml_anchor(self, any: bool = False) -> Any: ... + def yaml_set_anchor(self, value: Any, always_dump: bool = False) -> None: ... + +class LiteralScalarString(ScalarString): + style: str + def __new__(cls, value: str, anchor: Any = None) -> Any: ... + +PreservedScalarString = LiteralScalarString + +class FoldedScalarString(ScalarString): + style: str + def __new__(cls, value: str, anchor: Any = None) -> Any: ... + +class SingleQuotedScalarString(ScalarString): + style: str + def __new__(cls, value: str, anchor: Any = None) -> Any: ... + +class DoubleQuotedScalarString(ScalarString): + style: str + def __new__(cls, value: str, anchor: Any = None) -> Any: ... + +class PlainScalarString(ScalarString): + style: str + def __new__(cls, value: str, anchor: Any = None) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi new file mode 100644 index 000000000000..b1448594a7c6 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi @@ -0,0 +1,176 @@ +from _typeshed import Incomplete +from typing import Any + +from ruamel.yaml.error import MarkedYAMLError +from ruamel.yaml.tokens import * + +__all__ = ["Scanner", "RoundTripScanner", "ScannerError"] + +class ScannerError(MarkedYAMLError): ... + +class SimpleKey: + token_number: Incomplete + required: Incomplete + index: Incomplete + line: Incomplete + column: Incomplete + mark: Incomplete + def __init__(self, token_number: Any, required: Any, index: int, line: int, column: int, mark: Any) -> None: ... + +class Scanner: + loader: Incomplete + first_time: bool + def __init__(self, loader: Any = None) -> None: ... + @property + def flow_level(self) -> int: ... + done: bool + flow_context: Incomplete + tokens: Incomplete + tokens_taken: int + indent: int + indents: Incomplete + allow_simple_key: bool + possible_simple_keys: Incomplete + yaml_version: Incomplete + tag_directives: Incomplete + def reset_scanner(self) -> None: ... + @property + def reader(self) -> Any: ... + @property + def scanner_processing_version(self) -> Any: ... + def check_token(self, *choices: Any) -> bool: ... + def peek_token(self) -> Any: ... + def get_token(self) -> Any: ... + def need_more_tokens(self) -> bool: ... + def fetch_comment(self, comment: Any) -> None: ... + def fetch_more_tokens(self) -> Any: ... + def next_possible_simple_key(self) -> Any: ... + def stale_possible_simple_keys(self) -> None: ... + def save_possible_simple_key(self) -> None: ... + def remove_possible_simple_key(self) -> None: ... + def unwind_indent(self, column: Any) -> None: ... + def add_indent(self, column: int) -> bool: ... + def fetch_stream_start(self) -> None: ... + def fetch_stream_end(self) -> None: ... + def fetch_directive(self) -> None: ... + def fetch_document_start(self) -> None: ... + def fetch_document_end(self) -> None: ... + def fetch_document_indicator(self, TokenClass: Any) -> None: ... + def fetch_flow_sequence_start(self) -> None: ... + def fetch_flow_mapping_start(self) -> None: ... + def fetch_flow_collection_start(self, TokenClass: Any, to_push: str) -> None: ... + def fetch_flow_sequence_end(self) -> None: ... + def fetch_flow_mapping_end(self) -> None: ... + def fetch_flow_collection_end(self, TokenClass: Any) -> None: ... + def fetch_flow_entry(self) -> None: ... + def fetch_block_entry(self) -> None: ... + def fetch_key(self) -> None: ... + def fetch_value(self) -> None: ... + def fetch_alias(self) -> None: ... + def fetch_anchor(self) -> None: ... + def fetch_tag(self) -> None: ... + def fetch_literal(self) -> None: ... + def fetch_folded(self) -> None: ... + def fetch_block_scalar(self, style: Any) -> None: ... + def fetch_single(self) -> None: ... + def fetch_double(self) -> None: ... + def fetch_flow_scalar(self, style: Any) -> None: ... + def fetch_plain(self) -> None: ... + def check_directive(self) -> Any: ... + def check_document_start(self) -> Any: ... + def check_document_end(self) -> Any: ... + def check_block_entry(self) -> Any: ... + def check_key(self) -> Any: ... + def check_value(self) -> Any: ... + def check_plain(self) -> Any: ... + def scan_to_next_token(self) -> Any: ... + def scan_directive(self) -> Any: ... + def scan_directive_name(self, start_mark: Any) -> Any: ... + def scan_yaml_directive_value(self, start_mark: Any) -> Any: ... + def scan_yaml_directive_number(self, start_mark: Any) -> Any: ... + def scan_tag_directive_value(self, start_mark: Any) -> Any: ... + def scan_tag_directive_handle(self, start_mark: Any) -> Any: ... + def scan_tag_directive_prefix(self, start_mark: Any) -> Any: ... + def scan_directive_ignored_line(self, start_mark: Any) -> None: ... + def scan_anchor(self, TokenClass: Any) -> Any: ... + def scan_tag(self) -> Any: ... + def scan_block_scalar(self, style: Any, rt: bool | None = False) -> Any: ... + def scan_block_scalar_indicators(self, start_mark: Any) -> Any: ... + def scan_block_scalar_ignored_line(self, start_mark: Any) -> Any: ... + def scan_block_scalar_indentation(self) -> Any: ... + def scan_block_scalar_breaks(self, indent: int) -> Any: ... + def scan_flow_scalar(self, style: Any) -> Any: ... + ESCAPE_REPLACEMENTS: Incomplete + ESCAPE_CODES: Incomplete + def scan_flow_scalar_non_spaces(self, double: Any, start_mark: Any) -> Any: ... + def scan_flow_scalar_spaces(self, double: Any, start_mark: Any) -> Any: ... + def scan_flow_scalar_breaks(self, double: Any, start_mark: Any) -> Any: ... + def scan_plain(self) -> Any: ... + def scan_plain_spaces(self, indent: Any, start_mark: Any) -> Any: ... + def scan_tag_handle(self, name: Any, start_mark: Any) -> Any: ... + def scan_tag_uri(self, name: Any, start_mark: Any) -> Any: ... + def scan_uri_escapes(self, name: Any, start_mark: Any) -> Any: ... + def scan_line_break(self) -> Any: ... + +class RoundTripScanner(Scanner): + def check_token(self, *choices: Any) -> bool: ... + def peek_token(self) -> Any: ... + def get_token(self) -> Any: ... + def fetch_comment(self, comment: Any) -> None: ... + allow_simple_key: bool + def scan_to_next_token(self) -> Any: ... + def scan_line_break(self, empty_line: bool = False) -> str: ... + def scan_block_scalar(self, style: Any, rt: bool | None = True) -> Any: ... + def scan_uri_escapes(self, name: Any, start_mark: Any) -> Any: ... + +class CommentBase: + value: Incomplete + line: Incomplete + column: Incomplete + used: str + function: Incomplete + fline: Incomplete + ufun: Incomplete + uline: Incomplete + def __init__(self, value: Any, line: Any, column: Any) -> None: ... + def set_used(self, v: Any = "+") -> None: ... + def set_assigned(self) -> None: ... + def info(self) -> str: ... + +class EOLComment(CommentBase): + name: str + def __init__(self, value: Any, line: Any, column: Any) -> None: ... + +class FullLineComment(CommentBase): + name: str + def __init__(self, value: Any, line: Any, column: Any) -> None: ... + +class BlankLineComment(CommentBase): + name: str + def __init__(self, value: Any, line: Any, column: Any) -> None: ... + +class ScannedComments: + comments: Incomplete + unused: Incomplete + def __init__(self) -> None: ... + def add_eol_comment(self, comment: Any, column: Any, line: Any) -> Any: ... + def add_blank_line(self, comment: Any, column: Any, line: Any) -> Any: ... + def add_full_line_comment(self, comment: Any, column: Any, line: Any) -> Any: ... + def __getitem__(self, idx: Any) -> Any: ... + def last(self) -> str: ... + def any_unprocessed(self) -> bool: ... + def unprocessed(self, use: Any = False) -> Any: ... + def assign_pre(self, token: Any) -> Any: ... + def assign_eol(self, tokens: Any) -> Any: ... + def assign_post(self, token: Any) -> Any: ... + def str_unprocessed(self) -> Any: ... + +class RoundTripScannerSC(Scanner): + comments: Incomplete + def __init__(self, *arg: Any, **kw: Any) -> None: ... + def get_token(self) -> Any: ... + def need_more_tokens(self) -> bool: ... + allow_simple_key: bool + def scan_to_next_token(self) -> None: ... + def scan_empty_or_full_line_comments(self) -> None: ... + def scan_block_scalar_ignored_line(self, start_mark: Any) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi b/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi new file mode 100644 index 000000000000..7345d8131f2a --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi @@ -0,0 +1,42 @@ +from _typeshed import Incomplete +from typing import Any + +from ruamel.yaml.compat import VersionType +from ruamel.yaml.error import YAMLError + +__all__ = ["Serializer", "SerializerError"] + +class SerializerError(YAMLError): ... + +class Serializer: + ANCHOR_TEMPLATE: str + ANCHOR_RE: Incomplete + dumper: Incomplete + use_encoding: Incomplete + use_explicit_start: Incomplete + use_explicit_end: Incomplete + use_version: Incomplete + use_tags: Incomplete + serialized_nodes: Incomplete + anchors: Incomplete + last_anchor_id: int + closed: Incomplete + def __init__( + self, + encoding: Any = None, + explicit_start: bool | None = None, + explicit_end: bool | None = None, + version: VersionType | None = None, + tags: Any = None, + dumper: Any = None, + ) -> None: ... + @property + def emitter(self) -> Any: ... + @property + def resolver(self) -> Any: ... + def open(self) -> None: ... + def close(self) -> None: ... + def serialize(self, node: Any) -> None: ... + def anchor_node(self, node: Any) -> None: ... + def generate_anchor(self, node: Any) -> Any: ... + def serialize_node(self, node: Any, parent: Any, index: Any) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/tag.pyi b/stubs/ruamel.yaml/ruamel/yaml/tag.pyi new file mode 100644 index 000000000000..9218d896141c --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/tag.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete +from typing import Any + +tag_attrib: str + +class Tag: + attrib = tag_attrib + handle: Incomplete + suffix: Incomplete + handles: Incomplete + def __init__(self, handle: Any = None, suffix: Any = None, handles: Any = None) -> None: ... + def __hash__(self) -> int: ... + def __eq__(self, other: object) -> bool: ... + def startswith(self, x: str) -> bool: ... + @property + def trval(self) -> str | None: ... + value = trval + @property + def uri_decoded_suffix(self) -> str | None: ... + def select_transform(self, val: bool) -> None: ... + def check_handle(self) -> bool: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi b/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi new file mode 100644 index 000000000000..df55f2df380a --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi @@ -0,0 +1,19 @@ +import datetime +from typing import Any + +class TimeStamp(datetime.datetime): + def __init__(self, *args: Any, **kw: Any) -> None: ... + def __new__(cls, *args: Any, **kw: Any) -> Any: ... + def __deepcopy__(self, memo: Any) -> Any: ... + def replace( + self, + year: Any = None, + month: Any = None, + day: Any = None, + hour: Any = None, + minute: Any = None, + second: Any = None, + microsecond: Any = None, + tzinfo: Any = True, + fold: Any = None, + ) -> Any: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi new file mode 100644 index 000000000000..17b17b39f0ed --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi @@ -0,0 +1,113 @@ +from _typeshed import Incomplete +from typing import Any + +from ruamel.yaml.compat import nprintf as nprintf + +from .error import StreamMark + +SHOW_LINES: bool + +class Token: + start_mark: Incomplete + end_mark: Incomplete + def __init__(self, start_mark: StreamMark, end_mark: StreamMark) -> None: ... + @property + def column(self) -> int: ... + @column.setter + def column(self, pos: Any) -> None: ... + def add_post_comment(self, comment: Any) -> None: ... + def add_pre_comments(self, comments: Any) -> None: ... + def add_comment_pre(self, comment: Any) -> None: ... + def add_comment_eol(self, comment: Any, comment_type: Any) -> None: ... + def add_comment_post(self, comment: Any) -> None: ... + @property + def comment(self) -> Any: ... + def move_old_comment(self, target: Any, empty: bool = False) -> Any: ... + def split_old_comment(self) -> Any: ... + def move_new_comment(self, target: Any, empty: bool = False) -> Any: ... + +class DirectiveToken(Token): + id: str + name: Incomplete + value: Incomplete + def __init__(self, name: Any, value: Any, start_mark: Any, end_mark: Any) -> None: ... + +class DocumentStartToken(Token): + id: str + +class DocumentEndToken(Token): + id: str + +class StreamStartToken(Token): + id: str + encoding: Incomplete + def __init__(self, start_mark: Any = None, end_mark: Any = None, encoding: Any = None) -> None: ... + +class StreamEndToken(Token): + id: str + +class BlockSequenceStartToken(Token): + id: str + +class BlockMappingStartToken(Token): + id: str + +class BlockEndToken(Token): + id: str + +class FlowSequenceStartToken(Token): + id: str + +class FlowMappingStartToken(Token): + id: str + +class FlowSequenceEndToken(Token): + id: str + +class FlowMappingEndToken(Token): + id: str + +class KeyToken(Token): + id: str + +class ValueToken(Token): + id: str + +class BlockEntryToken(Token): + id: str + +class FlowEntryToken(Token): + id: str + +class AliasToken(Token): + id: str + value: Incomplete + def __init__(self, value: Any, start_mark: Any, end_mark: Any) -> None: ... + +class AnchorToken(Token): + id: str + value: Incomplete + def __init__(self, value: Any, start_mark: Any, end_mark: Any) -> None: ... + +class TagToken(Token): + id: str + value: Incomplete + def __init__(self, value: Any, start_mark: Any, end_mark: Any) -> None: ... + +class ScalarToken(Token): + id: str + value: Incomplete + plain: Incomplete + style: Incomplete + def __init__(self, value: Any, plain: Any, start_mark: Any, end_mark: Any, style: Any = None) -> None: ... + +class CommentToken(Token): + id: str + def __init__(self, value: Any, start_mark: Any = None, end_mark: Any = None, column: Any = None) -> None: ... + @property + def value(self) -> str: ... + @value.setter + def value(self, val: Any) -> None: ... + def reset(self) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/util.pyi b/stubs/ruamel.yaml/ruamel/yaml/util.pyi new file mode 100644 index 000000000000..b3a0d2c483b6 --- /dev/null +++ b/stubs/ruamel.yaml/ruamel/yaml/util.pyi @@ -0,0 +1,30 @@ +import datetime +from _typeshed import Incomplete +from typing import Any, Callable + +from .compat import StreamTextType as StreamTextType + +class LazyEval: + def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... + def __getattribute__(self, name: str) -> Any: ... + def __setattr__(self, name: str, value: Any) -> None: ... + +RegExp: Incomplete +timestamp_regexp: Incomplete + +def create_timestamp( + year: Any, + month: Any, + day: Any, + t: Any, + hour: Any, + minute: Any, + second: Any, + fraction: Any, + tz: Any, + tz_sign: Any, + tz_hour: Any, + tz_minute: Any, +) -> datetime.datetime | datetime.date: ... +def load_yaml_guess_indent(stream: StreamTextType, **kw: Any) -> Any: ... +def configobj_walker(cfg: Any) -> Any: ... From 4933e44c97e0208c95f625d306367d21fa5e41fc Mon Sep 17 00:00:00 2001 From: stevenlele Date: Wed, 21 Aug 2024 22:15:24 +0000 Subject: [PATCH 02/15] Regenerate with Any removed --- stubs/ruamel.yaml/ruamel/yaml/comments.pyi | 169 ++++++------- stubs/ruamel.yaml/ruamel/yaml/compat.pyi | 32 +-- stubs/ruamel.yaml/ruamel/yaml/composer.pyi | 27 +-- .../ruamel/yaml/configobjwalker.pyi | 4 +- stubs/ruamel.yaml/ruamel/yaml/constructor.pyi | 157 ++++++------ stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi | 62 ++--- stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/dumper.pyi | 72 +++--- stubs/ruamel.yaml/ruamel/yaml/emitter.pyi | 79 +++--- stubs/ruamel.yaml/ruamel/yaml/error.pyi | 51 ++-- stubs/ruamel.yaml/ruamel/yaml/events.pyi | 74 +++--- stubs/ruamel.yaml/ruamel/yaml/main.pyi | 228 +++++++++--------- stubs/ruamel.yaml/ruamel/yaml/nodes.pyi | 49 ++-- stubs/ruamel.yaml/ruamel/yaml/parser.pyi | 73 +++--- stubs/ruamel.yaml/ruamel/yaml/reader.pyi | 15 +- stubs/ruamel.yaml/ruamel/yaml/representer.pyi | 133 +++++----- stubs/ruamel.yaml/ruamel/yaml/resolver.pyi | 37 +-- stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi | 10 +- stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi | 26 +- stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi | 40 +-- .../ruamel.yaml/ruamel/yaml/scalarstring.pyi | 22 +- stubs/ruamel.yaml/ruamel/yaml/scanner.pyi | 148 ++++++------ stubs/ruamel.yaml/ruamel/yaml/serializer.pyi | 19 +- stubs/ruamel.yaml/ruamel/yaml/tag.pyi | 7 +- stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi | 28 +-- stubs/ruamel.yaml/ruamel/yaml/tokens.pyi | 45 ++-- stubs/ruamel.yaml/ruamel/yaml/util.pyi | 24 +- 27 files changed, 838 insertions(+), 795 deletions(-) diff --git a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi index 61e32e060f9a..d55f208b1f50 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Mapping, MutableSet, Set as AbstractSet, Sized +from collections.abc import Generator, Mapping, MutableSet, Set as AbstractSet, Sized from typing import Any, Iterator from ruamel.yaml.compat import MutableSliceableSequence, ordereddict @@ -27,7 +27,7 @@ C_BLANK_LINE_PRESERVE_SPACE: int class IDX: def __init__(self) -> None: ... - def __call__(self) -> Any: ... + def __call__(self): ... comment_attrib: str merge_attrib: str @@ -37,18 +37,18 @@ class Comment: comment: Incomplete def __init__(self, old: bool = True) -> None: ... @property - def items(self) -> Any: ... + def items(self): ... @property - def end(self) -> Any: ... + def end(self): ... @end.setter - def end(self, value: Any) -> None: ... + def end(self, value) -> None: ... @property - def pre(self) -> Any: ... + def pre(self): ... @pre.setter - def pre(self, value: Any) -> None: ... - def get(self, item: Any, pos: Any) -> Any: ... - def set(self, item: Any, pos: Any, value: Any) -> Any: ... - def __contains__(self, x: Any) -> Any: ... + def pre(self, value) -> None: ... + def get(self, item, pos): ... + def set(self, item, pos, value) -> None: ... + def __contains__(self, x) -> bool: ... class NotNone: ... @@ -57,7 +57,7 @@ class Format: def __init__(self) -> None: ... def set_flow_style(self) -> None: ... def set_block_style(self) -> None: ... - def flow_style(self, default: Any | None = None) -> Any: ... + def flow_style(self, default: Incomplete = None): ... class LineCol: attrib = line_col_attrib @@ -65,95 +65,100 @@ class LineCol: col: Incomplete data: Incomplete def __init__(self) -> None: ... - def add_kv_line_col(self, key: Any, data: Any) -> None: ... - def key(self, k: Any) -> Any: ... - def value(self, k: Any) -> Any: ... - def item(self, idx: Any) -> Any: ... - def add_idx_line_col(self, key: Any, data: Any) -> None: ... + def add_kv_line_col(self, key, data) -> None: ... + def key(self, k): ... + def value(self, k): ... + def item(self, idx): ... + def add_idx_line_col(self, key, data) -> None: ... class CommentedBase: @property def ca(self) -> Any: ... - def yaml_end_comment_extend(self, comment: Any, clear: bool = False) -> None: ... - def yaml_key_comment_extend(self, key: Any, comment: Any, clear: bool = False) -> None: ... - def yaml_value_comment_extend(self, key: Any, comment: Any, clear: bool = False) -> None: ... - def yaml_set_start_comment(self, comment: Any, indent: Any = 0) -> None: ... + def yaml_end_comment_extend(self, comment, clear: bool = False) -> None: ... + def yaml_key_comment_extend(self, key, comment, clear: bool = False) -> None: ... + def yaml_value_comment_extend(self, key, comment, clear: bool = False) -> None: ... + def yaml_set_start_comment(self, comment, indent: int = 0) -> None: ... def yaml_set_comment_before_after_key( - self, key: Any, before: Any = None, indent: Any = 0, after: Any = None, after_indent: Any = None + self, + key, + before: Incomplete | None = None, + indent: int = 0, + after: Incomplete | None = None, + after_indent: Incomplete | None = None, ) -> None: ... @property - def fa(self) -> Any: ... - def yaml_add_eol_comment(self, comment: Any, key: Any | None = ..., column: Any | None = None) -> None: ... + def fa(self): ... + def yaml_add_eol_comment(self, comment, key: Incomplete = ..., column: Incomplete = None) -> None: ... @property - def lc(self) -> Any: ... + def lc(self): ... @property - def anchor(self) -> Any: ... - def yaml_anchor(self) -> Any: ... - def yaml_set_anchor(self, value: Any, always_dump: bool = False) -> None: ... + def anchor(self): ... + def yaml_anchor(self): ... + def yaml_set_anchor(self, value, always_dump: bool = False) -> None: ... @property - def tag(self) -> Any: ... + def tag(self): ... def yaml_set_ctag(self, value: Tag) -> None: ... - def copy_attributes(self, t: Any, memo: Any = None) -> Any: ... + def copy_attributes(self, t, memo: Incomplete | None = None): ... class CommentedSeq(MutableSliceableSequence, list, CommentedBase): - def __init__(self, *args: Any, **kw: Any) -> None: ... - def __getsingleitem__(self, idx: Any) -> Any: ... - def __setsingleitem__(self, idx: Any, value: Any) -> None: ... - def __delsingleitem__(self, idx: Any = None) -> Any: ... + def __init__(self, *args, **kw) -> None: ... + def __getsingleitem__(self, idx): ... + def __setsingleitem__(self, idx, value) -> None: ... + def __delsingleitem__(self, idx: Incomplete | None = None) -> None: ... def __len__(self) -> int: ... - def insert(self, idx: Any, val: Any) -> None: ... - def extend(self, val: Any) -> None: ... - def __eq__(self, other: object) -> bool: ... - def __deepcopy__(self, memo: Any) -> Any: ... - def __add__(self, other: Any) -> Any: ... - def sort(self, key: Any = None, reverse: bool = False) -> None: ... + def insert(self, idx, val) -> None: ... + def extend(self, val) -> None: ... + def __eq__(self, other) -> bool: ... + def __deepcopy__(self, memo): ... + def __add__(self, other): ... + def sort(self, key: Incomplete | None = None, reverse: bool = False) -> None: ... class CommentedKeySeq(tuple, CommentedBase): ... class CommentedMapView(Sized): - def __init__(self, mapping: Any) -> None: ... + def __init__(self, mapping) -> None: ... def __len__(self) -> int: ... class CommentedMapKeysView(CommentedMapView, AbstractSet): - def __contains__(self, key: Any) -> Any: ... - def __iter__(self) -> Any: ... + def __contains__(self, key) -> bool: ... + def __iter__(self): ... class CommentedMapItemsView(CommentedMapView, AbstractSet): - def __contains__(self, item: Any) -> Any: ... - def __iter__(self) -> Any: ... + def __contains__(self, item) -> bool: ... + def __iter__(self): ... class CommentedMapValuesView(CommentedMapView): - def __contains__(self, value: Any) -> Any: ... - def __iter__(self) -> Any: ... + def __contains__(self, value) -> bool: ... + def __iter__(self): ... class CommentedMap(ordereddict, CommentedBase): - def __init__(self, *args: Any, **kw: Any) -> None: ... - def update(self, *vals: Any, **kw: Any) -> None: ... - def insert(self, pos: Any, key: Any, value: Any, comment: Any | None = None) -> None: ... - def mlget(self, key: Any, default: Any = None, list_ok: Any = False) -> Any: ... - def __getitem__(self, key: Any) -> Any: ... - def __setitem__(self, key: Any, value: Any) -> None: ... - def __contains__(self, key: Any) -> bool: ... - def get(self, key: Any, default: Any = None) -> Any: ... - def non_merged_items(self) -> Any: ... - def __delitem__(self, key: Any) -> None: ... - def __iter__(self) -> Any: ... - def pop(self, key: Any, default: Any = ...) -> Any: ... + def __init__(self, *args, **kw) -> None: ... + def update(self, *vals, **kw) -> None: ... + def insert(self, pos, key, value, comment: Incomplete = None) -> None: ... + def mlget(self, key, default: Incomplete | None = None, list_ok: bool = False): ... + def __getitem__(self, key): ... + def __setitem__(self, key, value) -> None: ... + def __contains__(self, key) -> bool: ... + def get(self, key, default: Incomplete | None = None): ... + def non_merged_items(self) -> Generator[Incomplete, None, None]: ... + def __delitem__(self, key) -> None: ... + def __iter__(self): ... + def pop(self, key, default=...): ... def __len__(self) -> int: ... - def __eq__(self, other: object) -> bool: ... - def keys(self) -> Any: ... - def values(self) -> Any: ... - def items(self) -> Any: ... + def __eq__(self, other) -> bool: ... + def keys(self): ... + def values(self): ... + def items(self): ... @property - def merge(self) -> Any: ... - def copy(self) -> Any: ... - def add_referent(self, cm: Any) -> None: ... - def add_yaml_merge(self, value: Any) -> None: ... - def update_key_value(self, key: Any) -> None: ... - def __deepcopy__(self, memo: Any) -> Any: ... + def merge(self): ... + def copy(self): ... + def add_referent(self, cm) -> None: ... + def add_yaml_merge(self, value) -> None: ... + def update_key_value(self, key) -> None: ... + def __deepcopy__(self, memo): ... class CommentedKeyMap(CommentedBase, Mapping): - def __init__(self, *args: Any, **kw: Any) -> None: ... + def __init__(self, *args, **kw) -> None: ... __delitem__ = raise_immutable __setitem__ = raise_immutable clear = raise_immutable @@ -161,27 +166,29 @@ class CommentedKeyMap(CommentedBase, Mapping): popitem = raise_immutable setdefault = raise_immutable update = raise_immutable - def __getitem__(self, index: Any) -> Any: ... - def __iter__(self) -> Iterator[Any]: ... + def __getitem__(self, index): ... + def __iter__(self) -> Iterator: ... def __len__(self) -> int: ... - def __hash__(self) -> Any: ... + def __hash__(self): ... @classmethod - def fromkeys(keys: Any, v: Any = None) -> Any: ... + def fromkeys(keys, v: Incomplete | None = None): ... class CommentedOrderedMap(CommentedMap): ... class CommentedSet(MutableSet, CommentedBase): odict: Incomplete - def __init__(self, values: Any = None) -> None: ... - def add(self, value: Any) -> None: ... - def discard(self, value: Any) -> None: ... - def __contains__(self, x: Any) -> Any: ... - def __iter__(self) -> Any: ... + def __init__(self, values: Incomplete | None = None) -> None: ... + def add(self, value) -> None: ... + def discard(self, value) -> None: ... + def __contains__(self, x) -> bool: ... + def __iter__(self): ... def __len__(self) -> int: ... class TaggedScalar(CommentedBase): value: Incomplete style: Incomplete - def __init__(self, value: Any = None, style: Any = None, tag: Any = None) -> None: ... - def count(self, s: str, start: int | None = None, end: int | None = None) -> Any: ... - def __getitem__(self, pos: int) -> Any: ... + def __init__( + self, value: Incomplete | None = None, style: Incomplete | None = None, tag: Incomplete | None = None + ) -> None: ... + def count(self, s: str, start: int | None = None, end: int | None = None): ... + def __getitem__(self, pos: int): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi index e794acb7da94..b24ad8e13d82 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi @@ -14,13 +14,13 @@ StreamTextType = StreamType VersionType = str | tuple[int, int] | list[int] | Version | None class ordereddict(OrderedDict): - def insert(self, pos: int, key: Any, value: Any) -> None: ... + def insert(self, pos: int, key, value) -> None: ... StringIO = io.StringIO BytesIO = io.BytesIO builtins_module: str -def with_metaclass(meta: Any, *bases: Any) -> Any: ... +def with_metaclass(meta, *bases): ... DBG_TOKEN: int DBG_EVENT: int @@ -29,33 +29,33 @@ DBG_NODE: int class ObjectCounter: map: Incomplete def __init__(self) -> None: ... - def __call__(self, k: Any) -> None: ... + def __call__(self, k) -> None: ... def dump(self) -> None: ... object_counter: Incomplete -def dbg(val: Any = None) -> Any: ... +def dbg(val: Incomplete | None = None): ... class Nprint: - def __init__(self, file_name: Any = None) -> None: ... - def __call__(self, *args: Any, **kw: Any) -> None: ... + def __init__(self, file_name: Incomplete | None = None) -> None: ... + def __call__(self, *args, **kw) -> None: ... def set_max_print(self, i: int) -> None: ... - def fp(self, mode: str = "a") -> Any: ... + def fp(self, mode: str = "a"): ... nprint: Incomplete nprintf: Incomplete -def check_namespace_char(ch: Any) -> bool: ... -def check_anchorname_char(ch: Any) -> bool: ... -def version_tnf(t1: Any, t2: Any = None) -> Any: ... +def check_namespace_char(ch) -> bool: ... +def check_anchorname_char(ch) -> bool: ... +def version_tnf(t1, t2: Incomplete | None = None): ... class MutableSliceableSequence(collections.abc.MutableSequence, metaclass=abc.ABCMeta): - def __getitem__(self, index: Any) -> Any: ... - def __setitem__(self, index: Any, value: Any) -> None: ... - def __delitem__(self, index: Any) -> None: ... + def __getitem__(self, index): ... + def __setitem__(self, index, value) -> None: ... + def __delitem__(self, index) -> None: ... @abstractmethod - def __getsingleitem__(self, index: Any) -> Any: ... + def __getsingleitem__(self, index): ... @abstractmethod - def __setsingleitem__(self, index: Any, value: Any) -> None: ... + def __setsingleitem__(self, index, value) -> None: ... @abstractmethod - def __delsingleitem__(self, index: Any) -> None: ... + def __delsingleitem__(self, index) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi index 83cf5143ad12..2b3a0040f4ff 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any from ruamel.yaml.error import MarkedYAMLError @@ -11,18 +10,18 @@ class Composer: loader: Incomplete anchors: Incomplete warn_double_anchors: bool - def __init__(self, loader: Any = None) -> None: ... + def __init__(self, loader: Incomplete | None = None) -> None: ... @property - def parser(self) -> Any: ... + def parser(self): ... @property - def resolver(self) -> Any: ... - def check_node(self) -> Any: ... - def get_node(self) -> Any: ... - def get_single_node(self) -> Any: ... - def compose_document(self) -> Any: ... - def return_alias(self, a: Any) -> Any: ... - def compose_node(self, parent: Any, index: Any) -> Any: ... - def compose_scalar_node(self, anchor: Any) -> Any: ... - def compose_sequence_node(self, anchor: Any) -> Any: ... - def compose_mapping_node(self, anchor: Any) -> Any: ... - def check_end_doc_comment(self, end_event: Any, node: Any) -> None: ... + def resolver(self): ... + def check_node(self): ... + def get_node(self): ... + def get_single_node(self): ... + def compose_document(self): ... + def return_alias(self, a): ... + def compose_node(self, parent, index): ... + def compose_scalar_node(self, anchor): ... + def compose_sequence_node(self, anchor): ... + def compose_mapping_node(self, anchor): ... + def check_end_doc_comment(self, end_event, node) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi b/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi index 82e056e33a89..bec5b1effbae 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi @@ -1,3 +1 @@ -from typing import Any - -def configobj_walker(cfg: Any) -> Any: ... +def configobj_walker(cfg): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi index c71f11bed154..7064c2c478a8 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi @@ -1,6 +1,7 @@ import datetime from _typeshed import Incomplete -from typing import Any, Iterator +from collections.abc import Generator +from typing import Iterator from ruamel.yaml.comments import * from ruamel.yaml.comments import CommentedMap, CommentedOrderedMap, CommentedSeq, CommentedSet, TaggedScalar @@ -17,8 +18,8 @@ class DuplicateKeyFutureWarning(MarkedYAMLFutureWarning): ... class DuplicateKeyError(MarkedYAMLError): ... class BaseConstructor: - yaml_constructors: dict[Any, Any] - yaml_multi_constructors: dict[Any, Any] + yaml_constructors: dict + yaml_multi_constructors: dict loader: Incomplete yaml_base_dict_type: Incomplete yaml_base_list_type: Incomplete @@ -27,91 +28,99 @@ class BaseConstructor: state_generators: Incomplete deep_construct: bool allow_duplicate_keys: Incomplete - def __init__(self, preserve_quotes: bool | None = None, loader: Any = None) -> None: ... + def __init__(self, preserve_quotes: bool | None = None, loader: Incomplete | None = None) -> None: ... @property - def composer(self) -> Any: ... + def composer(self): ... @property - def resolver(self) -> Any: ... + def resolver(self): ... @property - def scanner(self) -> Any: ... - def check_data(self) -> Any: ... - def get_data(self) -> Any: ... - def get_single_data(self) -> Any: ... - def construct_document(self, node: Any) -> Any: ... - def construct_object(self, node: Any, deep: bool = False) -> Any: ... - def construct_non_recursive_object(self, node: Any, tag: str | None = None) -> Any: ... - def construct_scalar(self, node: Any) -> Any: ... - def construct_sequence(self, node: Any, deep: bool = False) -> Any: ... - def construct_mapping(self, node: Any, deep: bool = False) -> Any: ... - def check_mapping_key(self, node: Any, key_node: Any, mapping: Any, key: Any, value: Any) -> bool: ... - def check_set_key(self, node: Any, key_node: Any, setting: Any, key: Any) -> None: ... - def construct_pairs(self, node: Any, deep: bool = False) -> Any: ... + def scanner(self): ... + def check_data(self): ... + def get_data(self): ... + def get_single_data(self): ... + def construct_document(self, node): ... + def construct_object(self, node, deep: bool = False): ... + def construct_non_recursive_object(self, node, tag: str | None = None): ... + def construct_scalar(self, node): ... + def construct_sequence(self, node, deep: bool = False): ... + def construct_mapping(self, node, deep: bool = False): ... + def check_mapping_key(self, node, key_node, mapping, key, value) -> bool: ... + def check_set_key(self, node, key_node, setting, key) -> None: ... + def construct_pairs(self, node, deep: bool = False): ... @classmethod - def add_constructor(cls, tag: Any, constructor: Any) -> Any: ... + def add_constructor(cls, tag, constructor): ... @classmethod - def add_multi_constructor(cls, tag_prefix: Any, multi_constructor: Any) -> None: ... + def add_multi_constructor(cls, tag_prefix, multi_constructor) -> None: ... @classmethod - def add_default_constructor(cls, tag: str, method: Any = None, tag_base: str = "tag:yaml.org,2002:") -> None: ... + def add_default_constructor( + cls, tag: str, method: Incomplete | None = None, tag_base: str = "tag:yaml.org,2002:" + ) -> None: ... class SafeConstructor(BaseConstructor): - def construct_scalar(self, node: Any) -> Any: ... - def flatten_mapping(self, node: Any) -> Any: ... - def construct_mapping(self, node: Any, deep: bool = False) -> Any: ... - def construct_yaml_null(self, node: Any) -> Any: ... + def construct_scalar(self, node): ... + def flatten_mapping(self, node) -> None: ... + def construct_mapping(self, node, deep: bool = False): ... + def construct_yaml_null(self, node) -> None: ... bool_values: Incomplete - def construct_yaml_bool(self, node: Any) -> bool: ... - def construct_yaml_int(self, node: Any) -> int: ... + def construct_yaml_bool(self, node) -> bool: ... + def construct_yaml_int(self, node) -> int: ... inf_value: float nan_value: Incomplete - def construct_yaml_float(self, node: Any) -> float: ... - def construct_yaml_binary(self, node: Any) -> Any: ... + def construct_yaml_float(self, node) -> float: ... + def construct_yaml_binary(self, node): ... timestamp_regexp = timestamp_regexp - def construct_yaml_timestamp(self, node: Any, values: Any = None) -> Any: ... - def construct_yaml_omap(self, node: Any) -> Any: ... - def construct_yaml_pairs(self, node: Any) -> Any: ... - def construct_yaml_set(self, node: Any) -> Any: ... - def construct_yaml_str(self, node: Any) -> Any: ... - def construct_yaml_seq(self, node: Any) -> Any: ... - def construct_yaml_map(self, node: Any) -> Any: ... - def construct_yaml_object(self, node: Any, cls: Any) -> Any: ... - def construct_undefined(self, node: Any) -> None: ... + def construct_yaml_timestamp(self, node, values: Incomplete | None = None): ... + def construct_yaml_omap(self, node) -> Generator[Incomplete, None, None]: ... + def construct_yaml_pairs(self, node) -> Generator[Incomplete, None, None]: ... + def construct_yaml_set(self, node) -> Generator[Incomplete, None, None]: ... + def construct_yaml_str(self, node): ... + def construct_yaml_seq(self, node) -> Generator[Incomplete, None, None]: ... + def construct_yaml_map(self, node) -> Generator[Incomplete, None, None]: ... + def construct_yaml_object(self, node, cls) -> Generator[Incomplete, None, None]: ... + def construct_undefined(self, node) -> None: ... class Constructor(SafeConstructor): - def construct_python_str(self, node: Any) -> Any: ... - def construct_python_unicode(self, node: Any) -> Any: ... - def construct_python_bytes(self, node: Any) -> Any: ... - def construct_python_long(self, node: Any) -> int: ... - def construct_python_complex(self, node: Any) -> Any: ... - def construct_python_tuple(self, node: Any) -> Any: ... - def find_python_module(self, name: Any, mark: Any) -> Any: ... - def find_python_name(self, name: Any, mark: Any) -> Any: ... - def construct_python_name(self, suffix: Any, node: Any) -> Any: ... - def construct_python_module(self, suffix: Any, node: Any) -> Any: ... - def make_python_instance(self, suffix: Any, node: Any, args: Any = None, kwds: Any = None, newobj: bool = False) -> Any: ... - def set_python_instance_state(self, instance: Any, state: Any) -> None: ... - def construct_python_object(self, suffix: Any, node: Any) -> Any: ... - def construct_python_object_apply(self, suffix: Any, node: Any, newobj: bool = False) -> Any: ... - def construct_python_object_new(self, suffix: Any, node: Any) -> Any: ... + def construct_python_str(self, node): ... + def construct_python_unicode(self, node): ... + def construct_python_bytes(self, node): ... + def construct_python_long(self, node) -> int: ... + def construct_python_complex(self, node): ... + def construct_python_tuple(self, node): ... + def find_python_module(self, name, mark): ... + def find_python_name(self, name, mark): ... + def construct_python_name(self, suffix, node): ... + def construct_python_module(self, suffix, node): ... + def make_python_instance( + self, suffix, node, args: Incomplete | None = None, kwds: Incomplete | None = None, newobj: bool = False + ): ... + def set_python_instance_state(self, instance, state) -> None: ... + def construct_python_object(self, suffix, node) -> Generator[Incomplete, None, None]: ... + def construct_python_object_apply(self, suffix, node, newobj: bool = False): ... + def construct_python_object_new(self, suffix, node): ... @classmethod - def add_default_constructor(cls, tag: str, method: Any = None, tag_base: str = "tag:yaml.org,2002:python/") -> None: ... + def add_default_constructor( + cls, tag: str, method: Incomplete | None = None, tag_base: str = "tag:yaml.org,2002:python/" + ) -> None: ... class RoundTripConstructor(SafeConstructor): - def comment(self, idx: Any) -> Any: ... - def comments(self, list_of_comments: Any, idx: Any | None = None) -> Any: ... - def construct_scalar(self, node: Any) -> Any: ... - def construct_yaml_int(self, node: Any) -> Any: ... - def construct_yaml_float(self, node: Any) -> Any: ... - def construct_yaml_str(self, node: Any) -> Any: ... - def construct_rt_sequence(self, node: Any, seqtyp: Any, deep: bool = False) -> Any: ... - def flatten_mapping(self, node: Any) -> Any: ... - def construct_mapping(self, node: Any, maptyp: Any, deep: bool = False) -> Any: ... - def construct_setting(self, node: Any, typ: Any, deep: bool = False) -> Any: ... - def construct_yaml_seq(self, node: Any) -> Iterator[CommentedSeq]: ... - def construct_yaml_map(self, node: Any) -> Iterator[CommentedMap]: ... - def set_collection_style(self, data: Any, node: Any) -> None: ... - def construct_yaml_object(self, node: Any, cls: Any) -> Any: ... - def construct_yaml_omap(self, node: Any) -> Iterator[CommentedOrderedMap]: ... - def construct_yaml_set(self, node: Any) -> Iterator[CommentedSet]: ... - def construct_unknown(self, node: Any) -> Iterator[CommentedMap | TaggedScalar | CommentedSeq]: ... - def construct_yaml_timestamp(self, node: Any, values: Any = None) -> datetime.date | datetime.datetime | TimeStamp: ... - def construct_yaml_sbool(self, node: Any) -> bool | ScalarBoolean: ... + def comment(self, idx): ... + def comments(self, list_of_comments, idx: Incomplete = None): ... + def construct_scalar(self, node): ... + def construct_yaml_int(self, node): ... + def construct_yaml_float(self, node): ... + def construct_yaml_str(self, node): ... + def construct_rt_sequence(self, node, seqtyp, deep: bool = False): ... + def flatten_mapping(self, node): ... + def construct_mapping(self, node, maptyp, deep: bool = False): ... + def construct_setting(self, node, typ, deep: bool = False): ... + def construct_yaml_seq(self, node) -> Iterator[CommentedSeq]: ... + def construct_yaml_map(self, node) -> Iterator[CommentedMap]: ... + def set_collection_style(self, data, node) -> None: ... + def construct_yaml_object(self, node, cls) -> Generator[Incomplete, None, None]: ... + def construct_yaml_omap(self, node) -> Iterator[CommentedOrderedMap]: ... + def construct_yaml_set(self, node) -> Iterator[CommentedSet]: ... + def construct_unknown(self, node) -> Iterator[CommentedMap | TaggedScalar | CommentedSeq]: ... + def construct_yaml_timestamp( + self, node, values: Incomplete | None = None + ) -> datetime.date | datetime.datetime | TimeStamp: ... + def construct_yaml_sbool(self, node) -> bool | ScalarBoolean: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi b/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi index 88107d8989cd..faf018964430 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi @@ -1,4 +1,4 @@ -from typing import Any +from _typeshed import Incomplete from _ruamel_yaml import CEmitter, CParser from ruamel.yaml.compat import StreamTextType, VersionType @@ -26,62 +26,62 @@ class CLoader(CParser, Constructor, Resolver): class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver): def __init__( self, - stream: Any, - default_style: Any = None, - default_flow_style: Any = None, + stream, + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding: Incomplete | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Any = None, - tags: Any = None, - block_seq_indent: Any = None, - top_level_colon_align: Any = None, - prefix_colon: Any = None, + version: Incomplete | None = None, + tags: Incomplete | None = None, + block_seq_indent: Incomplete | None = None, + top_level_colon_align: Incomplete | None = None, + prefix_colon: Incomplete | None = None, ) -> None: ... class CSafeDumper(CEmitter, SafeRepresenter, Resolver): def __init__( self, - stream: Any, - default_style: Any = None, - default_flow_style: Any = None, + stream, + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding: Incomplete | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Any = None, - tags: Any = None, - block_seq_indent: Any = None, - top_level_colon_align: Any = None, - prefix_colon: Any = None, + version: Incomplete | None = None, + tags: Incomplete | None = None, + block_seq_indent: Incomplete | None = None, + top_level_colon_align: Incomplete | None = None, + prefix_colon: Incomplete | None = None, ) -> None: ... class CDumper(CEmitter, Representer, Resolver): def __init__( self, - stream: Any, - default_style: Any = None, - default_flow_style: Any = None, + stream, + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding: Incomplete | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Any = None, - tags: Any = None, - block_seq_indent: Any = None, - top_level_colon_align: Any = None, - prefix_colon: Any = None, + version: Incomplete | None = None, + tags: Incomplete | None = None, + block_seq_indent: Incomplete | None = None, + top_level_colon_align: Incomplete | None = None, + prefix_colon: Incomplete | None = None, ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi b/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi index 8188a24d3837..098f9ce1814e 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi @@ -6,7 +6,7 @@ class Version: def major(self) -> int: ... @property def minor(self) -> int: ... - def __eq__(self, v: object) -> bool: ... + def __eq__(self, v) -> bool: ... def __lt__(self, v: Version) -> bool: ... def __le__(self, v: Version) -> bool: ... def __gt__(self, v: Version) -> bool: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi index c09a06a7af71..90449e531483 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi @@ -1,4 +1,4 @@ -from typing import Any +from _typeshed import Incomplete from ruamel.yaml.compat import StreamType from ruamel.yaml.emitter import Emitter @@ -12,82 +12,82 @@ class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): def __init__( self, stream: StreamType, - default_style: Any = None, - default_flow_style: Any = None, + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding: Incomplete | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Any = None, - tags: Any = None, - block_seq_indent: Any = None, - top_level_colon_align: Any = None, - prefix_colon: Any = None, + version: Incomplete | None = None, + tags: Incomplete | None = None, + block_seq_indent: Incomplete | None = None, + top_level_colon_align: Incomplete | None = None, + prefix_colon: Incomplete | None = None, ) -> None: ... class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): def __init__( self, stream: StreamType, - default_style: Any = None, - default_flow_style: Any = None, + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding: Incomplete | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Any = None, - tags: Any = None, - block_seq_indent: Any = None, - top_level_colon_align: Any = None, - prefix_colon: Any = None, + version: Incomplete | None = None, + tags: Incomplete | None = None, + block_seq_indent: Incomplete | None = None, + top_level_colon_align: Incomplete | None = None, + prefix_colon: Incomplete | None = None, ) -> None: ... class Dumper(Emitter, Serializer, Representer, Resolver): def __init__( self, stream: StreamType, - default_style: Any = None, - default_flow_style: Any = None, + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding: Incomplete | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Any = None, - tags: Any = None, - block_seq_indent: Any = None, - top_level_colon_align: Any = None, - prefix_colon: Any = None, + version: Incomplete | None = None, + tags: Incomplete | None = None, + block_seq_indent: Incomplete | None = None, + top_level_colon_align: Incomplete | None = None, + prefix_colon: Incomplete | None = None, ) -> None: ... class RoundTripDumper(Emitter, Serializer, RoundTripRepresenter, VersionedResolver): def __init__( self, stream: StreamType, - default_style: Any = None, + default_style: Incomplete | None = None, default_flow_style: bool | None = None, canonical: int | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding: Incomplete | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Any = None, - tags: Any = None, - block_seq_indent: Any = None, - top_level_colon_align: Any = None, - prefix_colon: Any = None, + version: Incomplete | None = None, + tags: Incomplete | None = None, + block_seq_indent: Incomplete | None = None, + top_level_colon_align: Incomplete | None = None, + prefix_colon: Incomplete | None = None, ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi index 6a455cff4611..0bcb964da88d 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any from ruamel.yaml.compat import StreamType from ruamel.yaml.error import YAMLError @@ -20,9 +19,9 @@ class ScalarAnalysis: allow_block: Incomplete def __init__( self, - scalar: Any, - empty: Any, - multiline: Any, + scalar, + empty, + multiline, allow_flow_plain: bool, allow_block_plain: bool, allow_single_quoted: bool, @@ -33,8 +32,8 @@ class ScalarAnalysis: class Indents: values: Incomplete def __init__(self) -> None: ... - def append(self, val: Any, seq: Any) -> None: ... - def pop(self) -> Any: ... + def append(self, val, seq) -> None: ... + def pop(self): ... def seq_seq(self) -> bool: ... def last_seq(self) -> bool: ... def seq_flow_align(self, seq_indent: int, column: int, pre_comment: bool | None = False) -> int: ... @@ -94,33 +93,33 @@ class Emitter: def __init__( self, stream: StreamType, - canonical: Any = None, + canonical: Incomplete | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, + line_break: Incomplete | None = None, block_seq_indent: int | None = None, top_level_colon_align: bool | None = None, - prefix_colon: Any = None, + prefix_colon: Incomplete | None = None, brace_single_entry_mapping_in_flow_sequence: bool | None = None, - dumper: Any = None, + dumper: Incomplete | None = None, ) -> None: ... @property - def stream(self) -> Any: ... + def stream(self): ... @stream.setter - def stream(self, val: Any) -> None: ... + def stream(self, val) -> None: ... @property - def serializer(self) -> Any: ... + def serializer(self): ... @property def flow_level(self) -> int: ... def dispose(self) -> None: ... - def emit(self, event: Any) -> None: ... + def emit(self, event) -> None: ... def need_more_events(self) -> bool: ... def need_events(self, count: int) -> bool: ... def increase_indent(self, flow: bool = False, sequence: bool | None = None, indentless: bool = False) -> None: ... def expect_stream_start(self) -> None: ... def expect_nothing(self) -> None: ... - def expect_first_document_start(self) -> Any: ... + def expect_first_document_start(self): ... def expect_document_start(self, first: bool = False) -> None: ... def expect_document_end(self) -> None: ... def expect_document_root(self) -> None: ... @@ -138,47 +137,45 @@ class Emitter: def expect_flow_mapping_simple_value(self) -> None: ... def expect_flow_mapping_value(self) -> None: ... def expect_block_sequence(self) -> None: ... - def expect_first_block_sequence_item(self) -> Any: ... + def expect_first_block_sequence_item(self): ... def expect_block_sequence_item(self, first: bool = False) -> None: ... def expect_block_mapping(self) -> None: ... def expect_first_block_mapping_key(self) -> None: ... - def expect_block_mapping_key(self, first: Any = False) -> None: ... + def expect_block_mapping_key(self, first: bool = False) -> None: ... def expect_block_mapping_simple_value(self) -> None: ... def expect_block_mapping_value(self) -> None: ... def check_empty_sequence(self) -> bool: ... def check_empty_mapping(self) -> bool: ... def check_empty_document(self) -> bool: ... def check_simple_key(self) -> bool: ... - def process_anchor(self, indicator: Any) -> bool: ... + def process_anchor(self, indicator) -> bool: ... def process_tag(self) -> None: ... - def choose_scalar_style(self) -> Any: ... + def choose_scalar_style(self): ... def process_scalar(self) -> None: ... - def prepare_version(self, version: Any) -> Any: ... - def prepare_tag_handle(self, handle: Any) -> Any: ... - def prepare_tag_prefix(self, prefix: Any) -> Any: ... - def prepare_tag(self, tag: Any) -> Any: ... - def prepare_anchor(self, anchor: Any) -> Any: ... - def analyze_scalar(self, scalar: Any) -> Any: ... + def prepare_version(self, version): ... + def prepare_tag_handle(self, handle): ... + def prepare_tag_prefix(self, prefix): ... + def prepare_tag(self, tag): ... + def prepare_anchor(self, anchor): ... + def analyze_scalar(self, scalar): ... def flush_stream(self) -> None: ... def write_stream_start(self) -> None: ... def write_stream_end(self) -> None: ... - def write_indicator( - self, indicator: Any, need_whitespace: Any, whitespace: bool = False, indention: bool = False - ) -> None: ... + def write_indicator(self, indicator, need_whitespace, whitespace: bool = False, indention: bool = False) -> None: ... def write_indent(self) -> None: ... - def write_line_break(self, data: Any = None) -> None: ... - def write_version_directive(self, version_text: Any) -> None: ... - def write_tag_directive(self, handle_text: Any, prefix_text: Any) -> None: ... - def write_single_quoted(self, text: Any, split: Any = True) -> None: ... + def write_line_break(self, data: Incomplete | None = None) -> None: ... + def write_version_directive(self, version_text) -> None: ... + def write_tag_directive(self, handle_text, prefix_text) -> None: ... + def write_single_quoted(self, text, split: bool = True) -> None: ... ESCAPE_REPLACEMENTS: Incomplete - def write_double_quoted(self, text: Any, split: Any = True) -> None: ... - def determine_block_hints(self, text: Any) -> Any: ... - def write_folded(self, text: Any, comment: Any) -> None: ... - def write_literal(self, text: Any, comment: Any = None) -> None: ... - def write_plain(self, text: Any, split: Any = True) -> None: ... - def write_comment(self, comment: Any, pre: bool = False) -> None: ... - def write_pre_comment(self, event: Any) -> bool: ... - def write_post_comment(self, event: Any) -> bool: ... + def write_double_quoted(self, text, split: bool = True) -> None: ... + def determine_block_hints(self, text): ... + def write_folded(self, text, comment) -> None: ... + def write_literal(self, text, comment: Incomplete | None = None) -> None: ... + def write_plain(self, text, split: bool = True) -> None: ... + def write_comment(self, comment, pre: bool = False) -> None: ... + def write_pre_comment(self, event) -> bool: ... + def write_post_comment(self, event) -> bool: ... class RoundTripEmitter(Emitter): - def prepare_tag(self, ctag: Any) -> Any: ... + def prepare_tag(self, ctag): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/error.pyi b/stubs/ruamel.yaml/ruamel/yaml/error.pyi index 36a80851d683..7eb7cc12bd32 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/error.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/error.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any __all__ = [ "FileMark", @@ -18,21 +17,21 @@ class StreamMark: index: Incomplete line: Incomplete column: Incomplete - def __init__(self, name: Any, index: int, line: int, column: int) -> None: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... + def __init__(self, name, index: int, line: int, column: int) -> None: ... + def __eq__(self, other) -> bool: ... + def __ne__(self, other) -> bool: ... class FileMark(StreamMark): ... class StringMark(StreamMark): buffer: Incomplete pointer: Incomplete - def __init__(self, name: Any, index: int, line: int, column: int, buffer: Any, pointer: Any) -> None: ... - def get_snippet(self, indent: int = 4, max_length: int = 75) -> Any: ... + def __init__(self, name, index: int, line: int, column: int, buffer, pointer) -> None: ... + def get_snippet(self, indent: int = 4, max_length: int = 75): ... class CommentMark: column: Incomplete - def __init__(self, column: Any) -> None: ... + def __init__(self, column) -> None: ... class YAMLError(Exception): ... @@ -44,12 +43,12 @@ class MarkedYAMLError(YAMLError): note: Incomplete def __init__( self, - context: Any = None, - context_mark: Any = None, - problem: Any = None, - problem_mark: Any = None, - note: Any = None, - warn: Any = None, + context: Incomplete | None = None, + context_mark: Incomplete | None = None, + problem: Incomplete | None = None, + problem_mark: Incomplete | None = None, + note: Incomplete | None = None, + warn: Incomplete | None = None, ) -> None: ... def check_append(self, lines: list[str], val: str | None) -> None: ... @@ -65,12 +64,12 @@ class MarkedYAMLWarning(YAMLWarning): warn: Incomplete def __init__( self, - context: Any = None, - context_mark: Any = None, - problem: Any = None, - problem_mark: Any = None, - note: Any = None, - warn: Any = None, + context: Incomplete | None = None, + context_mark: Incomplete | None = None, + problem: Incomplete | None = None, + problem_mark: Incomplete | None = None, + note: Incomplete | None = None, + warn: Incomplete | None = None, ) -> None: ... def check_append(self, lines: list[str], val: str | None) -> None: ... @@ -82,7 +81,7 @@ class UnsafeLoaderWarning(YAMLWarning): class MantissaNoDotYAML1_1Warning(YAMLWarning): node: Incomplete flt: Incomplete - def __init__(self, node: Any, flt_str: Any) -> None: ... + def __init__(self, node, flt_str) -> None: ... class YAMLFutureWarning(Warning): ... @@ -95,11 +94,11 @@ class MarkedYAMLFutureWarning(YAMLFutureWarning): warn: Incomplete def __init__( self, - context: Any = None, - context_mark: Any = None, - problem: Any = None, - problem_mark: Any = None, - note: Any = None, - warn: Any = None, + context: Incomplete | None = None, + context_mark: Incomplete | None = None, + problem: Incomplete | None = None, + problem_mark: Incomplete | None = None, + note: Incomplete | None = None, + warn: Incomplete | None = None, ) -> None: ... def check_append(self, lines: list[str], val: str | None) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/events.pyi b/stubs/ruamel.yaml/ruamel/yaml/events.pyi index 118f053e703d..a5f845aa5b1a 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/events.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/events.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any SHOW_LINES: bool @@ -10,12 +9,14 @@ class Event: start_mark: Incomplete end_mark: Incomplete comment: Incomplete - def __init__(self, start_mark: Any = None, end_mark: Any = None, comment: Any = ...) -> None: ... + def __init__(self, start_mark: Incomplete | None = None, end_mark: Incomplete | None = None, comment=...) -> None: ... def compact_repr(self) -> str: ... class NodeEvent(Event): anchor: Incomplete - def __init__(self, anchor: Any, start_mark: Any = None, end_mark: Any = None, comment: Any = None) -> None: ... + def __init__( + self, anchor, start_mark: Incomplete | None = None, end_mark: Incomplete | None = None, comment: Incomplete | None = None + ) -> None: ... class CollectionStartEvent(NodeEvent): ctag: Incomplete @@ -24,13 +25,13 @@ class CollectionStartEvent(NodeEvent): nr_items: Incomplete def __init__( self, - anchor: Any, - tag: Any, - implicit: Any, - start_mark: Any = None, - end_mark: Any = None, - flow_style: Any = None, - comment: Any = None, + anchor, + tag, + implicit, + start_mark: Incomplete | None = None, + end_mark: Incomplete | None = None, + flow_style: Incomplete | None = None, + comment: Incomplete | None = None, nr_items: int | None = None, ) -> None: ... @property @@ -41,7 +42,13 @@ class CollectionEndEvent(Event): ... class StreamStartEvent(Event): crepr: str encoding: Incomplete - def __init__(self, start_mark: Any = None, end_mark: Any = None, encoding: Any = None, comment: Any = None) -> None: ... + def __init__( + self, + start_mark: Incomplete | None = None, + end_mark: Incomplete | None = None, + encoding: Incomplete | None = None, + comment: Incomplete | None = None, + ) -> None: ... class StreamEndEvent(Event): crepr: str @@ -53,26 +60,37 @@ class DocumentStartEvent(Event): tags: Incomplete def __init__( self, - start_mark: Any = None, - end_mark: Any = None, - explicit: Any = None, - version: Any = None, - tags: Any = None, - comment: Any = None, + start_mark: Incomplete | None = None, + end_mark: Incomplete | None = None, + explicit: Incomplete | None = None, + version: Incomplete | None = None, + tags: Incomplete | None = None, + comment: Incomplete | None = None, ) -> None: ... def compact_repr(self) -> str: ... class DocumentEndEvent(Event): crepr: str explicit: Incomplete - def __init__(self, start_mark: Any = None, end_mark: Any = None, explicit: Any = None, comment: Any = None) -> None: ... + def __init__( + self, + start_mark: Incomplete | None = None, + end_mark: Incomplete | None = None, + explicit: Incomplete | None = None, + comment: Incomplete | None = None, + ) -> None: ... def compact_repr(self) -> str: ... class AliasEvent(NodeEvent): crepr: str style: Incomplete def __init__( - self, anchor: Any, start_mark: Any = None, end_mark: Any = None, style: Any = None, comment: Any = None + self, + anchor, + start_mark: Incomplete | None = None, + end_mark: Incomplete | None = None, + style: Incomplete | None = None, + comment: Incomplete | None = None, ) -> None: ... def compact_repr(self) -> str: ... @@ -84,19 +102,19 @@ class ScalarEvent(NodeEvent): style: Incomplete def __init__( self, - anchor: Any, - tag: Any, - implicit: Any, - value: Any, - start_mark: Any = None, - end_mark: Any = None, - style: Any = None, - comment: Any = None, + anchor, + tag, + implicit, + value, + start_mark: Incomplete | None = None, + end_mark: Incomplete | None = None, + style: Incomplete | None = None, + comment: Incomplete | None = None, ) -> None: ... @property def tag(self) -> str | None: ... @tag.setter - def tag(self, val: Any) -> None: ... + def tag(self, val) -> None: ... def compact_repr(self) -> str: ... class SequenceStartEvent(CollectionStartEvent): diff --git a/stubs/ruamel.yaml/ruamel/yaml/main.pyi b/stubs/ruamel.yaml/ruamel/yaml/main.pyi index 77a4780868a6..81c5dcdc4312 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/main.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/main.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from pathlib import Path from types import TracebackType -from typing import Any from ruamel.yaml.compat import ( StreamTextType as StreamTextType, @@ -57,193 +56,200 @@ class YAML: scalar_after_indicator: Incomplete brace_single_entry_mapping_in_flow_sequence: bool def __init__( - self, *, typ: list[str] | str | None = None, pure: Any = False, output: Any = None, plug_ins: Any = None + self, + *, + typ: list[str] | str | None = None, + pure: bool = False, + output: Incomplete | None = None, + plug_ins: Incomplete | None = None, ) -> None: ... @property - def reader(self) -> Any: ... + def reader(self): ... @property - def scanner(self) -> Any: ... + def scanner(self): ... @property - def parser(self) -> Any: ... + def parser(self): ... @property - def composer(self) -> Any: ... + def composer(self): ... @property - def constructor(self) -> Any: ... + def constructor(self): ... @property - def resolver(self) -> Any: ... + def resolver(self): ... @property - def emitter(self) -> Any: ... + def emitter(self): ... @property - def serializer(self) -> Any: ... + def serializer(self): ... @property - def representer(self) -> Any: ... - def scan(self, stream: StreamTextType) -> Any: ... - def parse(self, stream: StreamTextType) -> Any: ... - def compose(self, stream: Path | StreamTextType) -> Any: ... - def compose_all(self, stream: Path | StreamTextType) -> Any: ... - def load(self, stream: Path | StreamTextType) -> Any: ... - def load_all(self, stream: Path | StreamTextType) -> Any: ... - def get_constructor_parser(self, stream: StreamTextType) -> Any: ... - def emit(self, events: Any, stream: Any) -> None: ... - def serialize(self, node: Any, stream: StreamType | None) -> Any: ... - def serialize_all(self, nodes: Any, stream: StreamType | None) -> Any: ... - def dump(self, data: Path | StreamType, stream: Any = None, *, transform: Any = None) -> Any: ... - def dump_all(self, documents: Any, stream: Path | StreamType, *, transform: Any = None) -> Any: ... - def Xdump_all(self, documents: Any, stream: Any, *, transform: Any = None) -> Any: ... - def get_serializer_representer_emitter(self, stream: StreamType, tlca: Any) -> Any: ... - def map(self, **kw: Any) -> Any: ... - def seq(self, *args: Any) -> Any: ... - def official_plug_ins(self) -> Any: ... - def register_class(self, cls: Any) -> Any: ... - def __enter__(self) -> Any: ... + def representer(self): ... + def scan(self, stream: StreamTextType): ... + def parse(self, stream: StreamTextType): ... + def compose(self, stream: Path | StreamTextType): ... + def compose_all(self, stream: Path | StreamTextType): ... + def load(self, stream: Path | StreamTextType): ... + def load_all(self, stream: Path | StreamTextType): ... + def get_constructor_parser(self, stream: StreamTextType): ... + def emit(self, events, stream) -> None: ... + def serialize(self, node, stream: StreamType | None): ... + def serialize_all(self, nodes, stream: StreamType | None): ... + def dump(self, data: Path | StreamType, stream: Incomplete | None = None, *, transform: Incomplete | None = None): ... + def dump_all(self, documents, stream: Path | StreamType, *, transform: Incomplete | None = None): ... + def Xdump_all(self, documents, stream, *, transform: Incomplete | None = None): ... + def get_serializer_representer_emitter(self, stream: StreamType, tlca): ... + def map(self, **kw): ... + def seq(self, *args): ... + def official_plug_ins(self): ... + def register_class(self, cls): ... + def __enter__(self): ... def __exit__(self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None) -> None: ... @property def version(self) -> tuple[int, int] | None: ... @version.setter def version(self, val: VersionType) -> None: ... @property - def tags(self) -> Any: ... + def tags(self): ... @tags.setter - def tags(self, val: Any) -> None: ... + def tags(self, val) -> None: ... @property - def indent(self) -> Any: ... + def indent(self): ... @indent.setter - def indent(self, val: Any) -> None: ... + def indent(self, val) -> None: ... @property - def block_seq_indent(self) -> Any: ... + def block_seq_indent(self): ... @block_seq_indent.setter - def block_seq_indent(self, val: Any) -> None: ... - def compact(self, seq_seq: Any = None, seq_map: Any = None) -> None: ... + def block_seq_indent(self, val) -> None: ... + def compact(self, seq_seq: Incomplete | None = None, seq_map: Incomplete | None = None) -> None: ... class YAMLContextManager: - def __init__(self, yaml: Any, transform: Any = None) -> None: ... + def __init__(self, yaml, transform: Incomplete | None = None) -> None: ... def teardown_output(self) -> None: ... - def init_output(self, first_data: Any) -> None: ... - def dump(self, data: Any) -> None: ... + def init_output(self, first_data) -> None: ... + def dump(self, data) -> None: ... -def yaml_object(yml: Any) -> Any: ... -def warn_deprecation(fun: Any, method: Any, arg: str = "") -> None: ... -def error_deprecation(fun: Any, method: Any, arg: str = "", comment: str = "instead of") -> None: ... -def scan(stream: StreamTextType, Loader: Any = ...) -> Any: ... -def parse(stream: StreamTextType, Loader: Any = ...) -> Any: ... -def compose(stream: StreamTextType, Loader: Any = ...) -> Any: ... -def compose_all(stream: StreamTextType, Loader: Any = ...) -> Any: ... -def load(stream: Any, Loader: Any = None, version: Any = None, preserve_quotes: Any = None) -> Any: ... -def load_all(stream: Any, Loader: Any = None, version: Any = None, preserve_quotes: Any = None) -> Any: ... -def safe_load(stream: StreamTextType, version: VersionType | None = None) -> Any: ... -def safe_load_all(stream: StreamTextType, version: VersionType | None = None) -> Any: ... -def round_trip_load(stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None) -> Any: ... -def round_trip_load_all( - stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None -) -> Any: ... +def yaml_object(yml): ... +def warn_deprecation(fun, method, arg: str = "") -> None: ... +def error_deprecation(fun, method, arg: str = "", comment: str = "instead of") -> None: ... +def scan(stream: StreamTextType, Loader=...): ... +def parse(stream: StreamTextType, Loader=...): ... +def compose(stream: StreamTextType, Loader=...): ... +def compose_all(stream: StreamTextType, Loader=...): ... +def load( + stream, Loader: Incomplete | None = None, version: Incomplete | None = None, preserve_quotes: Incomplete | None = None +) -> None: ... +def load_all( + stream, Loader: Incomplete | None = None, version: Incomplete | None = None, preserve_quotes: Incomplete | None = None +) -> None: ... +def safe_load(stream: StreamTextType, version: VersionType | None = None): ... +def safe_load_all(stream: StreamTextType, version: VersionType | None = None): ... +def round_trip_load(stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None): ... +def round_trip_load_all(stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None): ... def emit( - events: Any, + events, stream: StreamType | None = None, - Dumper: Any = ..., + Dumper=..., canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, -) -> Any: ... + line_break: Incomplete | None = None, +): ... enc: Incomplete def serialize_all( - nodes: Any, + nodes, stream: StreamType | None = None, - Dumper: Any = ..., - canonical: Any = None, + Dumper=..., + canonical: Incomplete | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding=None, explicit_start: bool | None = None, explicit_end: bool | None = None, version: VersionType | None = None, - tags: Any = None, -) -> Any: ... -def serialize(node: Any, stream: StreamType | None = None, Dumper: Any = ..., **kwds: Any) -> Any: ... + tags: Incomplete | None = None, +): ... +def serialize(node, stream: StreamType | None = None, Dumper=..., **kwds): ... def dump_all( - documents: Any, + documents, stream: StreamType | None = None, - Dumper: Any = ..., - default_style: Any = None, - default_flow_style: Any = None, + Dumper=..., + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding=None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Any = None, - tags: Any = None, - block_seq_indent: Any = None, - top_level_colon_align: Any = None, - prefix_colon: Any = None, -) -> Any: ... + version: Incomplete | None = None, + tags: Incomplete | None = None, + block_seq_indent: Incomplete | None = None, + top_level_colon_align: Incomplete | None = None, + prefix_colon: Incomplete | None = None, +): ... def dump( - data: Any, + data, stream: StreamType | None = None, - Dumper: Any = ..., - default_style: Any = None, - default_flow_style: Any = None, + Dumper=..., + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding=None, explicit_start: bool | None = None, explicit_end: bool | None = None, version: VersionType | None = None, - tags: Any = None, - block_seq_indent: Any = None, -) -> Any: ... -def safe_dump(data: Any, stream: StreamType | None = None, **kwds: Any) -> Any: ... + tags: Incomplete | None = None, + block_seq_indent: Incomplete | None = None, +): ... +def safe_dump(data, stream: StreamType | None = None, **kwds): ... def round_trip_dump( - data: Any, + data, stream: StreamType | None = None, - Dumper: Any = ..., - default_style: Any = None, - default_flow_style: Any = None, + Dumper=..., + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Any = None, - encoding: Any = None, + line_break: Incomplete | None = None, + encoding=None, explicit_start: bool | None = None, explicit_end: bool | None = None, version: VersionType | None = None, - tags: Any = None, - block_seq_indent: Any = None, - top_level_colon_align: Any = None, - prefix_colon: Any = None, -) -> Any: ... + tags: Incomplete | None = None, + block_seq_indent: Incomplete | None = None, + top_level_colon_align: Incomplete | None = None, + prefix_colon: Incomplete | None = None, +): ... def add_implicit_resolver( - tag: Any, regexp: Any, first: Any = None, Loader: Any = None, Dumper: Any = None, resolver: Any = ... + tag, regexp, first: Incomplete | None = None, Loader: Incomplete | None = None, Dumper: Incomplete | None = None, resolver=... ) -> None: ... def add_path_resolver( - tag: Any, path: Any, kind: Any = None, Loader: Any = None, Dumper: Any = None, resolver: Any = ... + tag, path, kind: Incomplete | None = None, Loader: Incomplete | None = None, Dumper: Incomplete | None = None, resolver=... ) -> None: ... -def add_constructor(tag: Any, object_constructor: Any, Loader: Any = None, constructor: Any = ...) -> None: ... -def add_multi_constructor(tag_prefix: Any, multi_constructor: Any, Loader: Any = None, constructor: Any = ...) -> None: ... -def add_representer(data_type: Any, object_representer: Any, Dumper: Any = None, representer: Any = ...) -> None: ... -def add_multi_representer(data_type: Any, multi_representer: Any, Dumper: Any = None, representer: Any = ...) -> None: ... +def add_constructor(tag, object_constructor, Loader: Incomplete | None = None, constructor=...) -> None: ... +def add_multi_constructor(tag_prefix, multi_constructor, Loader: Incomplete | None = None, constructor=...) -> None: ... +def add_representer(data_type, object_representer, Dumper: Incomplete | None = None, representer=...) -> None: ... +def add_multi_representer(data_type, multi_representer, Dumper: Incomplete | None = None, representer=...) -> None: ... class YAMLObjectMetaclass(type): - def __init__(cls, name: Any, bases: Any, kwds: Any) -> None: ... + def __init__(cls, name, bases, kwds) -> None: ... class YAMLObject(Incomplete): yaml_constructor = Constructor yaml_representer = Representer - yaml_tag: Any - yaml_flow_style: Any + yaml_tag: Incomplete + yaml_flow_style: Incomplete @classmethod - def from_yaml(cls, constructor: Any, node: Any) -> Any: ... + def from_yaml(cls, constructor, node): ... @classmethod - def to_yaml(cls, representer: Any, data: Any) -> Any: ... + def to_yaml(cls, representer, data): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi index 425c60acebdb..312a367d6f2d 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any class Node: ctag: Incomplete @@ -8,11 +7,13 @@ class Node: end_mark: Incomplete comment: Incomplete anchor: Incomplete - def __init__(self, tag: Any, value: Any, start_mark: Any, end_mark: Any, comment: Any = None, anchor: Any = None) -> None: ... + def __init__( + self, tag, value, start_mark, end_mark, comment: Incomplete | None = None, anchor: Incomplete | None = None + ) -> None: ... @property def tag(self) -> str | None: ... @tag.setter - def tag(self, val: Any) -> None: ... + def tag(self, val) -> None: ... def dump(self, indent: int = 0) -> None: ... class ScalarNode(Node): @@ -20,13 +21,13 @@ class ScalarNode(Node): style: Incomplete def __init__( self, - tag: Any, - value: Any, - start_mark: Any = None, - end_mark: Any = None, - style: Any = None, - comment: Any = None, - anchor: Any = None, + tag, + value, + start_mark: Incomplete | None = None, + end_mark: Incomplete | None = None, + style: Incomplete | None = None, + comment: Incomplete | None = None, + anchor: Incomplete | None = None, ) -> None: ... class CollectionNode(Node): @@ -34,13 +35,13 @@ class CollectionNode(Node): anchor: Incomplete def __init__( self, - tag: Any, - value: Any, - start_mark: Any = None, - end_mark: Any = None, - flow_style: Any = None, - comment: Any = None, - anchor: Any = None, + tag, + value, + start_mark: Incomplete | None = None, + end_mark: Incomplete | None = None, + flow_style: Incomplete | None = None, + comment: Incomplete | None = None, + anchor: Incomplete | None = None, ) -> None: ... class SequenceNode(CollectionNode): @@ -51,11 +52,11 @@ class MappingNode(CollectionNode): merge: Incomplete def __init__( self, - tag: Any, - value: Any, - start_mark: Any = None, - end_mark: Any = None, - flow_style: Any = None, - comment: Any = None, - anchor: Any = None, + tag, + value, + start_mark: Incomplete | None = None, + end_mark: Incomplete | None = None, + flow_style: Incomplete | None = None, + comment: Incomplete | None = None, + anchor: Incomplete | None = None, ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/parser.pyi b/stubs/ruamel.yaml/ruamel/yaml/parser.pyi index 79ff2dd0b1de..7ad427ef2c8b 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/parser.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/parser.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any from ruamel.yaml.error import MarkedYAMLError from ruamel.yaml.events import * @@ -13,7 +12,7 @@ class ParserError(MarkedYAMLError): ... class Parser: DEFAULT_TAGS: Incomplete loader: Incomplete - def __init__(self, loader: Any) -> None: ... + def __init__(self, loader) -> None: ... current_event: Incomplete tag_handles: Incomplete states: Incomplete @@ -22,46 +21,46 @@ class Parser: def reset_parser(self) -> None: ... def dispose(self) -> None: ... @property - def scanner(self) -> Any: ... + def scanner(self): ... @property - def resolver(self) -> Any: ... - def check_event(self, *choices: Any) -> bool: ... - def peek_event(self) -> Any: ... + def resolver(self): ... + def check_event(self, *choices) -> bool: ... + def peek_event(self): ... last_event: Incomplete - def get_event(self) -> Any: ... - def parse_stream_start(self) -> Any: ... - def parse_implicit_document_start(self) -> Any: ... - def parse_document_start(self) -> Any: ... - def parse_document_end(self) -> Any: ... - def parse_document_content(self) -> Any: ... - def process_directives(self) -> Any: ... - def parse_block_node(self) -> Any: ... - def parse_flow_node(self) -> Any: ... - def parse_block_node_or_indentless_sequence(self) -> Any: ... + def get_event(self): ... + def parse_stream_start(self): ... + def parse_implicit_document_start(self): ... + def parse_document_start(self): ... + def parse_document_end(self): ... + def parse_document_content(self): ... + def process_directives(self): ... + def parse_block_node(self): ... + def parse_flow_node(self): ... + def parse_block_node_or_indentless_sequence(self): ... def select_tag_transform(self, tag: Tag) -> None: ... - def parse_node(self, block: bool = False, indentless_sequence: bool = False) -> Any: ... - def parse_block_sequence_first_entry(self) -> Any: ... - def parse_block_sequence_entry(self) -> Any: ... - def parse_indentless_sequence_entry(self) -> Any: ... - def parse_block_mapping_first_key(self) -> Any: ... - def parse_block_mapping_key(self) -> Any: ... - def parse_block_mapping_value(self) -> Any: ... - def parse_flow_sequence_first_entry(self) -> Any: ... - def parse_flow_sequence_entry(self, first: bool = False) -> Any: ... - def parse_flow_sequence_entry_mapping_key(self) -> Any: ... - def parse_flow_sequence_entry_mapping_value(self) -> Any: ... - def parse_flow_sequence_entry_mapping_end(self) -> Any: ... - def parse_flow_mapping_first_key(self) -> Any: ... - def parse_flow_mapping_key(self, first: Any = False) -> Any: ... - def parse_flow_mapping_value(self) -> Any: ... - def parse_flow_mapping_empty_value(self) -> Any: ... - def process_empty_scalar(self, mark: Any, comment: Any = None) -> Any: ... - def move_token_comment(self, token: Any, nt: Any | None = None, empty: bool | None = False) -> Any: ... + def parse_node(self, block: bool = False, indentless_sequence: bool = False): ... + def parse_block_sequence_first_entry(self): ... + def parse_block_sequence_entry(self): ... + def parse_indentless_sequence_entry(self): ... + def parse_block_mapping_first_key(self): ... + def parse_block_mapping_key(self): ... + def parse_block_mapping_value(self): ... + def parse_flow_sequence_first_entry(self): ... + def parse_flow_sequence_entry(self, first: bool = False): ... + def parse_flow_sequence_entry_mapping_key(self): ... + def parse_flow_sequence_entry_mapping_value(self): ... + def parse_flow_sequence_entry_mapping_end(self): ... + def parse_flow_mapping_first_key(self): ... + def parse_flow_mapping_key(self, first: bool = False): ... + def parse_flow_mapping_value(self): ... + def parse_flow_mapping_empty_value(self): ... + def process_empty_scalar(self, mark, comment: Incomplete | None = None): ... + def move_token_comment(self, token, nt: Incomplete = None, empty: bool | None = False): ... class RoundTripParser(Parser): def select_tag_transform(self, tag: Tag) -> None: ... - def move_token_comment(self, token: Any, nt: Any | None = None, empty: bool | None = False) -> Any: ... + def move_token_comment(self, token, nt: Incomplete = None, empty: bool | None = False): ... class RoundTripParserSC(RoundTripParser): - def move_token_comment(self, token: Any, nt: Any = None, empty: bool | None = False) -> None: ... - def distribute_comment(self, comment: Any, line: Any) -> Any: ... + def move_token_comment(self, token, nt: Incomplete | None = None, empty: bool | None = False) -> None: ... + def distribute_comment(self, comment, line): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/reader.pyi b/stubs/ruamel.yaml/ruamel/yaml/reader.pyi index e0bbe7f5bba4..4a2cfb61ff6f 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/reader.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/reader.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any from ruamel.yaml.error import YAMLError @@ -11,11 +10,11 @@ class ReaderError(YAMLError): position: Incomplete encoding: Incomplete reason: Incomplete - def __init__(self, name: Any, position: Any, character: Any, encoding: Any, reason: Any) -> None: ... + def __init__(self, name, position, character, encoding, reason) -> None: ... class Reader: loader: Incomplete - def __init__(self, stream: Any, loader: Any = None) -> None: ... + def __init__(self, stream, loader: Incomplete | None = None) -> None: ... name: Incomplete stream_pointer: int eof: bool @@ -29,16 +28,16 @@ class Reader: column: int def reset_reader(self) -> None: ... @property - def stream(self) -> Any: ... + def stream(self): ... @stream.setter - def stream(self, val: Any) -> None: ... + def stream(self, val) -> None: ... def peek(self, index: int = 0) -> str: ... - def prefix(self, length: int = 1) -> Any: ... + def prefix(self, length: int = 1): ... def forward_1_1(self, length: int = 1) -> None: ... def forward(self, length: int = 1) -> None: ... - def get_mark(self) -> Any: ... + def get_mark(self): ... def determine_encoding(self) -> None: ... NON_PRINTABLE: Incomplete - def check_printable(self, data: Any) -> None: ... + def check_printable(self, data) -> None: ... def update(self, length: int) -> None: ... def update_raw(self, size: int | None = None) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi index 802c57ccaaf1..df38972fe446 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any from ruamel.yaml.error import * from ruamel.yaml.nodes import * @@ -9,8 +8,8 @@ __all__ = ["BaseRepresenter", "SafeRepresenter", "Representer", "RepresenterErro class RepresenterError(YAMLError): ... class BaseRepresenter: - yaml_representers: dict[Any, Any] - yaml_multi_representers: dict[Any, Any] + yaml_representers: dict + yaml_multi_representers: dict dumper: Incomplete default_style: Incomplete default_flow_style: Incomplete @@ -18,74 +17,84 @@ class BaseRepresenter: object_keeper: Incomplete alias_key: Incomplete sort_base_mapping_type_on_output: bool - def __init__(self, default_style: Any = None, default_flow_style: Any = None, dumper: Any = None) -> None: ... + def __init__( + self, + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, + dumper: Incomplete | None = None, + ) -> None: ... @property - def serializer(self) -> Any: ... - def represent(self, data: Any) -> None: ... - def represent_data(self, data: Any) -> Any: ... - def represent_key(self, data: Any) -> Any: ... + def serializer(self): ... + def represent(self, data) -> None: ... + def represent_data(self, data): ... + def represent_key(self, data): ... @classmethod - def add_representer(cls, data_type: Any, representer: Any) -> None: ... + def add_representer(cls, data_type, representer) -> None: ... @classmethod - def add_multi_representer(cls, data_type: Any, representer: Any) -> None: ... - def represent_scalar(self, tag: Any, value: Any, style: Any = None, anchor: Any = None) -> ScalarNode: ... - def represent_sequence(self, tag: Any, sequence: Any, flow_style: Any = None) -> SequenceNode: ... - def represent_omap(self, tag: Any, omap: Any, flow_style: Any = None) -> SequenceNode: ... - def represent_mapping(self, tag: Any, mapping: Any, flow_style: Any = None) -> MappingNode: ... - def ignore_aliases(self, data: Any) -> bool: ... + def add_multi_representer(cls, data_type, representer) -> None: ... + def represent_scalar(self, tag, value, style: Incomplete | None = None, anchor: Incomplete | None = None) -> ScalarNode: ... + def represent_sequence(self, tag, sequence, flow_style: Incomplete | None = None) -> SequenceNode: ... + def represent_omap(self, tag, omap, flow_style: Incomplete | None = None) -> SequenceNode: ... + def represent_mapping(self, tag, mapping, flow_style: Incomplete | None = None) -> MappingNode: ... + def ignore_aliases(self, data) -> bool: ... class SafeRepresenter(BaseRepresenter): - def ignore_aliases(self, data: Any) -> bool: ... - def represent_none(self, data: Any) -> ScalarNode: ... - def represent_str(self, data: Any) -> Any: ... - def represent_binary(self, data: Any) -> ScalarNode: ... - def represent_bool(self, data: Any, anchor: Any | None = None) -> ScalarNode: ... - def represent_int(self, data: Any) -> ScalarNode: ... + def ignore_aliases(self, data) -> bool: ... + def represent_none(self, data) -> ScalarNode: ... + def represent_str(self, data): ... + def represent_binary(self, data) -> ScalarNode: ... + def represent_bool(self, data, anchor: Incomplete = None) -> ScalarNode: ... + def represent_int(self, data) -> ScalarNode: ... inf_value: float - def represent_float(self, data: Any) -> ScalarNode: ... - def represent_list(self, data: Any) -> SequenceNode: ... - def represent_dict(self, data: Any) -> MappingNode: ... - def represent_ordereddict(self, data: Any) -> SequenceNode: ... - def represent_set(self, data: Any) -> MappingNode: ... - def represent_date(self, data: Any) -> ScalarNode: ... - def represent_datetime(self, data: Any) -> ScalarNode: ... - def represent_yaml_object(self, tag: Any, data: Any, cls: Any, flow_style: Any = None) -> MappingNode: ... - def represent_undefined(self, data: Any) -> None: ... + def represent_float(self, data) -> ScalarNode: ... + def represent_list(self, data) -> SequenceNode: ... + def represent_dict(self, data) -> MappingNode: ... + def represent_ordereddict(self, data) -> SequenceNode: ... + def represent_set(self, data) -> MappingNode: ... + def represent_date(self, data) -> ScalarNode: ... + def represent_datetime(self, data) -> ScalarNode: ... + def represent_yaml_object(self, tag, data, cls, flow_style: Incomplete | None = None) -> MappingNode: ... + def represent_undefined(self, data) -> None: ... class Representer(SafeRepresenter): - def represent_complex(self, data: Any) -> Any: ... - def represent_tuple(self, data: Any) -> SequenceNode: ... - def represent_name(self, data: Any) -> ScalarNode: ... - def represent_module(self, data: Any) -> ScalarNode: ... - def represent_object(self, data: Any) -> SequenceNode | MappingNode: ... + def represent_complex(self, data): ... + def represent_tuple(self, data) -> SequenceNode: ... + def represent_name(self, data) -> ScalarNode: ... + def represent_module(self, data) -> ScalarNode: ... + def represent_object(self, data) -> SequenceNode | MappingNode: ... class RoundTripRepresenter(SafeRepresenter): - def __init__(self, default_style: Any = None, default_flow_style: Any = None, dumper: Any = None) -> None: ... - def ignore_aliases(self, data: Any) -> bool: ... - def represent_none(self, data: Any) -> ScalarNode: ... - def represent_literal_scalarstring(self, data: Any) -> ScalarNode: ... + def __init__( + self, + default_style: Incomplete | None = None, + default_flow_style: Incomplete | None = None, + dumper: Incomplete | None = None, + ) -> None: ... + def ignore_aliases(self, data) -> bool: ... + def represent_none(self, data) -> ScalarNode: ... + def represent_literal_scalarstring(self, data) -> ScalarNode: ... represent_preserved_scalarstring = represent_literal_scalarstring - def represent_folded_scalarstring(self, data: Any) -> ScalarNode: ... - def represent_single_quoted_scalarstring(self, data: Any) -> ScalarNode: ... - def represent_double_quoted_scalarstring(self, data: Any) -> ScalarNode: ... - def represent_plain_scalarstring(self, data: Any) -> ScalarNode: ... - def insert_underscore(self, prefix: Any, s: Any, underscore: Any, anchor: Any = None) -> ScalarNode: ... - def represent_scalar_int(self, data: Any) -> ScalarNode: ... - def represent_binary_int(self, data: Any) -> ScalarNode: ... - def represent_octal_int(self, data: Any) -> ScalarNode: ... - def represent_hex_int(self, data: Any) -> ScalarNode: ... - def represent_hex_caps_int(self, data: Any) -> ScalarNode: ... - def represent_scalar_float(self, data: Any) -> ScalarNode: ... - def represent_sequence(self, tag: Any, sequence: Any, flow_style: Any = None) -> SequenceNode: ... - def merge_comments(self, node: Any, comments: Any) -> Any: ... + def represent_folded_scalarstring(self, data) -> ScalarNode: ... + def represent_single_quoted_scalarstring(self, data) -> ScalarNode: ... + def represent_double_quoted_scalarstring(self, data) -> ScalarNode: ... + def represent_plain_scalarstring(self, data) -> ScalarNode: ... + def insert_underscore(self, prefix, s, underscore, anchor: Incomplete | None = None) -> ScalarNode: ... + def represent_scalar_int(self, data) -> ScalarNode: ... + def represent_binary_int(self, data) -> ScalarNode: ... + def represent_octal_int(self, data) -> ScalarNode: ... + def represent_hex_int(self, data) -> ScalarNode: ... + def represent_hex_caps_int(self, data) -> ScalarNode: ... + def represent_scalar_float(self, data) -> ScalarNode: ... + def represent_sequence(self, tag, sequence, flow_style: Incomplete | None = None) -> SequenceNode: ... + def merge_comments(self, node, comments): ... alias_key: Incomplete - def represent_key(self, data: Any) -> Any: ... - def represent_mapping(self, tag: Any, mapping: Any, flow_style: Any = None) -> MappingNode: ... - def represent_omap(self, tag: Any, omap: Any, flow_style: Any = None) -> SequenceNode: ... - def represent_set(self, setting: Any) -> MappingNode: ... - def represent_dict(self, data: Any) -> MappingNode: ... - def represent_list(self, data: Any) -> SequenceNode: ... - def represent_datetime(self, data: Any) -> ScalarNode: ... - def represent_tagged_scalar(self, data: Any) -> ScalarNode: ... - def represent_scalar_bool(self, data: Any) -> ScalarNode: ... - def represent_yaml_object(self, tag: Any, data: Any, cls: Any, flow_style: Any | None = None) -> MappingNode: ... + def represent_key(self, data): ... + def represent_mapping(self, tag, mapping, flow_style: Incomplete | None = None) -> MappingNode: ... + def represent_omap(self, tag, omap, flow_style: Incomplete | None = None) -> SequenceNode: ... + def represent_set(self, setting) -> MappingNode: ... + def represent_dict(self, data) -> MappingNode: ... + def represent_list(self, data) -> SequenceNode: ... + def represent_datetime(self, data) -> ScalarNode: ... + def represent_tagged_scalar(self, data) -> ScalarNode: ... + def represent_scalar_bool(self, data) -> ScalarNode: ... + def represent_yaml_object(self, tag, data, cls, flow_style: Incomplete = None) -> MappingNode: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi index ea35ef3472dc..db138d02b27d 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any from ruamel.yaml.compat import VersionType from ruamel.yaml.error import * @@ -12,35 +11,37 @@ class BaseResolver: DEFAULT_SCALAR_TAG: Incomplete DEFAULT_SEQUENCE_TAG: Incomplete DEFAULT_MAPPING_TAG: Incomplete - yaml_implicit_resolvers: dict[Any, Any] - yaml_path_resolvers: dict[Any, Any] + yaml_implicit_resolvers: dict + yaml_path_resolvers: dict loadumper: Incomplete resolver_exact_paths: Incomplete resolver_prefix_paths: Incomplete - def __init__(self, loadumper: Any = None) -> None: ... + def __init__(self, loadumper: Incomplete | None = None) -> None: ... @property - def parser(self) -> Any: ... + def parser(self): ... @classmethod - def add_implicit_resolver_base(cls, tag: Any, regexp: Any, first: Any) -> None: ... + def add_implicit_resolver_base(cls, tag, regexp, first) -> None: ... @classmethod - def add_implicit_resolver(cls, tag: Any, regexp: Any, first: Any) -> None: ... + def add_implicit_resolver(cls, tag, regexp, first) -> None: ... @classmethod - def add_path_resolver(cls, tag: Any, path: Any, kind: Any = None) -> None: ... - def descend_resolver(self, current_node: Any, current_index: Any) -> None: ... + def add_path_resolver(cls, tag, path, kind: Incomplete | None = None) -> None: ... + def descend_resolver(self, current_node, current_index) -> None: ... def ascend_resolver(self) -> None: ... - def check_resolver_prefix(self, depth: int, path: Any, kind: Any, current_node: Any, current_index: Any) -> bool: ... - def resolve(self, kind: Any, value: Any, implicit: Any) -> Any: ... + def check_resolver_prefix(self, depth: int, path, kind, current_node, current_index) -> bool: ... + def resolve(self, kind, value, implicit): ... @property - def processing_version(self) -> Any: ... + def processing_version(self) -> None: ... class Resolver(BaseResolver): ... class VersionedResolver(BaseResolver): - def __init__(self, version: VersionType | None = None, loader: Any = None, loadumper: Any = None) -> None: ... - def add_version_implicit_resolver(self, version: VersionType, tag: Any, regexp: Any, first: Any) -> None: ... - def get_loader_version(self, version: VersionType | None) -> Any: ... + def __init__( + self, version: VersionType | None = None, loader: Incomplete | None = None, loadumper: Incomplete | None = None + ) -> None: ... + def add_version_implicit_resolver(self, version: VersionType, tag, regexp, first) -> None: ... + def get_loader_version(self, version: VersionType | None): ... @property - def versioned_resolver(self) -> Any: ... - def resolve(self, kind: Any, value: Any, implicit: Any) -> Any: ... + def versioned_resolver(self): ... + def resolve(self, kind, value, implicit): ... @property - def processing_version(self) -> Any: ... + def processing_version(self): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi index b16a4cb1e41d..a7502d1126a6 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi @@ -1,10 +1,8 @@ -from typing import Any - __all__ = ["ScalarBoolean"] class ScalarBoolean(int): - def __new__(cls, *args: Any, **kw: Any) -> Any: ... + def __new__(cls, *args, **kw): ... @property - def anchor(self) -> Any: ... - def yaml_anchor(self, any: bool = False) -> Any: ... - def yaml_set_anchor(self, value: Any, always_dump: bool = False) -> None: ... + def anchor(self): ... + def yaml_anchor(self, any: bool = False): ... + def yaml_set_anchor(self, value, always_dump: bool = False) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi index a5f40cba62b6..49b306403f4a 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi @@ -1,22 +1,22 @@ -from typing import Any +from _typeshed import Incomplete __all__ = ["ScalarFloat", "ExponentialFloat", "ExponentialCapsFloat"] class ScalarFloat(float): - def __new__(cls, *args: Any, **kw: Any) -> Any: ... - def __iadd__(self, a: Any) -> Any: ... - def __ifloordiv__(self, a: Any) -> Any: ... - def __imul__(self, a: Any) -> Any: ... - def __ipow__(self, a: Any) -> Any: ... - def __isub__(self, a: Any) -> Any: ... + def __new__(cls, *args, **kw): ... + def __iadd__(self, a): ... + def __ifloordiv__(self, a): ... + def __imul__(self, a): ... + def __ipow__(self, a): ... + def __isub__(self, a): ... @property - def anchor(self) -> Any: ... - def yaml_anchor(self, any: bool = False) -> Any: ... - def yaml_set_anchor(self, value: Any, always_dump: bool = False) -> None: ... - def dump(self, out: Any = ...) -> None: ... + def anchor(self): ... + def yaml_anchor(self, any: bool = False): ... + def yaml_set_anchor(self, value, always_dump: bool = False) -> None: ... + def dump(self, out=...) -> None: ... class ExponentialFloat(ScalarFloat): - def __new__(cls, value: Any, width: Any = None, underscore: Any = None) -> Any: ... + def __new__(cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None): ... class ExponentialCapsFloat(ScalarFloat): - def __new__(cls, value: Any, width: Any = None, underscore: Any = None) -> Any: ... + def __new__(cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi index 9ae877b7040d..3d9b8fbe2ced 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi @@ -1,30 +1,40 @@ -from typing import Any +from _typeshed import Incomplete __all__ = ["ScalarInt", "BinaryInt", "OctalInt", "HexInt", "HexCapsInt", "DecimalInt"] class ScalarInt(int): - def __new__(cls, *args: Any, **kw: Any) -> Any: ... - def __iadd__(self, a: Any) -> Any: ... - def __ifloordiv__(self, a: Any) -> Any: ... - def __imul__(self, a: Any) -> Any: ... - def __ipow__(self, a: Any) -> Any: ... - def __isub__(self, a: Any) -> Any: ... + def __new__(cls, *args, **kw): ... + def __iadd__(self, a): ... + def __ifloordiv__(self, a): ... + def __imul__(self, a): ... + def __ipow__(self, a): ... + def __isub__(self, a): ... @property - def anchor(self) -> Any: ... - def yaml_anchor(self, any: bool = False) -> Any: ... - def yaml_set_anchor(self, value: Any, always_dump: bool = False) -> None: ... + def anchor(self): ... + def yaml_anchor(self, any: bool = False): ... + def yaml_set_anchor(self, value, always_dump: bool = False) -> None: ... class BinaryInt(ScalarInt): - def __new__(cls, value: Any, width: Any = None, underscore: Any = None, anchor: Any = None) -> Any: ... + def __new__( + cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None, anchor: Incomplete | None = None + ): ... class OctalInt(ScalarInt): - def __new__(cls, value: Any, width: Any = None, underscore: Any = None, anchor: Any = None) -> Any: ... + def __new__( + cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None, anchor: Incomplete | None = None + ): ... class HexInt(ScalarInt): - def __new__(cls, value: Any, width: Any = None, underscore: Any = None, anchor: Any = None) -> Any: ... + def __new__( + cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None, anchor: Incomplete | None = None + ): ... class HexCapsInt(ScalarInt): - def __new__(cls, value: Any, width: Any = None, underscore: Any = None, anchor: Any = None) -> Any: ... + def __new__( + cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None, anchor: Incomplete | None = None + ): ... class DecimalInt(ScalarInt): - def __new__(cls, value: Any, width: Any = None, underscore: Any = None, anchor: Any = None) -> Any: ... + def __new__( + cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None, anchor: Incomplete | None = None + ): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi index 4513ecda53ae..791cd54f0a94 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi @@ -1,4 +1,4 @@ -from typing import Any +from _typeshed import Incomplete from ruamel.yaml.compat import SupportsIndex @@ -13,31 +13,31 @@ __all__ = [ ] class ScalarString(str): - def __new__(cls, *args: Any, **kw: Any) -> Any: ... - def replace(self, old: Any, new: Any, maxreplace: SupportsIndex = -1) -> Any: ... + def __new__(cls, *args, **kw): ... + def replace(self, old, new, maxreplace: SupportsIndex = -1): ... @property - def anchor(self) -> Any: ... - def yaml_anchor(self, any: bool = False) -> Any: ... - def yaml_set_anchor(self, value: Any, always_dump: bool = False) -> None: ... + def anchor(self): ... + def yaml_anchor(self, any: bool = False): ... + def yaml_set_anchor(self, value, always_dump: bool = False) -> None: ... class LiteralScalarString(ScalarString): style: str - def __new__(cls, value: str, anchor: Any = None) -> Any: ... + def __new__(cls, value: str, anchor: Incomplete | None = None): ... PreservedScalarString = LiteralScalarString class FoldedScalarString(ScalarString): style: str - def __new__(cls, value: str, anchor: Any = None) -> Any: ... + def __new__(cls, value: str, anchor: Incomplete | None = None): ... class SingleQuotedScalarString(ScalarString): style: str - def __new__(cls, value: str, anchor: Any = None) -> Any: ... + def __new__(cls, value: str, anchor: Incomplete | None = None): ... class DoubleQuotedScalarString(ScalarString): style: str - def __new__(cls, value: str, anchor: Any = None) -> Any: ... + def __new__(cls, value: str, anchor: Incomplete | None = None): ... class PlainScalarString(ScalarString): style: str - def __new__(cls, value: str, anchor: Any = None) -> Any: ... + def __new__(cls, value: str, anchor: Incomplete | None = None): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi index b1448594a7c6..4726bcbf17c1 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing import Any +from collections.abc import Generator from ruamel.yaml.error import MarkedYAMLError from ruamel.yaml.tokens import * @@ -15,12 +15,12 @@ class SimpleKey: line: Incomplete column: Incomplete mark: Incomplete - def __init__(self, token_number: Any, required: Any, index: int, line: int, column: int, mark: Any) -> None: ... + def __init__(self, token_number, required, index: int, line: int, column: int, mark) -> None: ... class Scanner: loader: Incomplete first_time: bool - def __init__(self, loader: Any = None) -> None: ... + def __init__(self, loader: Incomplete | None = None) -> None: ... @property def flow_level(self) -> int: ... done: bool @@ -35,33 +35,33 @@ class Scanner: tag_directives: Incomplete def reset_scanner(self) -> None: ... @property - def reader(self) -> Any: ... + def reader(self): ... @property - def scanner_processing_version(self) -> Any: ... - def check_token(self, *choices: Any) -> bool: ... - def peek_token(self) -> Any: ... - def get_token(self) -> Any: ... + def scanner_processing_version(self): ... + def check_token(self, *choices) -> bool: ... + def peek_token(self): ... + def get_token(self): ... def need_more_tokens(self) -> bool: ... - def fetch_comment(self, comment: Any) -> None: ... - def fetch_more_tokens(self) -> Any: ... - def next_possible_simple_key(self) -> Any: ... + def fetch_comment(self, comment) -> None: ... + def fetch_more_tokens(self): ... + def next_possible_simple_key(self): ... def stale_possible_simple_keys(self) -> None: ... def save_possible_simple_key(self) -> None: ... def remove_possible_simple_key(self) -> None: ... - def unwind_indent(self, column: Any) -> None: ... + def unwind_indent(self, column) -> None: ... def add_indent(self, column: int) -> bool: ... def fetch_stream_start(self) -> None: ... def fetch_stream_end(self) -> None: ... def fetch_directive(self) -> None: ... def fetch_document_start(self) -> None: ... def fetch_document_end(self) -> None: ... - def fetch_document_indicator(self, TokenClass: Any) -> None: ... + def fetch_document_indicator(self, TokenClass) -> None: ... def fetch_flow_sequence_start(self) -> None: ... def fetch_flow_mapping_start(self) -> None: ... - def fetch_flow_collection_start(self, TokenClass: Any, to_push: str) -> None: ... + def fetch_flow_collection_start(self, TokenClass, to_push: str) -> None: ... def fetch_flow_sequence_end(self) -> None: ... def fetch_flow_mapping_end(self) -> None: ... - def fetch_flow_collection_end(self, TokenClass: Any) -> None: ... + def fetch_flow_collection_end(self, TokenClass) -> None: ... def fetch_flow_entry(self) -> None: ... def fetch_block_entry(self) -> None: ... def fetch_key(self) -> None: ... @@ -71,57 +71,57 @@ class Scanner: def fetch_tag(self) -> None: ... def fetch_literal(self) -> None: ... def fetch_folded(self) -> None: ... - def fetch_block_scalar(self, style: Any) -> None: ... + def fetch_block_scalar(self, style) -> None: ... def fetch_single(self) -> None: ... def fetch_double(self) -> None: ... - def fetch_flow_scalar(self, style: Any) -> None: ... + def fetch_flow_scalar(self, style) -> None: ... def fetch_plain(self) -> None: ... - def check_directive(self) -> Any: ... - def check_document_start(self) -> Any: ... - def check_document_end(self) -> Any: ... - def check_block_entry(self) -> Any: ... - def check_key(self) -> Any: ... - def check_value(self) -> Any: ... - def check_plain(self) -> Any: ... - def scan_to_next_token(self) -> Any: ... - def scan_directive(self) -> Any: ... - def scan_directive_name(self, start_mark: Any) -> Any: ... - def scan_yaml_directive_value(self, start_mark: Any) -> Any: ... - def scan_yaml_directive_number(self, start_mark: Any) -> Any: ... - def scan_tag_directive_value(self, start_mark: Any) -> Any: ... - def scan_tag_directive_handle(self, start_mark: Any) -> Any: ... - def scan_tag_directive_prefix(self, start_mark: Any) -> Any: ... - def scan_directive_ignored_line(self, start_mark: Any) -> None: ... - def scan_anchor(self, TokenClass: Any) -> Any: ... - def scan_tag(self) -> Any: ... - def scan_block_scalar(self, style: Any, rt: bool | None = False) -> Any: ... - def scan_block_scalar_indicators(self, start_mark: Any) -> Any: ... - def scan_block_scalar_ignored_line(self, start_mark: Any) -> Any: ... - def scan_block_scalar_indentation(self) -> Any: ... - def scan_block_scalar_breaks(self, indent: int) -> Any: ... - def scan_flow_scalar(self, style: Any) -> Any: ... + def check_directive(self): ... + def check_document_start(self): ... + def check_document_end(self): ... + def check_block_entry(self): ... + def check_key(self): ... + def check_value(self): ... + def check_plain(self): ... + def scan_to_next_token(self) -> None: ... + def scan_directive(self): ... + def scan_directive_name(self, start_mark): ... + def scan_yaml_directive_value(self, start_mark): ... + def scan_yaml_directive_number(self, start_mark): ... + def scan_tag_directive_value(self, start_mark): ... + def scan_tag_directive_handle(self, start_mark): ... + def scan_tag_directive_prefix(self, start_mark): ... + def scan_directive_ignored_line(self, start_mark) -> None: ... + def scan_anchor(self, TokenClass): ... + def scan_tag(self): ... + def scan_block_scalar(self, style, rt: bool | None = False): ... + def scan_block_scalar_indicators(self, start_mark): ... + def scan_block_scalar_ignored_line(self, start_mark): ... + def scan_block_scalar_indentation(self): ... + def scan_block_scalar_breaks(self, indent: int): ... + def scan_flow_scalar(self, style): ... ESCAPE_REPLACEMENTS: Incomplete ESCAPE_CODES: Incomplete - def scan_flow_scalar_non_spaces(self, double: Any, start_mark: Any) -> Any: ... - def scan_flow_scalar_spaces(self, double: Any, start_mark: Any) -> Any: ... - def scan_flow_scalar_breaks(self, double: Any, start_mark: Any) -> Any: ... - def scan_plain(self) -> Any: ... - def scan_plain_spaces(self, indent: Any, start_mark: Any) -> Any: ... - def scan_tag_handle(self, name: Any, start_mark: Any) -> Any: ... - def scan_tag_uri(self, name: Any, start_mark: Any) -> Any: ... - def scan_uri_escapes(self, name: Any, start_mark: Any) -> Any: ... - def scan_line_break(self) -> Any: ... + def scan_flow_scalar_non_spaces(self, double, start_mark): ... + def scan_flow_scalar_spaces(self, double, start_mark): ... + def scan_flow_scalar_breaks(self, double, start_mark): ... + def scan_plain(self): ... + def scan_plain_spaces(self, indent, start_mark): ... + def scan_tag_handle(self, name, start_mark): ... + def scan_tag_uri(self, name, start_mark): ... + def scan_uri_escapes(self, name, start_mark): ... + def scan_line_break(self): ... class RoundTripScanner(Scanner): - def check_token(self, *choices: Any) -> bool: ... - def peek_token(self) -> Any: ... - def get_token(self) -> Any: ... - def fetch_comment(self, comment: Any) -> None: ... + def check_token(self, *choices) -> bool: ... + def peek_token(self): ... + def get_token(self): ... + def fetch_comment(self, comment) -> None: ... allow_simple_key: bool - def scan_to_next_token(self) -> Any: ... + def scan_to_next_token(self): ... def scan_line_break(self, empty_line: bool = False) -> str: ... - def scan_block_scalar(self, style: Any, rt: bool | None = True) -> Any: ... - def scan_uri_escapes(self, name: Any, start_mark: Any) -> Any: ... + def scan_block_scalar(self, style, rt: bool | None = True): ... + def scan_uri_escapes(self, name, start_mark): ... class CommentBase: value: Incomplete @@ -132,45 +132,45 @@ class CommentBase: fline: Incomplete ufun: Incomplete uline: Incomplete - def __init__(self, value: Any, line: Any, column: Any) -> None: ... - def set_used(self, v: Any = "+") -> None: ... + def __init__(self, value, line, column) -> None: ... + def set_used(self, v: str = "+") -> None: ... def set_assigned(self) -> None: ... def info(self) -> str: ... class EOLComment(CommentBase): name: str - def __init__(self, value: Any, line: Any, column: Any) -> None: ... + def __init__(self, value, line, column) -> None: ... class FullLineComment(CommentBase): name: str - def __init__(self, value: Any, line: Any, column: Any) -> None: ... + def __init__(self, value, line, column) -> None: ... class BlankLineComment(CommentBase): name: str - def __init__(self, value: Any, line: Any, column: Any) -> None: ... + def __init__(self, value, line, column) -> None: ... class ScannedComments: comments: Incomplete unused: Incomplete def __init__(self) -> None: ... - def add_eol_comment(self, comment: Any, column: Any, line: Any) -> Any: ... - def add_blank_line(self, comment: Any, column: Any, line: Any) -> Any: ... - def add_full_line_comment(self, comment: Any, column: Any, line: Any) -> Any: ... - def __getitem__(self, idx: Any) -> Any: ... + def add_eol_comment(self, comment, column, line): ... + def add_blank_line(self, comment, column, line): ... + def add_full_line_comment(self, comment, column, line): ... + def __getitem__(self, idx): ... def last(self) -> str: ... def any_unprocessed(self) -> bool: ... - def unprocessed(self, use: Any = False) -> Any: ... - def assign_pre(self, token: Any) -> Any: ... - def assign_eol(self, tokens: Any) -> Any: ... - def assign_post(self, token: Any) -> Any: ... - def str_unprocessed(self) -> Any: ... + def unprocessed(self, use: bool = False) -> Generator[Incomplete, None, None]: ... + def assign_pre(self, token): ... + def assign_eol(self, tokens) -> None: ... + def assign_post(self, token): ... + def str_unprocessed(self): ... class RoundTripScannerSC(Scanner): comments: Incomplete - def __init__(self, *arg: Any, **kw: Any) -> None: ... - def get_token(self) -> Any: ... + def __init__(self, *arg, **kw) -> None: ... + def get_token(self): ... def need_more_tokens(self) -> bool: ... allow_simple_key: bool def scan_to_next_token(self) -> None: ... def scan_empty_or_full_line_comments(self) -> None: ... - def scan_block_scalar_ignored_line(self, start_mark: Any) -> Any: ... + def scan_block_scalar_ignored_line(self, start_mark) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi b/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi index 7345d8131f2a..79c63b8f89aa 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any from ruamel.yaml.compat import VersionType from ruamel.yaml.error import YAMLError @@ -23,20 +22,20 @@ class Serializer: closed: Incomplete def __init__( self, - encoding: Any = None, + encoding: Incomplete | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, version: VersionType | None = None, - tags: Any = None, - dumper: Any = None, + tags: Incomplete | None = None, + dumper: Incomplete | None = None, ) -> None: ... @property - def emitter(self) -> Any: ... + def emitter(self): ... @property - def resolver(self) -> Any: ... + def resolver(self): ... def open(self) -> None: ... def close(self) -> None: ... - def serialize(self, node: Any) -> None: ... - def anchor_node(self, node: Any) -> None: ... - def generate_anchor(self, node: Any) -> Any: ... - def serialize_node(self, node: Any, parent: Any, index: Any) -> None: ... + def serialize(self, node) -> None: ... + def anchor_node(self, node) -> None: ... + def generate_anchor(self, node): ... + def serialize_node(self, node, parent, index) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/tag.pyi b/stubs/ruamel.yaml/ruamel/yaml/tag.pyi index 9218d896141c..d253d8a75dc5 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/tag.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/tag.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any tag_attrib: str @@ -8,9 +7,11 @@ class Tag: handle: Incomplete suffix: Incomplete handles: Incomplete - def __init__(self, handle: Any = None, suffix: Any = None, handles: Any = None) -> None: ... + def __init__( + self, handle: Incomplete | None = None, suffix: Incomplete | None = None, handles: Incomplete | None = None + ) -> None: ... def __hash__(self) -> int: ... - def __eq__(self, other: object) -> bool: ... + def __eq__(self, other) -> bool: ... def startswith(self, x: str) -> bool: ... @property def trval(self) -> str | None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi b/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi index df55f2df380a..2d6e474073d6 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi @@ -1,19 +1,19 @@ import datetime -from typing import Any +from _typeshed import Incomplete class TimeStamp(datetime.datetime): - def __init__(self, *args: Any, **kw: Any) -> None: ... - def __new__(cls, *args: Any, **kw: Any) -> Any: ... - def __deepcopy__(self, memo: Any) -> Any: ... + def __init__(self, *args, **kw) -> None: ... + def __new__(cls, *args, **kw): ... + def __deepcopy__(self, memo): ... def replace( self, - year: Any = None, - month: Any = None, - day: Any = None, - hour: Any = None, - minute: Any = None, - second: Any = None, - microsecond: Any = None, - tzinfo: Any = True, - fold: Any = None, - ) -> Any: ... + year: Incomplete | None = None, + month: Incomplete | None = None, + day: Incomplete | None = None, + hour: Incomplete | None = None, + minute: Incomplete | None = None, + second: Incomplete | None = None, + microsecond: Incomplete | None = None, + tzinfo: bool = True, + fold: Incomplete | None = None, + ): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi index 17b17b39f0ed..7d2be62b6abd 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Any from ruamel.yaml.compat import nprintf as nprintf @@ -14,23 +13,23 @@ class Token: @property def column(self) -> int: ... @column.setter - def column(self, pos: Any) -> None: ... - def add_post_comment(self, comment: Any) -> None: ... - def add_pre_comments(self, comments: Any) -> None: ... - def add_comment_pre(self, comment: Any) -> None: ... - def add_comment_eol(self, comment: Any, comment_type: Any) -> None: ... - def add_comment_post(self, comment: Any) -> None: ... + def column(self, pos) -> None: ... + def add_post_comment(self, comment) -> None: ... + def add_pre_comments(self, comments) -> None: ... + def add_comment_pre(self, comment) -> None: ... + def add_comment_eol(self, comment, comment_type) -> None: ... + def add_comment_post(self, comment) -> None: ... @property - def comment(self) -> Any: ... - def move_old_comment(self, target: Any, empty: bool = False) -> Any: ... - def split_old_comment(self) -> Any: ... - def move_new_comment(self, target: Any, empty: bool = False) -> Any: ... + def comment(self): ... + def move_old_comment(self, target, empty: bool = False): ... + def split_old_comment(self): ... + def move_new_comment(self, target, empty: bool = False): ... class DirectiveToken(Token): id: str name: Incomplete value: Incomplete - def __init__(self, name: Any, value: Any, start_mark: Any, end_mark: Any) -> None: ... + def __init__(self, name, value, start_mark, end_mark) -> None: ... class DocumentStartToken(Token): id: str @@ -41,7 +40,9 @@ class DocumentEndToken(Token): class StreamStartToken(Token): id: str encoding: Incomplete - def __init__(self, start_mark: Any = None, end_mark: Any = None, encoding: Any = None) -> None: ... + def __init__( + self, start_mark: Incomplete | None = None, end_mark: Incomplete | None = None, encoding: Incomplete | None = None + ) -> None: ... class StreamEndToken(Token): id: str @@ -82,32 +83,34 @@ class FlowEntryToken(Token): class AliasToken(Token): id: str value: Incomplete - def __init__(self, value: Any, start_mark: Any, end_mark: Any) -> None: ... + def __init__(self, value, start_mark, end_mark) -> None: ... class AnchorToken(Token): id: str value: Incomplete - def __init__(self, value: Any, start_mark: Any, end_mark: Any) -> None: ... + def __init__(self, value, start_mark, end_mark) -> None: ... class TagToken(Token): id: str value: Incomplete - def __init__(self, value: Any, start_mark: Any, end_mark: Any) -> None: ... + def __init__(self, value, start_mark, end_mark) -> None: ... class ScalarToken(Token): id: str value: Incomplete plain: Incomplete style: Incomplete - def __init__(self, value: Any, plain: Any, start_mark: Any, end_mark: Any, style: Any = None) -> None: ... + def __init__(self, value, plain, start_mark, end_mark, style: Incomplete | None = None) -> None: ... class CommentToken(Token): id: str - def __init__(self, value: Any, start_mark: Any = None, end_mark: Any = None, column: Any = None) -> None: ... + def __init__( + self, value, start_mark: Incomplete | None = None, end_mark: Incomplete | None = None, column: Incomplete | None = None + ) -> None: ... @property def value(self) -> str: ... @value.setter - def value(self, val: Any) -> None: ... + def value(self, val) -> None: ... def reset(self) -> None: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... + def __eq__(self, other) -> bool: ... + def __ne__(self, other) -> bool: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/util.pyi b/stubs/ruamel.yaml/ruamel/yaml/util.pyi index b3a0d2c483b6..d89ce73788d7 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/util.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/util.pyi @@ -1,30 +1,20 @@ import datetime from _typeshed import Incomplete +from collections.abc import Generator from typing import Any, Callable from .compat import StreamTextType as StreamTextType class LazyEval: - def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... - def __getattribute__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... + def __init__(self, func: Callable[..., Any], *args, **kwargs) -> None: ... + def __getattribute__(self, name: str): ... + def __setattr__(self, name: str, value) -> None: ... RegExp: Incomplete timestamp_regexp: Incomplete def create_timestamp( - year: Any, - month: Any, - day: Any, - t: Any, - hour: Any, - minute: Any, - second: Any, - fraction: Any, - tz: Any, - tz_sign: Any, - tz_hour: Any, - tz_minute: Any, + year, month, day, t, hour, minute, second, fraction, tz, tz_sign, tz_hour, tz_minute ) -> datetime.datetime | datetime.date: ... -def load_yaml_guess_indent(stream: StreamTextType, **kw: Any) -> Any: ... -def configobj_walker(cfg: Any) -> Any: ... +def load_yaml_guess_indent(stream: StreamTextType, **kw): ... +def configobj_walker(cfg) -> Generator[Incomplete, None, None]: ... From 4903841bd5c60bc6a8ef83fae4643787f99d8893 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Thu, 22 Aug 2024 06:36:40 +0800 Subject: [PATCH 03/15] Fix some import errors --- stubs/ruamel.yaml/ruamel/yaml/__init__.pyi | 3 +-- stubs/ruamel.yaml/ruamel/yaml/comments.pyi | 4 ++-- stubs/ruamel.yaml/ruamel/yaml/compat.pyi | 4 ++-- stubs/ruamel.yaml/ruamel/yaml/composer.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/constructor.pyi | 13 ++++++------ stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi | 9 ++++---- stubs/ruamel.yaml/ruamel/yaml/dumper.pyi | 10 ++++----- stubs/ruamel.yaml/ruamel/yaml/emitter.pyi | 6 +++--- stubs/ruamel.yaml/ruamel/yaml/loader.pyi | 14 ++++++------- stubs/ruamel.yaml/ruamel/yaml/main.pyi | 21 +++++++------------ stubs/ruamel.yaml/ruamel/yaml/parser.pyi | 8 +++---- stubs/ruamel.yaml/ruamel/yaml/reader.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/representer.pyi | 4 ++-- stubs/ruamel.yaml/ruamel/yaml/resolver.pyi | 4 ++-- .../ruamel.yaml/ruamel/yaml/scalarstring.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/scanner.pyi | 4 ++-- stubs/ruamel.yaml/ruamel/yaml/serializer.pyi | 4 ++-- stubs/ruamel.yaml/ruamel/yaml/tokens.pyi | 3 +-- 18 files changed, 55 insertions(+), 62 deletions(-) diff --git a/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi b/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi index d240323343f7..07d19af2c8ee 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete -from ruamel.yaml.main import * - from .cyaml import * +from .main import * version_info: Incomplete __version__: Incomplete diff --git a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi index d55f208b1f50..6802104ab301 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from collections.abc import Generator, Mapping, MutableSet, Set as AbstractSet, Sized from typing import Any, Iterator -from ruamel.yaml.compat import MutableSliceableSequence, ordereddict -from ruamel.yaml.tag import Tag +from .compat import MutableSliceableSequence, ordereddict +from .tag import Tag __all__ = [ "CommentedSeq", diff --git a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi index b24ad8e13d82..2a95587ac41b 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi @@ -3,10 +3,10 @@ import collections.abc import io from _typeshed import Incomplete from abc import abstractmethod +from collections import OrderedDict from typing import Any -from ordereddict import OrderedDict -from ruamel.yaml.docinfo import Version +from .docinfo import Version SupportsIndex = int StreamType = Any diff --git a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi index 2b3a0040f4ff..c987ac5082a0 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from ruamel.yaml.error import MarkedYAMLError +from .error import MarkedYAMLError __all__ = ["Composer", "ComposerError"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi index 7064c2c478a8..f2ef665576d1 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi @@ -3,13 +3,12 @@ from _typeshed import Incomplete from collections.abc import Generator from typing import Iterator -from ruamel.yaml.comments import * -from ruamel.yaml.comments import CommentedMap, CommentedOrderedMap, CommentedSeq, CommentedSet, TaggedScalar -from ruamel.yaml.error import MarkedYAMLError, MarkedYAMLFutureWarning -from ruamel.yaml.nodes import * -from ruamel.yaml.scalarbool import ScalarBoolean -from ruamel.yaml.timestamp import TimeStamp -from ruamel.yaml.util import timestamp_regexp +from .comments import * +from .comments import CommentedMap, CommentedOrderedMap, CommentedSeq, CommentedSet, TaggedScalar +from .error import MarkedYAMLError, MarkedYAMLFutureWarning +from .nodes import * +from .scalarbool import ScalarBoolean +from .timestamp import TimeStamp __all__ = ["BaseConstructor", "SafeConstructor", "Constructor", "ConstructorError", "RoundTripConstructor"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi b/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi index faf018964430..a2e9ba1dd601 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi @@ -1,10 +1,11 @@ from _typeshed import Incomplete from _ruamel_yaml import CEmitter, CParser -from ruamel.yaml.compat import StreamTextType, VersionType -from ruamel.yaml.constructor import BaseConstructor, Constructor, SafeConstructor -from ruamel.yaml.representer import BaseRepresenter, Representer, SafeRepresenter -from ruamel.yaml.resolver import BaseResolver, Resolver + +from .compat import StreamTextType, VersionType +from .constructor import BaseConstructor, Constructor, SafeConstructor +from .representer import BaseRepresenter, Representer, SafeRepresenter +from .resolver import BaseResolver, Resolver __all__ = ["CBaseLoader", "CSafeLoader", "CLoader", "CBaseDumper", "CSafeDumper", "CDumper"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi index 90449e531483..d28a6e8c7edc 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi @@ -1,10 +1,10 @@ from _typeshed import Incomplete -from ruamel.yaml.compat import StreamType -from ruamel.yaml.emitter import Emitter -from ruamel.yaml.representer import BaseRepresenter, Representer, RoundTripRepresenter, SafeRepresenter -from ruamel.yaml.resolver import BaseResolver, Resolver, VersionedResolver -from ruamel.yaml.serializer import Serializer +from .compat import StreamType +from .emitter import Emitter +from .representer import BaseRepresenter, Representer, RoundTripRepresenter, SafeRepresenter +from .resolver import BaseResolver, Resolver, VersionedResolver +from .serializer import Serializer __all__ = ["BaseDumper", "SafeDumper", "Dumper", "RoundTripDumper"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi index 0bcb964da88d..9064839c264e 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete -from ruamel.yaml.compat import StreamType -from ruamel.yaml.error import YAMLError -from ruamel.yaml.events import * +from .compat import StreamType +from .error import YAMLError +from .events import * __all__ = ["Emitter", "EmitterError"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/loader.pyi b/stubs/ruamel.yaml/ruamel/yaml/loader.pyi index 3272a5a9d18b..cf526a50ec1f 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/loader.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/loader.pyi @@ -1,12 +1,12 @@ from _typeshed import Incomplete -from ruamel.yaml.compat import StreamTextType, VersionType -from ruamel.yaml.composer import Composer -from ruamel.yaml.constructor import BaseConstructor, Constructor, RoundTripConstructor, SafeConstructor -from ruamel.yaml.parser import Parser, RoundTripParser -from ruamel.yaml.reader import Reader -from ruamel.yaml.resolver import VersionedResolver -from ruamel.yaml.scanner import RoundTripScanner, Scanner +from .compat import StreamTextType, VersionType +from .composer import Composer +from .constructor import BaseConstructor, Constructor, RoundTripConstructor, SafeConstructor +from .parser import Parser, RoundTripParser +from .reader import Reader +from .resolver import VersionedResolver +from .scanner import RoundTripScanner, Scanner __all__ = ["BaseLoader", "SafeLoader", "Loader", "RoundTripLoader"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/main.pyi b/stubs/ruamel.yaml/ruamel/yaml/main.pyi index 81c5dcdc4312..9b206404d854 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/main.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/main.pyi @@ -2,19 +2,14 @@ from _typeshed import Incomplete from pathlib import Path from types import TracebackType -from ruamel.yaml.compat import ( - StreamTextType as StreamTextType, - StreamType as StreamType, - VersionType as VersionType, - nprintf as nprintf, -) -from ruamel.yaml.constructor import Constructor -from ruamel.yaml.error import UnsafeLoaderWarning as UnsafeLoaderWarning -from ruamel.yaml.events import * -from ruamel.yaml.nodes import * -from ruamel.yaml.representer import Representer -from ruamel.yaml.resolver import VersionedResolver as VersionedResolver -from ruamel.yaml.tokens import * +from .compat import StreamTextType as StreamTextType, StreamType as StreamType, VersionType as VersionType, nprintf as nprintf +from .constructor import Constructor +from .error import UnsafeLoaderWarning as UnsafeLoaderWarning +from .events import * +from .nodes import * +from .representer import Representer +from .resolver import VersionedResolver as VersionedResolver +from .tokens import * class YAML: typ: Incomplete diff --git a/stubs/ruamel.yaml/ruamel/yaml/parser.pyi b/stubs/ruamel.yaml/ruamel/yaml/parser.pyi index 7ad427ef2c8b..24404d47698b 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/parser.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/parser.pyi @@ -1,9 +1,9 @@ from _typeshed import Incomplete -from ruamel.yaml.error import MarkedYAMLError -from ruamel.yaml.events import * -from ruamel.yaml.tag import Tag -from ruamel.yaml.tokens import * +from .error import MarkedYAMLError +from .events import * +from .tag import Tag +from .tokens import * __all__ = ["Parser", "RoundTripParser", "ParserError"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/reader.pyi b/stubs/ruamel.yaml/ruamel/yaml/reader.pyi index 4a2cfb61ff6f..5894127b229e 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/reader.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/reader.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from ruamel.yaml.error import YAMLError +from .error import YAMLError __all__ = ["Reader", "ReaderError"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi index df38972fe446..e71b1b8a7e4b 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete -from ruamel.yaml.error import * -from ruamel.yaml.nodes import * +from .error import * +from .nodes import * __all__ = ["BaseRepresenter", "SafeRepresenter", "Representer", "RepresenterError", "RoundTripRepresenter"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi index db138d02b27d..02db7d47c839 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete -from ruamel.yaml.compat import VersionType -from ruamel.yaml.error import * +from .compat import VersionType +from .error import * __all__ = ["BaseResolver", "Resolver", "VersionedResolver"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi index 791cd54f0a94..7df59f91949b 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from ruamel.yaml.compat import SupportsIndex +from .compat import SupportsIndex __all__ = [ "ScalarString", diff --git a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi index 4726bcbf17c1..fc4da8bf49f9 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator -from ruamel.yaml.error import MarkedYAMLError -from ruamel.yaml.tokens import * +from .error import MarkedYAMLError +from .tokens import * __all__ = ["Scanner", "RoundTripScanner", "ScannerError"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi b/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi index 79c63b8f89aa..3f9184ec80e3 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete -from ruamel.yaml.compat import VersionType -from ruamel.yaml.error import YAMLError +from .compat import VersionType +from .error import YAMLError __all__ = ["Serializer", "SerializerError"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi index 7d2be62b6abd..67ef20fa839e 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete -from ruamel.yaml.compat import nprintf as nprintf - +from .compat import nprintf as nprintf from .error import StreamMark SHOW_LINES: bool From cd1999359234e6e6409e8788cb56d1eca1d6f5a3 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Sat, 24 Aug 2024 12:16:46 +0000 Subject: [PATCH 04/15] Some initial typing effort --- stubs/ruamel.yaml/ruamel/yaml/__init__.pyi | 6 +- stubs/ruamel.yaml/ruamel/yaml/anchor.pyi | 3 +- stubs/ruamel.yaml/ruamel/yaml/comments.pyi | 11 +- stubs/ruamel.yaml/ruamel/yaml/compat.pyi | 12 +- stubs/ruamel.yaml/ruamel/yaml/composer.pyi | 34 +- stubs/ruamel.yaml/ruamel/yaml/dumper.pyi | 4 + stubs/ruamel.yaml/ruamel/yaml/main.pyi | 349 ++++++++++++++------- 7 files changed, 282 insertions(+), 137 deletions(-) diff --git a/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi b/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi index 07d19af2c8ee..2c7113d49a48 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi @@ -1,8 +1,6 @@ -from _typeshed import Incomplete - from .cyaml import * from .main import * -version_info: Incomplete -__version__: Incomplete +version_info: tuple[int, int, int] +__version__: str __with_libyaml__: bool diff --git a/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi b/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi index 2f61c1540e61..91a0ec14ee6f 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete +from typing import Literal -anchor_attrib: str +anchor_attrib: Literal["_yaml_anchor"] class Anchor: attrib = anchor_attrib diff --git a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi index 6802104ab301..1ef6027d81f7 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Generator, Mapping, MutableSet, Set as AbstractSet, Sized -from typing import Any, Iterator +from typing import Any, Iterator, Literal, NoReturn from .compat import MutableSliceableSequence, ordereddict from .tag import Tag @@ -29,8 +29,10 @@ class IDX: def __init__(self) -> None: ... def __call__(self): ... -comment_attrib: str -merge_attrib: str +comment_attrib: Literal["_yaml_comment"] +format_attrib: Literal["_yaml_format"] +line_col_attrib: Literal["_yaml_line_col"] +merge_attrib: Literal["_yaml_merge"] class Comment: attrib = comment_attrib @@ -157,6 +159,9 @@ class CommentedMap(ordereddict, CommentedBase): def update_key_value(self, key) -> None: ... def __deepcopy__(self, memo): ... +@classmethod +def raise_immutable(cls, *args, **kwargs) -> NoReturn: ... + class CommentedKeyMap(CommentedBase, Mapping): def __init__(self, *args, **kw) -> None: ... __delitem__ = raise_immutable diff --git a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi index 2a95587ac41b..7d3e9e61214a 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi @@ -1,17 +1,17 @@ import abc import collections.abc import io -from _typeshed import Incomplete +from _typeshed import Incomplete, SupportsRead from abc import abstractmethod from collections import OrderedDict -from typing import Any +from typing_extensions import TypeAlias from .docinfo import Version -SupportsIndex = int -StreamType = Any -StreamTextType = StreamType -VersionType = str | tuple[int, int] | list[int] | Version | None +SupportsIndex: TypeAlias = int +StreamType: TypeAlias = str | bytes | SupportsRead[str | bytes] +StreamTextType: TypeAlias = StreamType +VersionType: TypeAlias = str | tuple[int, int] | list[int] | Version | None class ordereddict(OrderedDict): def insert(self, pos: int, key, value) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi index c987ac5082a0..b02bd8f8bc6b 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi @@ -1,27 +1,31 @@ -from _typeshed import Incomplete +from typing import Any from .error import MarkedYAMLError +from .main import YAML +from .nodes import MappingNode, Node, ScalarNode, SequenceNode +from .parser import Parser +from .resolver import BaseResolver __all__ = ["Composer", "ComposerError"] class ComposerError(MarkedYAMLError): ... class Composer: - loader: Incomplete - anchors: Incomplete + loader: YAML + anchors: dict[Any, Node] warn_double_anchors: bool - def __init__(self, loader: Incomplete | None = None) -> None: ... + def __init__(self, loader: YAML | None = None) -> None: ... @property - def parser(self): ... + def parser(self) -> Parser: ... @property - def resolver(self): ... - def check_node(self): ... - def get_node(self): ... - def get_single_node(self): ... - def compose_document(self): ... - def return_alias(self, a): ... - def compose_node(self, parent, index): ... - def compose_scalar_node(self, anchor): ... - def compose_sequence_node(self, anchor): ... - def compose_mapping_node(self, anchor): ... + def resolver(self) -> BaseResolver: ... + def check_node(self) -> bool: ... + def get_node(self) -> Node | None: ... + def get_single_node(self) -> Node | None: ... + def compose_document(self) -> Node | None: ... + def return_alias(self, a: Node | None) -> Node | None: ... + def compose_node(self, parent: Node | None, index: int) -> Node | None: ... + def compose_scalar_node(self, anchor: dict[Any, Node]) -> ScalarNode: ... + def compose_sequence_node(self, anchor: dict[Any, Node]) -> SequenceNode: ... + def compose_mapping_node(self, anchor: dict[Any, Node]) -> MappingNode: ... def check_end_doc_comment(self, end_event, node) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi index d28a6e8c7edc..f9662cba514c 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from typing_extensions import TypeAlias from .compat import StreamType from .emitter import Emitter @@ -8,6 +9,9 @@ from .serializer import Serializer __all__ = ["BaseDumper", "SafeDumper", "Dumper", "RoundTripDumper"] +# https://github.com/python/typeshed/pull/8973 +_Inf: TypeAlias = float + class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): def __init__( self, diff --git a/stubs/ruamel.yaml/ruamel/yaml/main.pyi b/stubs/ruamel.yaml/ruamel/yaml/main.pyi index 9b206404d854..dfb33b0dfe45 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/main.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/main.pyi @@ -1,81 +1,143 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, SupportsWrite from pathlib import Path -from types import TracebackType +from types import ModuleType, TracebackType +from typing import Callable, Final, Literal, NoReturn, Protocol, overload +from typing_extensions import Never, Self, TypeAlias, deprecated +from .comments import CommentedMap, CommentedSeq from .compat import StreamTextType as StreamTextType, StreamType as StreamType, VersionType as VersionType, nprintf as nprintf -from .constructor import Constructor +from .composer import Composer +from .constructor import BaseConstructor, Constructor, RoundTripConstructor +from .docinfo import DocInfo +from .dumper import _Inf +from .emitter import Emitter, RoundTripEmitter from .error import UnsafeLoaderWarning as UnsafeLoaderWarning from .events import * from .nodes import * -from .representer import Representer -from .resolver import VersionedResolver as VersionedResolver +from .parser import Parser, RoundTripParser +from .reader import Reader +from .representer import BaseRepresenter, Representer, RoundTripRepresenter +from .resolver import BaseResolver, VersionedResolver as VersionedResolver +from .scanner import RoundTripScanner, Scanner +from .serializer import Serializer from .tokens import * +_YAMLType: TypeAlias = str | Literal["rt", "safe", "unsafe", "full", "base"] + class YAML: - typ: Incomplete - pure: Incomplete - plug_ins: Incomplete - Resolver: Incomplete + typ: list[_YAMLType] + pure: Final[bool] + plug_ins: list[ModuleType] + Resolver: type[BaseResolver] allow_unicode: bool - Reader: Incomplete - Representer: Incomplete - Constructor: Incomplete - Scanner: Incomplete - Serializer: Incomplete - default_flow_style: Incomplete - comment_handling: Incomplete - Emitter: Incomplete - Parser: Incomplete - Composer: Incomplete - stream: Incomplete - canonical: Incomplete - old_indent: Incomplete - width: Incomplete - line_break: Incomplete - map_indent: Incomplete - sequence_indent: Incomplete + Reader: type[Reader] | None + Representer: type[BaseRepresenter] + Constructor: type[BaseConstructor] + Scanner: type[Scanner] | None + Serializer: type[Serializer] | None + default_flow_style: bool | None + comment_handling: None + Emitter: type[Emitter] # TODO: CEmitter + Parser: type[Parser] # TODO: CParser + Composer: type[Composer] + stream: None + canonical: bool | None + old_indent: int | None + width: int | _Inf | None + line_break: str | None + map_indent: int | None + sequence_indent: int | None sequence_dash_offset: int - compact_seq_seq: Incomplete - compact_seq_map: Incomplete - sort_base_mapping_type_on_output: Incomplete - top_level_colon_align: Incomplete - prefix_colon: Incomplete - preserve_quotes: Incomplete + compact_seq_seq: bool | None + compact_seq_map: bool | None + sort_base_mapping_type_on_output: bool | None + top_level_colon_align: bool | None + prefix_colon: str | None + preserve_quotes: bool | None allow_duplicate_keys: bool encoding: str - explicit_start: Incomplete - explicit_end: Incomplete - doc_infos: Incomplete - default_style: Incomplete + explicit_start: bool | None + explicit_end: bool | None + doc_infos: list[DocInfo] + default_style: str | None top_level_block_style_scalar_no_indent_error_1_1: bool - scalar_after_indicator: Incomplete + scalar_after_indicator: bool | None brace_single_entry_mapping_in_flow_sequence: bool + @overload + def __new__( + cls, + *, + typ: Literal["rt"] | list[Literal["rt"]] | None = None, + pure: bool = False, + output: Path | SupportsWrite[str] | None = None, + plug_ins: list[str] | None = None, + ) -> _RoundTripYAML: ... + @overload + def __new__( + cls, + *, + typ: Literal["full"] | list[Literal["full"]], + pure: bool = False, + output: Path | SupportsWrite[str] | None = None, + plug_ins: list[str] | None = None, + ) -> _FullYAML: ... + @overload + def __new__( + cls, + *, + typ: _YAMLType | list[_YAMLType], + pure: bool = False, + output: Path | SupportsWrite[str] | None = None, + plug_ins: list[str] | None = None, + ) -> Self: ... + # This redundant overload prevents type checkers from matching the deprecated "unsafe" overload + # when users are typing `YAML(typ=)`. + @overload + def __init__( + self, + *, + typ: Literal["rt"] | list[Literal["rt"]] | None = None, + pure: bool = False, + output: Path | SupportsWrite[str] | None = None, + plug_ins: list[str] | None = None, + ) -> None: ... + @overload + @deprecated("For **dumping only** use YAML(typ='full')", category=PendingDeprecationWarning) + def __init__( + self, + *, + typ: Literal["unsafe"] | list[Literal["unsafe"]], + pure: bool = False, + output: Path | SupportsWrite[str] | None = None, + plug_ins: list[str] | None = None, + ) -> None: ... + @overload def __init__( self, *, - typ: list[str] | str | None = None, + typ: _YAMLType | list[_YAMLType], pure: bool = False, - output: Incomplete | None = None, - plug_ins: Incomplete | None = None, + output: Path | SupportsWrite[str] | None = None, + plug_ins: list[str] | None = None, ) -> None: ... @property - def reader(self): ... + def reader(self) -> Reader: ... @property - def scanner(self): ... + def scanner(self) -> Scanner: ... @property - def parser(self): ... + def parser(self) -> Parser | None: ... # TODO: CParser @property - def composer(self): ... + def composer(self) -> Composer: ... @property - def constructor(self): ... + def constructor(self) -> Constructor: ... @property - def resolver(self): ... + def resolver(self) -> BaseResolver: ... @property - def emitter(self): ... + def emitter(self) -> Emitter | None: ... # TODO: CEmitter @property - def serializer(self): ... + def serializer(self) -> Serializer: ... @property - def representer(self): ... + def representer(self) -> BaseRepresenter: ... def scan(self, stream: StreamTextType): ... def parse(self, stream: StreamTextType): ... def compose(self, stream: Path | StreamTextType): ... @@ -90,11 +152,11 @@ class YAML: def dump_all(self, documents, stream: Path | StreamType, *, transform: Incomplete | None = None): ... def Xdump_all(self, documents, stream, *, transform: Incomplete | None = None): ... def get_serializer_representer_emitter(self, stream: StreamType, tlca): ... - def map(self, **kw): ... - def seq(self, *args): ... - def official_plug_ins(self): ... - def register_class(self, cls): ... - def __enter__(self): ... + def map(self, **kw) -> dict: ... + def seq(self, *args) -> list: ... + def official_plug_ins(self) -> list[str]: ... + def register_class(self, cls: _RegistrableClass) -> _RegistrableClass: ... + def __enter__(self) -> _YAMLContext: ... def __exit__(self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None) -> None: ... @property def version(self) -> tuple[int, int] | None: ... @@ -105,14 +167,57 @@ class YAML: @tags.setter def tags(self, val) -> None: ... @property - def indent(self): ... + def indent(self) -> _IndentSetter: ... @indent.setter - def indent(self, val) -> None: ... + def indent(self, val: int | None) -> None: ... @property - def block_seq_indent(self): ... + def block_seq_indent(self) -> int: ... @block_seq_indent.setter - def block_seq_indent(self, val) -> None: ... - def compact(self, seq_seq: Incomplete | None = None, seq_map: Incomplete | None = None) -> None: ... + def block_seq_indent(self, val: int) -> None: ... + def compact(self, seq_seq: bool | None = None, seq_map: bool | None = None) -> None: ... + +class _IndentSetter(Protocol): + def __call__(self, mapping: int | None = None, sequence: int | None = None, offset: int | None = None) -> None: ... + +class _RoundTripYAML(YAML): + typ: list[Literal["rt"]] + Representer: type[RoundTripRepresenter] + Constructor: type[RoundTripConstructor] + Scanner: type[RoundTripScanner] + Emitter: type[RoundTripEmitter] + Parser: type[RoundTripParser] + def map(self, **kw) -> CommentedMap: ... + def seq(self, *args) -> CommentedSeq: ... + def __enter__(self) -> _RoundTripYAMLContext: ... + +class _FullYAML(YAML): + typ: list[Literal["full"]] + Composer: None + Constructor: Never + @property + def composer(self) -> NoReturn: ... + @property + def constructor(self) -> NoReturn: ... + @deprecated("You can only use YAML(typ='full') for dumping") + def scan(self, stream: Incomplete) -> NoReturn: ... + @deprecated("You can only use YAML(typ='full') for dumping") + def parse(self, stream: Incomplete) -> NoReturn: ... + @deprecated("You can only use YAML(typ='full') for dumping") + def compose(self, stream: Path | Incomplete) -> NoReturn: ... + @deprecated("You can only use YAML(typ='full') for dumping") + def compose_all(self, stream: Path | Incomplete) -> NoReturn: ... + @deprecated("You can only use YAML(typ='full') for dumping") + def load(self, stream: Path | Incomplete) -> NoReturn: ... + @deprecated("You can only use YAML(typ='full') for dumping") + def load_all(self, stream: Path | Incomplete) -> NoReturn: ... + def get_constructor_parser(self, stream: StreamTextType) -> NoReturn: ... + def __enter__(self) -> _FullYAMLContext: ... + +class _YAMLContext(YAML): + def dump_all(self, documents, stream: Path | Incomplete, *, transform: Incomplete | None = ...) -> NoReturn: ... + +class _RoundTripYAMLContext(_YAMLContext, _RoundTripYAML): ... +class _FullYAMLContext(_YAMLContext, _FullYAML): ... class YAMLContextManager: def __init__(self, yaml, transform: Incomplete | None = None) -> None: ... @@ -120,23 +225,45 @@ class YAMLContextManager: def init_output(self, first_data) -> None: ... def dump(self, data) -> None: ... -def yaml_object(yml): ... -def warn_deprecation(fun, method, arg: str = "") -> None: ... -def error_deprecation(fun, method, arg: str = "", comment: str = "instead of") -> None: ... -def scan(stream: StreamTextType, Loader=...): ... -def parse(stream: StreamTextType, Loader=...): ... -def compose(stream: StreamTextType, Loader=...): ... -def compose_all(stream: StreamTextType, Loader=...): ... -def load( - stream, Loader: Incomplete | None = None, version: Incomplete | None = None, preserve_quotes: Incomplete | None = None -) -> None: ... -def load_all( - stream, Loader: Incomplete | None = None, version: Incomplete | None = None, preserve_quotes: Incomplete | None = None -) -> None: ... -def safe_load(stream: StreamTextType, version: VersionType | None = None): ... -def safe_load_all(stream: StreamTextType, version: VersionType | None = None): ... -def round_trip_load(stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None): ... -def round_trip_load_all(stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None): ... +# This is because we can't mark protocol fields as not required +# See https://github.com/python/typing/issues/601 +_RegistrableClass: TypeAlias = type[_RegistrableObject | object] + +class _RegistrableObject(Protocol): + yaml_tag: str + @classmethod + def to_yaml(cls, representer: BaseRepresenter, data: Self, /) -> Node: ... + @classmethod + def from_yaml(cls, constructor: BaseConstructor, node: Node, /) -> Self: ... + +def yaml_object(yml: YAML) -> Callable[[_RegistrableClass], _RegistrableClass]: ... +def warn_deprecation(fun: str, method: str, arg: str = "") -> None: ... +def error_deprecation(fun: str, method: str, arg: str = "", comment: str = "instead of") -> NoReturn: ... +@deprecated("Use YAML().scan() instead") +def scan(stream: StreamTextType, Loader=...) -> NoReturn: ... +@deprecated("Use YAML().parse() instead") +def parse(stream: StreamTextType, Loader=...) -> NoReturn: ... +@deprecated("Use YAML().compose() instead") +def compose(stream: StreamTextType, Loader=...) -> NoReturn: ... +@deprecated("Use YAML().compose_all() instead") +def compose_all(stream: StreamTextType, Loader=...) -> NoReturn: ... +@deprecated("Use YAML().load() instead") +def load(stream, Loader=None, version=None, preserve_quotes=None) -> NoReturn: ... +@deprecated("Use YAML().load_all() instead") +def load_all(stream, Loader=None, version=None, preserve_quotes=None) -> NoReturn: ... +@deprecated("Use YAML(typ='safe', pure=True).load() instead") +def safe_load(stream: StreamTextType, version: VersionType | None = None) -> NoReturn: ... +@deprecated("Use YAML(typ='safe', pure=True).load_all() instead") +def safe_load_all(stream: StreamTextType, version: VersionType | None = None) -> NoReturn: ... +@deprecated("Use YAML().load() instead") +def round_trip_load( + stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None +) -> NoReturn: ... +@deprecated("Use YAML().load_all() instead") +def round_trip_load_all( + stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None +) -> NoReturn: ... +@deprecated("Use YAML(typ='safe', pure=True).emit() instead") def emit( events, stream: StreamType | None = None, @@ -145,86 +272,92 @@ def emit( indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, -): ... + line_break=None, +) -> NoReturn: ... -enc: Incomplete +enc: None +@deprecated("Use YAML(typ='safe', pure=True).serialize_all() instead") def serialize_all( nodes, stream: StreamType | None = None, Dumper=..., - canonical: Incomplete | None = None, + canonical=None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, + line_break=None, encoding=None, explicit_start: bool | None = None, explicit_end: bool | None = None, version: VersionType | None = None, - tags: Incomplete | None = None, -): ... -def serialize(node, stream: StreamType | None = None, Dumper=..., **kwds): ... + tags=None, +) -> NoReturn: ... +@deprecated("Use YAML(typ='safe', pure=True).serialize() instead") +def serialize(node, stream: StreamType | None = None, Dumper=..., **kwds) -> NoReturn: ... +@deprecated("Use YAML(typ='unsafe', pure=True).dump_all() instead") def dump_all( documents, stream: StreamType | None = None, Dumper=..., - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, + default_style=None, + default_flow_style=None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, + line_break=None, encoding=None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Incomplete | None = None, - tags: Incomplete | None = None, - block_seq_indent: Incomplete | None = None, - top_level_colon_align: Incomplete | None = None, - prefix_colon: Incomplete | None = None, -): ... + version=None, + tags=None, + block_seq_indent=None, + top_level_colon_align=None, + prefix_colon=None, +) -> NoReturn: ... +@deprecated("Use YAML(typ='unsafe', pure=True).dump() instead") def dump( data, stream: StreamType | None = None, Dumper=..., - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, + default_style=None, + default_flow_style=None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, + line_break=None, encoding=None, explicit_start: bool | None = None, explicit_end: bool | None = None, version: VersionType | None = None, - tags: Incomplete | None = None, - block_seq_indent: Incomplete | None = None, -): ... -def safe_dump(data, stream: StreamType | None = None, **kwds): ... + tags=None, + block_seq_indent=None, +) -> NoReturn: ... +@deprecated("Use YAML(typ='safe', pure=True).dump() instead") +def safe_dump(data, stream: StreamType | None = None, **kwds) -> NoReturn: ... +@deprecated("Use YAML().dump() instead") def round_trip_dump( data, stream: StreamType | None = None, Dumper=..., - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, + default_style=None, + default_flow_style=None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, + line_break=None, encoding=None, explicit_start: bool | None = None, explicit_end: bool | None = None, version: VersionType | None = None, - tags: Incomplete | None = None, - block_seq_indent: Incomplete | None = None, - top_level_colon_align: Incomplete | None = None, - prefix_colon: Incomplete | None = None, -): ... + tags=None, + block_seq_indent=None, + top_level_colon_align=None, + prefix_colon=None, +) -> NoReturn: ... def add_implicit_resolver( tag, regexp, first: Incomplete | None = None, Loader: Incomplete | None = None, Dumper: Incomplete | None = None, resolver=... ) -> None: ... From 42448daf4882b842a2db557a36d32c3578ddc237 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Thu, 12 Sep 2024 19:27:54 +0000 Subject: [PATCH 05/15] Finish all except main (thanks, MonkeyType) --- stubs/ruamel.yaml/METADATA.toml | 2 + stubs/ruamel.yaml/_ruamel_yaml.pyi | 55 ++++ stubs/ruamel.yaml/ruamel/yaml/anchor.pyi | 9 +- stubs/ruamel.yaml/ruamel/yaml/comments.pyi | 249 +++++++++--------- stubs/ruamel.yaml/ruamel/yaml/compat.pyi | 81 +++--- stubs/ruamel.yaml/ruamel/yaml/composer.pyi | 27 +- .../ruamel/yaml/configobjwalker.pyi | 8 +- stubs/ruamel.yaml/ruamel/yaml/constructor.pyi | 216 ++++++++------- stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi | 79 +++--- stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi | 10 +- stubs/ruamel.yaml/ruamel/yaml/dumper.pyi | 84 +++--- stubs/ruamel.yaml/ruamel/yaml/emitter.pyi | 177 +++++++------ stubs/ruamel.yaml/ruamel/yaml/error.pyi | 112 ++++---- stubs/ruamel.yaml/ruamel/yaml/events.pyi | 149 ++++++----- stubs/ruamel.yaml/ruamel/yaml/loader.pyi | 22 +- stubs/ruamel.yaml/ruamel/yaml/nodes.pyi | 102 +++---- stubs/ruamel.yaml/ruamel/yaml/parser.pyi | 102 +++---- stubs/ruamel.yaml/ruamel/yaml/reader.pyi | 48 ++-- stubs/ruamel.yaml/ruamel/yaml/representer.pyi | 182 +++++++------ stubs/ruamel.yaml/ruamel/yaml/resolver.pyi | 64 +++-- stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi | 10 +- stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi | 52 +++- stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi | 49 ++-- .../ruamel.yaml/ruamel/yaml/scalarstring.pyi | 45 ++-- stubs/ruamel.yaml/ruamel/yaml/scanner.pyi | 217 ++++++++------- stubs/ruamel.yaml/ruamel/yaml/serializer.pyi | 49 ++-- stubs/ruamel.yaml/ruamel/yaml/tag.pyi | 22 +- stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi | 22 +- stubs/ruamel.yaml/ruamel/yaml/tokens.pyi | 136 ++++++---- stubs/ruamel.yaml/ruamel/yaml/util.pyi | 40 ++- 30 files changed, 1334 insertions(+), 1086 deletions(-) create mode 100644 stubs/ruamel.yaml/_ruamel_yaml.pyi diff --git a/stubs/ruamel.yaml/METADATA.toml b/stubs/ruamel.yaml/METADATA.toml index 9550463d6ca4..00f0dd37f445 100644 --- a/stubs/ruamel.yaml/METADATA.toml +++ b/stubs/ruamel.yaml/METADATA.toml @@ -1 +1,3 @@ version = "0.18.*" +requires = ["configobj"] +upstream_repository = "https://sourceforge.net/p/ruamel-yaml/code/" diff --git a/stubs/ruamel.yaml/_ruamel_yaml.pyi b/stubs/ruamel.yaml/_ruamel_yaml.pyi new file mode 100644 index 000000000000..e95ff1e06ded --- /dev/null +++ b/stubs/ruamel.yaml/_ruamel_yaml.pyi @@ -0,0 +1,55 @@ +from _typeshed import SupportsRead, SupportsWrite +from collections.abc import Mapping, Sequence + +from ruamel.yaml.events import Event +from ruamel.yaml.nodes import Node +from ruamel.yaml.tokens import Token + +def get_version_string() -> str: ... +def get_version() -> tuple[int, int, int]: ... + +class Mark: + name: str | None + index: int + line: int + column: int + buffer: None + pointer: None + def __init__(self, name: str | None, index: int, line: int, column: int, buffer: None, pointer: None) -> None: ... + def get_snippet(self) -> None: ... + +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: type[Token]) -> bool: ... + def get_event(self) -> Event | None: ... + def peek_event(self) -> Event | None: ... + def check_event(self, *choices: type[Token]) -> 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: SupportsWrite[str | bytes], + canonical: bool | None = ..., + indent: int | None = ..., + width: int | None = ..., + allow_unicode: bool | None = ..., + line_break: str | None = ..., + encoding: str | None = ..., + explicit_start: bool | None = ..., + explicit_end: bool | None = ..., + version: Sequence[int] | None = ..., + tags: Mapping[str, str] | None = ..., + ) -> None: ... + def dispose(self) -> None: ... + def emit(self, event_object: Event) -> None: ... + def open(self) -> None: ... + def close(self) -> None: ... + def serialize(self, node: Node) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi b/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi index 91a0ec14ee6f..6ddc8f10b72c 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/anchor.pyi @@ -1,10 +1,9 @@ -from _typeshed import Incomplete -from typing import Literal +from typing import Final -anchor_attrib: Literal["_yaml_anchor"] +anchor_attrib: Final = "_yaml_anchor" class Anchor: - attrib = anchor_attrib - value: Incomplete + attrib: Final = anchor_attrib + value: str | None always_dump: bool def __init__(self) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi index 1ef6027d81f7..f88a6e4f3af9 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi @@ -1,9 +1,23 @@ -from _typeshed import Incomplete -from collections.abc import Generator, Mapping, MutableSet, Set as AbstractSet, Sized -from typing import Any, Iterator, Literal, NoReturn +import sys +from _typeshed import SupportsWrite, sentinel +from collections.abc import Hashable, Iterable, Iterator, Mapping, MutableSet, Set as AbstractSet, Sized +from typing import Any, Final, Generic, NoReturn, Self, TypeAlias, TypeVar +from .anchor import Anchor from .compat import MutableSliceableSequence, ordereddict +from .nodes import _ScalarNodeStyle from .tag import Tag +from .tokens import CommentToken, _CommentGroup + +_Index: TypeAlias = int +_Key: TypeAlias = Hashable + +_T = TypeVar("_T") +_KT = TypeVar("_KT") +_VT = TypeVar("_VT") +_KT_co = TypeVar("_KT_co", covariant=True) +_VT_co = TypeVar("_VT_co", covariant=True) +_Commented = TypeVar("_Commented", bound=CommentedBase) __all__ = [ "CommentedSeq", @@ -20,150 +34,123 @@ __all__ = [ "C_BLANK_LINE_PRESERVE_SPACE", ] -C_POST: int -C_PRE: int -C_SPLIT_ON_FIRST_BLANK: int -C_BLANK_LINE_PRESERVE_SPACE: int +C_POST: Final = 0b00 +C_PRE: Final = 0b01 +C_SPLIT_ON_FIRST_BLANK: Final = 0b10 +C_BLANK_LINE_PRESERVE_SPACE: Final = 0b100 -class IDX: - def __init__(self) -> None: ... - def __call__(self): ... - -comment_attrib: Literal["_yaml_comment"] -format_attrib: Literal["_yaml_format"] -line_col_attrib: Literal["_yaml_line_col"] -merge_attrib: Literal["_yaml_merge"] +comment_attrib: Final = "_yaml_comment" +format_attrib: Final = "_yaml_format" +line_col_attrib: Final = "_yaml_line_col" +merge_attrib: Final = "_yaml_merge" class Comment: - attrib = comment_attrib - comment: Incomplete - def __init__(self, old: bool = True) -> None: ... + attrib: Final = comment_attrib + comment: _CommentGroup | None + def __init__(self, *, old: bool = True) -> None: ... @property - def items(self): ... + def items(self) -> dict[_Index | _Key, _CommentGroup]: ... @property - def end(self): ... + def end(self): ... # RTSC @end.setter - def end(self, value) -> None: ... + def end(self, value) -> None: ... # RTSC @property - def pre(self): ... + def pre(self): ... # RTSC @pre.setter - def pre(self, value) -> None: ... - def get(self, item, pos): ... - def set(self, item, pos, value) -> None: ... - def __contains__(self, x) -> bool: ... - -class NotNone: ... + def pre(self, value) -> None: ... # RTSC + def get(self, item: _Index | _Key, pos: int): ... # RTSC + def set(self, item: _Index | _Key, pos: int, value: list[int]): ... # RTSC + def __contains__(self, x: str, /) -> bool: ... class Format: - attrib = format_attrib + attrib: Final = format_attrib def __init__(self) -> None: ... def set_flow_style(self) -> None: ... def set_block_style(self) -> None: ... - def flow_style(self, default: Incomplete = None): ... + def flow_style(self, default: bool | None = None) -> bool | None: ... class LineCol: - attrib = line_col_attrib - line: Incomplete - col: Incomplete - data: Incomplete + attrib: Final = line_col_attrib + line: int | None + col: int | None + data: dict[_Key, list[int]] | None def __init__(self) -> None: ... - def add_kv_line_col(self, key, data) -> None: ... - def key(self, k): ... - def value(self, k): ... - def item(self, idx): ... - def add_idx_line_col(self, key, data) -> None: ... + def add_kv_line_col(self, key: _Key, data: list[int]) -> None: ... + def key(self, k: str, /) -> tuple[int, int] | None: ... + def value(self, k: str, /) -> tuple[int, int] | None: ... + def item(self, idx: int, /) -> tuple[int, int] | None: ... + def add_idx_line_col(self, key: _Index, data: list[int]) -> None: ... class CommentedBase: @property - def ca(self) -> Any: ... - def yaml_end_comment_extend(self, comment, clear: bool = False) -> None: ... - def yaml_key_comment_extend(self, key, comment, clear: bool = False) -> None: ... - def yaml_value_comment_extend(self, key, comment, clear: bool = False) -> None: ... - def yaml_set_start_comment(self, comment, indent: int = 0) -> None: ... + def ca(self) -> Comment: ... + def yaml_end_comment_extend(self, comment: list[CommentToken] | None, *, clear: bool = False) -> None: ... + def yaml_key_comment_extend(self, key: _Index | _Key, comment: _CommentGroup, *, clear: bool = False) -> None: ... + def yaml_value_comment_extend(self, key: _Key, comment: _CommentGroup, *, clear: bool = False) -> None: ... + def yaml_set_start_comment(self, comment: str, *, indent: int = 0) -> None: ... def yaml_set_comment_before_after_key( - self, - key, - before: Incomplete | None = None, - indent: int = 0, - after: Incomplete | None = None, - after_indent: Incomplete | None = None, + self, key: _Key, before: str | None = None, indent: int = 0, after: str | None = None, after_indent: int | None = None ) -> None: ... @property - def fa(self): ... - def yaml_add_eol_comment(self, comment, key: Incomplete = ..., column: Incomplete = None) -> None: ... + def fa(self) -> Format: ... + def yaml_add_eol_comment(self, comment: str, key: _Index | _Key = sentinel, column: int | None = None) -> None: ... @property - def lc(self): ... + def lc(self) -> LineCol: ... @property - def anchor(self): ... - def yaml_anchor(self): ... - def yaml_set_anchor(self, value, always_dump: bool = False) -> None: ... + def anchor(self) -> Anchor: ... + def yaml_anchor(self) -> Anchor | None: ... + def yaml_set_anchor(self, value: str, *, always_dump: bool = False) -> None: ... @property - def tag(self): ... - def yaml_set_ctag(self, value: Tag) -> None: ... - def copy_attributes(self, t, memo: Incomplete | None = None): ... - -class CommentedSeq(MutableSliceableSequence, list, CommentedBase): - def __init__(self, *args, **kw) -> None: ... - def __getsingleitem__(self, idx): ... - def __setsingleitem__(self, idx, value) -> None: ... - def __delsingleitem__(self, idx: Incomplete | None = None) -> None: ... - def __len__(self) -> int: ... - def insert(self, idx, val) -> None: ... - def extend(self, val) -> None: ... - def __eq__(self, other) -> bool: ... - def __deepcopy__(self, memo): ... - def __add__(self, other): ... - def sort(self, key: Incomplete | None = None, reverse: bool = False) -> None: ... + def tag(self) -> Tag: ... + def yaml_set_ctag(self, value: Tag, /) -> None: ... + def copy_attributes(self, t: _Commented, memo: dict[int, Any] | None = None) -> _Commented: ... + +class CommentedSeq(MutableSliceableSequence[_T], list[_T], CommentedBase): + def __getsingleitem__(self, idx: int) -> _T: ... + def __setsingleitem__(self, idx: int, value: _T) -> None: ... + def __delsingleitem__(self, idx: int): ... + def __deepcopy__(self, memo: dict[int, Any]) -> Self: ... -class CommentedKeySeq(tuple, CommentedBase): ... +class CommentedKeySeq(tuple[_T, ...], CommentedBase): ... class CommentedMapView(Sized): - def __init__(self, mapping) -> None: ... + def __init__(self, mapping: CommentedMap[Any, Any]) -> None: ... def __len__(self) -> int: ... -class CommentedMapKeysView(CommentedMapView, AbstractSet): - def __contains__(self, key) -> bool: ... - def __iter__(self): ... - -class CommentedMapItemsView(CommentedMapView, AbstractSet): - def __contains__(self, item) -> bool: ... - def __iter__(self): ... - -class CommentedMapValuesView(CommentedMapView): - def __contains__(self, value) -> bool: ... - def __iter__(self): ... - -class CommentedMap(ordereddict, CommentedBase): - def __init__(self, *args, **kw) -> None: ... - def update(self, *vals, **kw) -> None: ... - def insert(self, pos, key, value, comment: Incomplete = None) -> None: ... - def mlget(self, key, default: Incomplete | None = None, list_ok: bool = False): ... - def __getitem__(self, key): ... - def __setitem__(self, key, value) -> None: ... - def __contains__(self, key) -> bool: ... - def get(self, key, default: Incomplete | None = None): ... - def non_merged_items(self) -> Generator[Incomplete, None, None]: ... - def __delitem__(self, key) -> None: ... - def __iter__(self): ... - def pop(self, key, default=...): ... - def __len__(self) -> int: ... - def __eq__(self, other) -> bool: ... - def keys(self): ... - def values(self): ... - def items(self): ... +class CommentedMapKeysView(CommentedMapView, AbstractSet[_KT_co]): + def __init__(self, mapping: CommentedMap[_KT_co, Any]) -> None: ... + def __contains__(self, key: object) -> bool: ... + def __iter__(self) -> Iterator[_KT_co]: ... + +class CommentedMapItemsView(CommentedMapView, AbstractSet[tuple[_KT_co, _VT_co]]): + def __init__(self, mapping: CommentedMap[_KT_co, _VT_co]) -> None: ... + def __contains__(self, item: object) -> bool: ... + def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... + +class CommentedMapValuesView(CommentedMapView, Generic[_VT_co]): + def __init__(self, mapping: CommentedMap[Any, _VT_co]) -> None: ... + def __contains__(self, value: object) -> bool: ... + def __iter__(self) -> Iterator[_VT_co]: ... + +class CommentedMap(ordereddict[_KT, _VT], CommentedBase): + def insert(self, pos: int, key: _KT, value: _VT, comment: str | None = None) -> None: ... + def mlget(self, key: list[_Index | _Key], default: Any = None, list_ok: bool = False) -> Any: ... + def non_merged_items(self) -> Iterator[tuple[_KT, _VT]]: ... + def keys(self) -> CommentedMapKeysView[_KT]: ... + def values(self) -> CommentedMapValuesView[_VT]: ... + def items(self) -> CommentedMapItemsView[_KT, _VT]: ... @property - def merge(self): ... - def copy(self): ... - def add_referent(self, cm) -> None: ... - def add_yaml_merge(self, value) -> None: ... - def update_key_value(self, key) -> None: ... - def __deepcopy__(self, memo): ... + def merge(self) -> list[tuple[int, Self]]: ... + def add_referent(self, cm: Self) -> None: ... + def add_yaml_merge(self, value: list[tuple[int, Self]]) -> None: ... + def update_key_value(self, key: _KT) -> None: ... + def __deepcopy__(self, memo: dict[int, Any]) -> Self: ... @classmethod def raise_immutable(cls, *args, **kwargs) -> NoReturn: ... -class CommentedKeyMap(CommentedBase, Mapping): - def __init__(self, *args, **kw) -> None: ... +class CommentedKeyMap(CommentedBase, Mapping[_KT, _VT]): + __init__ = ordereddict[_KT, _VT].__init__ __delitem__ = raise_immutable __setitem__ = raise_immutable clear = raise_immutable @@ -171,29 +158,29 @@ class CommentedKeyMap(CommentedBase, Mapping): popitem = raise_immutable setdefault = raise_immutable update = raise_immutable - def __getitem__(self, index): ... - def __iter__(self) -> Iterator: ... + def __getitem__(self, index: _KT) -> _VT: ... + def __iter__(self) -> Iterator[_KT]: ... def __len__(self) -> int: ... - def __hash__(self): ... + def __hash__(self) -> int: ... @classmethod - def fromkeys(keys, v: Incomplete | None = None): ... + def fromkeys(keys, v=None) -> NoReturn: ... # broken -class CommentedOrderedMap(CommentedMap): ... +class CommentedOrderedMap(CommentedMap[_KT, _VT]): ... -class CommentedSet(MutableSet, CommentedBase): - odict: Incomplete - def __init__(self, values: Incomplete | None = None) -> None: ... - def add(self, value) -> None: ... - def discard(self, value) -> None: ... - def __contains__(self, x) -> bool: ... - def __iter__(self): ... +class CommentedSet(MutableSet[_T], CommentedBase): + odict: ordereddict[_T, None] + def __init__(self, values: Iterable[_T] | None = None) -> None: ... + def add(self, value: _T) -> None: ... + def discard(self, value: _T) -> None: ... + def __contains__(self, x: object) -> bool: ... + def __iter__(self) -> Iterator[_T]: ... def __len__(self) -> int: ... class TaggedScalar(CommentedBase): - value: Incomplete - style: Incomplete - def __init__( - self, value: Incomplete | None = None, style: Incomplete | None = None, tag: Incomplete | None = None - ) -> None: ... - def count(self, s: str, start: int | None = None, end: int | None = None): ... - def __getitem__(self, pos: int): ... + value: str | None + style: _ScalarNodeStyle | None + def __init__(self, value: str | None = None, style: _ScalarNodeStyle | None = None, tag: Tag | str | None = None) -> None: ... + def count(self, s: str, start: int | None = None, end: int | None = None) -> int: ... + def __getitem__(self, pos: int) -> str: ... + +def dump_comments(d: object, name: str = "", sep: str = ".", out: SupportsWrite[str] = sys.stdout) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi index 7d3e9e61214a..a8da97e4204a 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi @@ -1,61 +1,62 @@ -import abc -import collections.abc -import io -from _typeshed import Incomplete, SupportsRead -from abc import abstractmethod +from _typeshed import SupportsRead, SupportsWrite +from abc import ABCMeta, abstractmethod from collections import OrderedDict +from collections.abc import Iterable, MutableSequence +from typing import Final, Self, TypeVar, overload from typing_extensions import TypeAlias from .docinfo import Version -SupportsIndex: TypeAlias = int -StreamType: TypeAlias = str | bytes | SupportsRead[str | bytes] -StreamTextType: TypeAlias = StreamType +_T = TypeVar("_T") +_KT = TypeVar("_KT") +_VT = TypeVar("_VT") + +StreamType: TypeAlias = SupportsWrite[str | bytes] +StreamTextType: TypeAlias = str | bytes | SupportsRead[str | bytes] VersionType: TypeAlias = str | tuple[int, int] | list[int] | Version | None -class ordereddict(OrderedDict): - def insert(self, pos: int, key, value) -> None: ... +class ordereddict(OrderedDict[_KT, _VT]): + def insert(self, pos: int, key: _KT, value: _VT) -> None: ... -StringIO = io.StringIO -BytesIO = io.BytesIO -builtins_module: str +builtins_module: Final = "builtins" def with_metaclass(meta, *bases): ... -DBG_TOKEN: int -DBG_EVENT: int -DBG_NODE: int - -class ObjectCounter: - map: Incomplete - def __init__(self) -> None: ... - def __call__(self, k) -> None: ... - def dump(self) -> None: ... - -object_counter: Incomplete +DBG_TOKEN: Final = 1 +DBG_EVENT: Final = 2 +DBG_NODE: Final = 4 -def dbg(val: Incomplete | None = None): ... +def dbg(val: int | None = None) -> int: ... class Nprint: - def __init__(self, file_name: Incomplete | None = None) -> None: ... + def __init__(self, file_name: str | None = None) -> None: ... def __call__(self, *args, **kw) -> None: ... def set_max_print(self, i: int) -> None: ... def fp(self, mode: str = "a"): ... -nprint: Incomplete -nprintf: Incomplete - -def check_namespace_char(ch) -> bool: ... -def check_anchorname_char(ch) -> bool: ... -def version_tnf(t1, t2: Incomplete | None = None): ... - -class MutableSliceableSequence(collections.abc.MutableSequence, metaclass=abc.ABCMeta): - def __getitem__(self, index): ... - def __setitem__(self, index, value) -> None: ... - def __delitem__(self, index) -> None: ... +nprint: Nprint +nprintf: Nprint + +def check_namespace_char(ch: str) -> bool: ... +def check_anchorname_char(ch: str) -> bool: ... +def version_tnf(t1: tuple[int, ...], t2: tuple[int, ...] | None = None): ... + +class MutableSliceableSequence(MutableSequence[_T], metaclass=ABCMeta): + @overload + def __getitem__(self, index: int) -> _T: ... + @overload + def __getitem__(self, index: slice) -> Self: ... + @overload + def __setitem__(self, index: int, value: _T) -> None: ... + @overload + def __setitem__(self, index: slice, value: Iterable[_T]) -> None: ... + @overload + def __delitem__(self, index: int) -> None: ... + @overload + def __delitem__(self, index: slice) -> None: ... @abstractmethod - def __getsingleitem__(self, index): ... + def __getsingleitem__(self, index: int) -> _T: ... @abstractmethod - def __setsingleitem__(self, index, value) -> None: ... + def __setsingleitem__(self, index: int, value: _T) -> None: ... @abstractmethod - def __delsingleitem__(self, index) -> None: ... + def __delsingleitem__(self, index: int) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi index b02bd8f8bc6b..ce598cfe5343 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi @@ -1,8 +1,7 @@ -from typing import Any - from .error import MarkedYAMLError +from .events import MappingEndEvent, SequenceEndEvent from .main import YAML -from .nodes import MappingNode, Node, ScalarNode, SequenceNode +from .nodes import CollectionNode, MappingNode, Node, ScalarNode, SequenceNode from .parser import Parser from .resolver import BaseResolver @@ -11,8 +10,8 @@ __all__ = ["Composer", "ComposerError"] class ComposerError(MarkedYAMLError): ... class Composer: - loader: YAML - anchors: dict[Any, Node] + loader: YAML | None + anchors: dict[str, Node] warn_double_anchors: bool def __init__(self, loader: YAML | None = None) -> None: ... @property @@ -20,12 +19,12 @@ class Composer: @property def resolver(self) -> BaseResolver: ... def check_node(self) -> bool: ... - def get_node(self) -> Node | None: ... - def get_single_node(self) -> Node | None: ... - def compose_document(self) -> Node | None: ... - def return_alias(self, a: Node | None) -> Node | None: ... - def compose_node(self, parent: Node | None, index: int) -> Node | None: ... - def compose_scalar_node(self, anchor: dict[Any, Node]) -> ScalarNode: ... - def compose_sequence_node(self, anchor: dict[Any, Node]) -> SequenceNode: ... - def compose_mapping_node(self, anchor: dict[Any, Node]) -> MappingNode: ... - def check_end_doc_comment(self, end_event, node) -> None: ... + def get_node(self) -> Node: ... + def get_single_node(self) -> Node: ... + def compose_document(self) -> Node: ... + def return_alias(self, a: Node) -> Node: ... + def compose_node(self, parent: CollectionNode | None, index: int | Node | None) -> Node: ... + def compose_scalar_node(self, anchor: str | None) -> ScalarNode: ... + def compose_sequence_node(self, anchor: str | None) -> SequenceNode: ... + def compose_mapping_node(self, anchor: str | None) -> MappingNode: ... + def check_end_doc_comment(self, end_event: SequenceEndEvent | MappingEndEvent, node: SequenceNode | MappingNode) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi b/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi index bec5b1effbae..0711b22f845e 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi @@ -1 +1,7 @@ -def configobj_walker(cfg): ... +from collections.abc import Iterator +from typing_extensions import deprecated + +from configobj import ConfigObj + +@deprecated("configobj_walker has moved to ruamel.yaml.util") +def configobj_walker(cfg: ConfigObj, /) -> Iterator[str]: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi index f2ef665576d1..293eb854769b 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi @@ -1,15 +1,31 @@ -import datetime -from _typeshed import Incomplete -from collections.abc import Generator -from typing import Iterator +from collections.abc import Generator, Iterable, Iterator, Mapping, Set as AbstractSet +from datetime import date, datetime +from types import ModuleType +from typing import Any, ClassVar, Final, NoReturn, Protocol, Self, TypeVar, overload -from .comments import * +from . import util from .comments import CommentedMap, CommentedOrderedMap, CommentedSeq, CommentedSet, TaggedScalar -from .error import MarkedYAMLError, MarkedYAMLFutureWarning -from .nodes import * +from .compat import ordereddict +from .composer import Composer +from .error import MarkedYAMLError, MarkedYAMLFutureWarning, _Mark +from .main import YAML +from .nodes import MappingNode, Node, ScalarNode, SequenceNode +from .resolver import BaseResolver from .scalarbool import ScalarBoolean +from .scalarfloat import ScalarFloat +from .scanner import ScannedComments, Scanner +from .tag import Tag from .timestamp import TimeStamp +_T = TypeVar("_T") +_Constructor = TypeVar("_Constructor", bound=BaseConstructor, contravariant=True) + +class _ConstructorFunction(Protocol[_Constructor]): + def __call__(self, loader: _Constructor, node: Node, /) -> Any: ... + +class _MultiConstructorFunction(Protocol[_Constructor]): + def __call__(self, loader: _Constructor, tag_suffix: str, node: Node, /) -> Any: ... + __all__ = ["BaseConstructor", "SafeConstructor", "Constructor", "ConstructorError", "RoundTripConstructor"] class ConstructorError(MarkedYAMLError): ... @@ -17,109 +33,121 @@ class DuplicateKeyFutureWarning(MarkedYAMLFutureWarning): ... class DuplicateKeyError(MarkedYAMLError): ... class BaseConstructor: - yaml_constructors: dict - yaml_multi_constructors: dict - loader: Incomplete - yaml_base_dict_type: Incomplete - yaml_base_list_type: Incomplete - constructed_objects: Incomplete - recursive_objects: Incomplete - state_generators: Incomplete + yaml_constructors: ClassVar[dict[str | None, _ConstructorFunction[Self]]] + yaml_multi_constructors: ClassVar[dict[str | None, _MultiConstructorFunction[Self]]] + loader: YAML | None + yaml_base_dict_type: type[dict[Any, Any]] + yaml_base_list_type: type[list[Any]] + constructed_objects: dict[Node, Any] + recursive_objects: dict[Node, Any] + state_generators: list[Generator[Any, Any, Any]] deep_construct: bool - allow_duplicate_keys: Incomplete - def __init__(self, preserve_quotes: bool | None = None, loader: Incomplete | None = None) -> None: ... + allow_duplicate_keys: bool | None + def __init__(self, preserve_quotes: bool | None = None, loader: YAML | None = None) -> None: ... @property - def composer(self): ... + def composer(self) -> Composer: ... @property - def resolver(self): ... + def resolver(self) -> BaseResolver: ... @property - def scanner(self): ... - def check_data(self): ... - def get_data(self): ... - def get_single_data(self): ... - def construct_document(self, node): ... - def construct_object(self, node, deep: bool = False): ... - def construct_non_recursive_object(self, node, tag: str | None = None): ... - def construct_scalar(self, node): ... - def construct_sequence(self, node, deep: bool = False): ... - def construct_mapping(self, node, deep: bool = False): ... - def check_mapping_key(self, node, key_node, mapping, key, value) -> bool: ... - def check_set_key(self, node, key_node, setting, key) -> None: ... - def construct_pairs(self, node, deep: bool = False): ... + def scanner(self) -> Scanner: ... + def check_data(self) -> bool: ... + def get_data(self) -> Any: ... + def get_single_data(self) -> Any: ... + def construct_document(self, node: Node) -> Any: ... + def construct_object(self, node: Node, deep: bool = False) -> Any: ... + def construct_non_recursive_object(self, node: Node, tag: str | None = None) -> Any: ... + def construct_scalar(self, node: ScalarNode) -> str: ... + def construct_sequence(self, node: SequenceNode, deep: bool = False) -> list[Any]: ... + def construct_mapping(self, node: MappingNode, deep: bool = False) -> dict[Any, Any]: ... + def check_mapping_key(self, node: MappingNode, key_node: Node, mapping: Mapping[Any, Any], key: Any, value: Any) -> bool: ... + def check_set_key(self, node: MappingNode, key_node: ScalarNode, setting: AbstractSet[Any], key: Any) -> None: ... + def construct_pairs(self, node: MappingNode, deep: bool = False) -> list[tuple[Any, Any]]: ... @classmethod - def add_constructor(cls, tag, constructor): ... + def add_constructor( + cls, tag: Tag | str | None, constructor: _ConstructorFunction[Self] + ) -> _ConstructorFunction[Self] | None: ... @classmethod - def add_multi_constructor(cls, tag_prefix, multi_constructor) -> None: ... + def add_multi_constructor(cls, tag_prefix: str, multi_constructor: _MultiConstructorFunction[Self]) -> None: ... @classmethod - def add_default_constructor( - cls, tag: str, method: Incomplete | None = None, tag_base: str = "tag:yaml.org,2002:" - ) -> None: ... + def add_default_constructor(cls, tag: str, method: str | None = None, tag_base: str = "tag:yaml.org,2002:") -> None: ... class SafeConstructor(BaseConstructor): - def construct_scalar(self, node): ... - def flatten_mapping(self, node) -> None: ... - def construct_mapping(self, node, deep: bool = False): ... - def construct_yaml_null(self, node) -> None: ... - bool_values: Incomplete - def construct_yaml_bool(self, node) -> bool: ... - def construct_yaml_int(self, node) -> int: ... - inf_value: float - nan_value: Incomplete - def construct_yaml_float(self, node) -> float: ... - def construct_yaml_binary(self, node): ... - timestamp_regexp = timestamp_regexp - def construct_yaml_timestamp(self, node, values: Incomplete | None = None): ... - def construct_yaml_omap(self, node) -> Generator[Incomplete, None, None]: ... - def construct_yaml_pairs(self, node) -> Generator[Incomplete, None, None]: ... - def construct_yaml_set(self, node) -> Generator[Incomplete, None, None]: ... - def construct_yaml_str(self, node): ... - def construct_yaml_seq(self, node) -> Generator[Incomplete, None, None]: ... - def construct_yaml_map(self, node) -> Generator[Incomplete, None, None]: ... - def construct_yaml_object(self, node, cls) -> Generator[Incomplete, None, None]: ... - def construct_undefined(self, node) -> None: ... + def construct_scalar(self, node: ScalarNode) -> str: ... + def flatten_mapping(self, node: MappingNode) -> None: ... + def construct_mapping(self, node: MappingNode, deep: bool = False) -> dict[Any, Any]: ... + def construct_yaml_null(self, node: ScalarNode) -> None: ... + bool_values: Final[dict[str, bool]] + def construct_yaml_bool(self, node: ScalarNode) -> bool: ... + def construct_yaml_int(self, node: ScalarNode) -> int: ... + inf_value: Final[float] + nan_value: Final[float] + def construct_yaml_float(self, node: ScalarNode) -> float: ... + def construct_yaml_binary(self, node: ScalarNode) -> bytes: ... + timestamp_regexp: Final = util.timestamp_regexp + def construct_yaml_timestamp(self, node: ScalarNode, values: dict[str, str | None] | None = None) -> date | datetime: ... + def construct_yaml_omap(self, node: SequenceNode) -> Iterator[ordereddict[Any, Any]]: ... + def construct_yaml_pairs(self, node: SequenceNode) -> Iterator[list[tuple[Any, Any]]]: ... + def construct_yaml_set(self, node: MappingNode) -> Iterator[set[Any]]: ... + def construct_yaml_str(self, node: ScalarNode) -> str: ... + def construct_yaml_seq(self, node: SequenceNode) -> Iterator[list[Any]]: ... + def construct_yaml_map(self, node: MappingNode) -> Iterator[dict[Any, Any]]: ... + def construct_yaml_object(self, node: MappingNode, cls: type[_T]) -> Iterator[_T]: ... + def construct_undefined(self, node: Node) -> NoReturn: ... class Constructor(SafeConstructor): - def construct_python_str(self, node): ... - def construct_python_unicode(self, node): ... - def construct_python_bytes(self, node): ... - def construct_python_long(self, node) -> int: ... - def construct_python_complex(self, node): ... - def construct_python_tuple(self, node): ... - def find_python_module(self, name, mark): ... - def find_python_name(self, name, mark): ... - def construct_python_name(self, suffix, node): ... - def construct_python_module(self, suffix, node): ... + def construct_python_str(self, node: ScalarNode) -> str: ... + def construct_python_unicode(self, node: ScalarNode) -> str: ... + def construct_python_bytes(self, node: ScalarNode) -> bytes: ... + def construct_python_long(self, node: ScalarNode) -> int: ... + def construct_python_complex(self, node: ScalarNode) -> complex: ... + def construct_python_tuple(self, node: SequenceNode) -> tuple[Any, ...]: ... + def find_python_module(self, name: str, mark: _Mark) -> ModuleType: ... + def find_python_name(self, name: str, mark: _Mark) -> Any: ... + def construct_python_name(self, suffix: str, node: ScalarNode) -> Any: ... + def construct_python_module(self, suffix: str, node: ScalarNode) -> ModuleType: ... def make_python_instance( - self, suffix, node, args: Incomplete | None = None, kwds: Incomplete | None = None, newobj: bool = False - ): ... + self, + suffix: str, + node: Node, + args: Iterable[Any] | None = None, + kwds: Mapping[str, Any] | None = None, + newobj: bool = False, + ) -> Any: ... def set_python_instance_state(self, instance, state) -> None: ... - def construct_python_object(self, suffix, node) -> Generator[Incomplete, None, None]: ... - def construct_python_object_apply(self, suffix, node, newobj: bool = False): ... - def construct_python_object_new(self, suffix, node): ... + def construct_python_object(self, suffix: str, node: MappingNode) -> Iterator[Any]: ... + def construct_python_object_apply(self, suffix: str, node: SequenceNode | MappingNode, newobj: bool = False) -> Any: ... + def construct_python_object_new(self, suffix: str, node: SequenceNode | MappingNode) -> Any: ... @classmethod def add_default_constructor( - cls, tag: str, method: Incomplete | None = None, tag_base: str = "tag:yaml.org,2002:python/" + cls, tag: str, method: str | None = None, tag_base: str = "tag:yaml.org,2002:python/" ) -> None: ... class RoundTripConstructor(SafeConstructor): - def comment(self, idx): ... - def comments(self, list_of_comments, idx: Incomplete = None): ... - def construct_scalar(self, node): ... - def construct_yaml_int(self, node): ... - def construct_yaml_float(self, node): ... - def construct_yaml_str(self, node): ... - def construct_rt_sequence(self, node, seqtyp, deep: bool = False): ... - def flatten_mapping(self, node): ... - def construct_mapping(self, node, maptyp, deep: bool = False): ... - def construct_setting(self, node, typ, deep: bool = False): ... - def construct_yaml_seq(self, node) -> Iterator[CommentedSeq]: ... - def construct_yaml_map(self, node) -> Iterator[CommentedMap]: ... - def set_collection_style(self, data, node) -> None: ... - def construct_yaml_object(self, node, cls) -> Generator[Incomplete, None, None]: ... - def construct_yaml_omap(self, node) -> Iterator[CommentedOrderedMap]: ... - def construct_yaml_set(self, node) -> Iterator[CommentedSet]: ... - def construct_unknown(self, node) -> Iterator[CommentedMap | TaggedScalar | CommentedSeq]: ... + def comment(self, idx: int) -> ScannedComments: ... # RTSC + def comments(self, list_of_comments: list[list[int] | None], idx: int | None = None) -> Iterator[ScannedComments]: ... # RTSC + def construct_scalar(self, node: ScalarNode) -> str: ... + def construct_yaml_int(self, node: ScalarNode) -> int: ... + def construct_yaml_float(self, node: ScalarNode) -> float | ScalarFloat: ... + def construct_yaml_str(self, node: ScalarNode) -> str | TaggedScalar: ... + def construct_rt_sequence(self, node: SequenceNode, seqtyp: CommentedSeq[_T], deep: bool = False) -> list[_T]: ... + def flatten_mapping(self, node: MappingNode) -> list[tuple[int, CommentedMap[Any, Any]]]: ... + def construct_mapping(self, node: MappingNode, maptyp: CommentedMap[Any, Any], deep: bool = False) -> None: ... + def construct_setting(self, node: MappingNode, typ: CommentedSet[Any], deep: bool = False) -> None: ... + def construct_yaml_seq(self, node: SequenceNode) -> Iterator[CommentedSeq[Any]]: ... + def construct_yaml_map(self, node: MappingNode) -> Iterator[CommentedMap[Any, Any]]: ... + def set_collection_style( + self, data: CommentedSeq[Any] | CommentedMap[Any, Any], node: SequenceNode | MappingNode + ) -> None: ... + def construct_yaml_object(self, node: MappingNode, cls: type[_T]) -> Iterator[_T]: ... + def construct_yaml_omap(self, node: SequenceNode) -> Iterator[CommentedOrderedMap[Any, Any]]: ... + def construct_yaml_set(self, node: MappingNode) -> Iterator[CommentedSet[Any]]: ... + @overload + def construct_unknown(self, node: ScalarNode) -> Iterator[TaggedScalar]: ... + @overload + def construct_unknown(self, node: SequenceNode) -> Iterator[CommentedSeq[Any]]: ... + @overload + def construct_unknown(self, node: MappingNode) -> Iterator[CommentedMap[Any, Any]]: ... def construct_yaml_timestamp( - self, node, values: Incomplete | None = None - ) -> datetime.date | datetime.datetime | TimeStamp: ... - def construct_yaml_sbool(self, node) -> bool | ScalarBoolean: ... + self, node: ScalarNode, values: dict[str, str | None] | None = None + ) -> date | datetime | TimeStamp: ... + def construct_yaml_sbool(self, node: ScalarNode) -> bool | ScalarBoolean: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi b/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi index a2e9ba1dd601..90562f29b711 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi @@ -1,88 +1,85 @@ -from _typeshed import Incomplete +from _typeshed import Unused from _ruamel_yaml import CEmitter, CParser -from .compat import StreamTextType, VersionType +from .compat import StreamTextType, StreamType from .constructor import BaseConstructor, Constructor, SafeConstructor +from .emitter import _LineBreak from .representer import BaseRepresenter, Representer, SafeRepresenter from .resolver import BaseResolver, Resolver +from .tag import _TagHandleToPrefix +from .tokens import _ScalarStyle, _VersionTuple __all__ = ["CBaseLoader", "CSafeLoader", "CLoader", "CBaseDumper", "CSafeDumper", "CDumper"] class CBaseLoader(CParser, BaseConstructor, BaseResolver): - def __init__( - self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None - ) -> None: ... + def __init__(self, stream: StreamTextType, version: Unused = None, preserve_quotes: Unused = None) -> None: ... class CSafeLoader(CParser, SafeConstructor, Resolver): - def __init__( - self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None - ) -> None: ... + def __init__(self, stream: StreamTextType, version: Unused = None, preserve_quotes: Unused = None) -> None: ... class CLoader(CParser, Constructor, Resolver): - def __init__( - self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None - ) -> None: ... + def __init__(self, stream: StreamTextType, version: Unused = None, preserve_quotes: Unused = None) -> None: ... class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver): def __init__( self, - stream, - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, + stream: StreamType, + default_style: _ScalarStyle | None = None, + default_flow_style: bool | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, - encoding: Incomplete | None = None, + line_break: _LineBreak | None = None, + encoding: str | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Incomplete | None = None, - tags: Incomplete | None = None, - block_seq_indent: Incomplete | None = None, - top_level_colon_align: Incomplete | None = None, - prefix_colon: Incomplete | None = None, + version: _VersionTuple | None = None, + tags: _TagHandleToPrefix | None = None, + block_seq_indent: Unused = None, + top_level_colon_align: Unused = None, + prefix_colon: Unused = None, ) -> None: ... class CSafeDumper(CEmitter, SafeRepresenter, Resolver): def __init__( self, - stream, - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, + stream: StreamType, + default_style: _ScalarStyle | None = None, + default_flow_style: bool | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, - encoding: Incomplete | None = None, + line_break: _LineBreak | None = None, + encoding: str | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Incomplete | None = None, - tags: Incomplete | None = None, - block_seq_indent: Incomplete | None = None, - top_level_colon_align: Incomplete | None = None, - prefix_colon: Incomplete | None = None, + version: _VersionTuple | None = None, + tags: _TagHandleToPrefix | None = None, + block_seq_indent: Unused = None, + top_level_colon_align: Unused = None, + prefix_colon: Unused = None, ) -> None: ... class CDumper(CEmitter, Representer, Resolver): def __init__( self, - stream, - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, + stream: StreamType, + default_style: _ScalarStyle | None = None, + default_flow_style: bool | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, - encoding: Incomplete | None = None, + line_break: _LineBreak | None = None, + encoding: str | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Incomplete | None = None, - tags: Incomplete | None = None, - block_seq_indent: Incomplete | None = None, - top_level_colon_align: Incomplete | None = None, - prefix_colon: Incomplete | None = None, + version: _VersionTuple | None = None, + tags: _TagHandleToPrefix | None = None, + block_seq_indent: Unused = None, + top_level_colon_align: Unused = None, + prefix_colon: Unused = None, ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi b/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi index 098f9ce1814e..6c054f47d1b5 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi @@ -1,12 +1,10 @@ -from _typeshed import Incomplete - class Version: def __init__(self, major: int, minor: int) -> None: ... @property def major(self) -> int: ... @property def minor(self) -> int: ... - def __eq__(self, v) -> bool: ... + def __eq__(self, v: Version) -> bool: ... def __lt__(self, v: Version) -> bool: ... def __le__(self, v: Version) -> bool: ... def __gt__(self, v: Version) -> bool: ... @@ -22,9 +20,9 @@ class Tag: def prefix(self) -> str: ... class DocInfo: - requested_version: Incomplete - doc_version: Incomplete - tags: Incomplete + requested_version: Version | None + doc_version: Version | None + tags: list[Tag] def __init__( self, requested_version: Version | None = None, doc_version: Version | None = None, tags: list[Tag] | None = None ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi index f9662cba514c..df14d579b69f 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi @@ -1,97 +1,95 @@ -from _typeshed import Incomplete -from typing_extensions import TypeAlias +from _typeshed import Unused -from .compat import StreamType -from .emitter import Emitter +from .compat import StreamType, VersionType +from .emitter import Emitter, _LineBreak from .representer import BaseRepresenter, Representer, RoundTripRepresenter, SafeRepresenter from .resolver import BaseResolver, Resolver, VersionedResolver from .serializer import Serializer +from .tag import _TagHandleToPrefix +from .tokens import _ScalarStyle __all__ = ["BaseDumper", "SafeDumper", "Dumper", "RoundTripDumper"] -# https://github.com/python/typeshed/pull/8973 -_Inf: TypeAlias = float - class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): def __init__( self, stream: StreamType, - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, + default_style: _ScalarStyle | None = None, + default_flow_style: bool | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, - encoding: Incomplete | None = None, + line_break: _LineBreak | None = None, + encoding: str | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Incomplete | None = None, - tags: Incomplete | None = None, - block_seq_indent: Incomplete | None = None, - top_level_colon_align: Incomplete | None = None, - prefix_colon: Incomplete | None = None, + version: VersionType | None = None, + tags: _TagHandleToPrefix | None = None, + block_seq_indent: int | None = None, + top_level_colon_align: Unused = None, + prefix_colon: Unused = None, ) -> None: ... class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): def __init__( self, stream: StreamType, - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, + default_style: _ScalarStyle | None = None, + default_flow_style: bool | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, - encoding: Incomplete | None = None, + line_break: _LineBreak | None = None, + encoding: str | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Incomplete | None = None, - tags: Incomplete | None = None, - block_seq_indent: Incomplete | None = None, - top_level_colon_align: Incomplete | None = None, - prefix_colon: Incomplete | None = None, + version: VersionType | None = None, + tags: _TagHandleToPrefix | None = None, + block_seq_indent: int | None = None, + top_level_colon_align: Unused = None, + prefix_colon: Unused = None, ) -> None: ... class Dumper(Emitter, Serializer, Representer, Resolver): def __init__( self, stream: StreamType, - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, + default_style: _ScalarStyle | None = None, + default_flow_style: bool | None = None, canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, - encoding: Incomplete | None = None, + line_break: _LineBreak | None = None, + encoding: str | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Incomplete | None = None, - tags: Incomplete | None = None, - block_seq_indent: Incomplete | None = None, - top_level_colon_align: Incomplete | None = None, - prefix_colon: Incomplete | None = None, + version: VersionType | None = None, + tags: _TagHandleToPrefix | None = None, + block_seq_indent: int | None = None, + top_level_colon_align: Unused = None, + prefix_colon: Unused = None, ) -> None: ... class RoundTripDumper(Emitter, Serializer, RoundTripRepresenter, VersionedResolver): def __init__( self, stream: StreamType, - default_style: Incomplete | None = None, + default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, - canonical: int | None = None, + canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, - encoding: Incomplete | None = None, + line_break: _LineBreak | None = None, + encoding: str | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, - version: Incomplete | None = None, - tags: Incomplete | None = None, - block_seq_indent: Incomplete | None = None, - top_level_colon_align: Incomplete | None = None, - prefix_colon: Incomplete | None = None, + version: VersionType | None = None, + tags: _TagHandleToPrefix | None = None, + block_seq_indent: int | None = None, + top_level_colon_align: bool | None = None, + prefix_colon: str | None = None, ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi index 9064839c264e..c6f6e1e847a9 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi @@ -1,27 +1,34 @@ -from _typeshed import Incomplete +from collections.abc import Callable +from typing import Final, Literal, TypeAlias from .compat import StreamType from .error import YAMLError -from .events import * +from .events import Event +from .main import YAML +from .serializer import Serializer +from .tag import Tag, _TagHandleToPrefix +from .tokens import CommentToken, _ScalarStyle, _VersionTuple + +_LineBreak: TypeAlias = Literal["\r", "\n", "\r\n"] __all__ = ["Emitter", "EmitterError"] class EmitterError(YAMLError): ... class ScalarAnalysis: - scalar: Incomplete - empty: Incomplete - multiline: Incomplete - allow_flow_plain: Incomplete - allow_block_plain: Incomplete - allow_single_quoted: Incomplete - allow_double_quoted: Incomplete - allow_block: Incomplete + scalar: str + empty: bool + multiline: bool + allow_flow_plain: bool + allow_block_plain: bool + allow_single_quoted: bool + allow_double_quoted: bool + allow_block: bool def __init__( self, - scalar, - empty, - multiline, + scalar: str, + empty: bool, + multiline: bool, allow_flow_plain: bool, allow_block_plain: bool, allow_single_quoted: bool, @@ -30,34 +37,34 @@ class ScalarAnalysis: ) -> None: ... class Indents: - values: Incomplete + values: list[tuple[int | None, bool | None]] def __init__(self) -> None: ... - def append(self, val, seq) -> None: ... - def pop(self): ... + def append(self, val: int | None, seq: bool | None) -> None: ... + def pop(self) -> int | None: ... def seq_seq(self) -> bool: ... - def last_seq(self) -> bool: ... + def last_seq(self) -> bool | None: ... def seq_flow_align(self, seq_indent: int, column: int, pre_comment: bool | None = False) -> int: ... def __len__(self) -> int: ... class Emitter: - DEFAULT_TAG_PREFIXES: Incomplete - MAX_SIMPLE_KEY_LENGTH: int - flow_seq_start: str - flow_seq_end: str - flow_seq_separator: str - flow_map_start: str - flow_map_end: str - flow_map_separator: str - dumper: Incomplete - encoding: Incomplete - allow_space_break: Incomplete - states: Incomplete - state: Incomplete - events: Incomplete - event: Incomplete - indents: Incomplete - indent: Incomplete - flow_context: Incomplete + DEFAULT_TAG_PREFIXES: Final[_TagHandleToPrefix] + MAX_SIMPLE_KEY_LENGTH: Final = 128 + flow_seq_start: Final = "[" + flow_seq_end: Final = "]" + flow_seq_separator: Final = "," + flow_map_start: Final = "{" + flow_map_end: Final = "}" + flow_map_separator: Final = "," + dumper: YAML | None + encoding: str | None + allow_space_break: bool | None + states: list[Callable[[], None]] + state: Callable[[], None] | None + events: list[Event] + event: Event | None + indents: Indents + indent: int | None + flow_context: list[str] root_context: bool sequence_context: bool mapping_context: bool @@ -68,58 +75,58 @@ class Emitter: indention: bool compact_seq_seq: bool compact_seq_map: bool - no_newline: Incomplete + no_newline: bool | None open_ended: bool colon: str - prefixed_colon: Incomplete - brace_single_entry_mapping_in_flow_sequence: Incomplete - canonical: Incomplete - allow_unicode: Incomplete - unicode_supplementary: Incomplete - sequence_dash_offset: Incomplete - top_level_colon_align: Incomplete + prefixed_colon: str + brace_single_entry_mapping_in_flow_sequence: bool | None + canonical: bool | None + allow_unicode: bool | None + unicode_supplementary: bool + sequence_dash_offset: int + top_level_colon_align: bool | None best_sequence_indent: int - requested_indent: Incomplete - best_map_indent: Incomplete + requested_indent: int | None + best_map_indent: int best_width: int - best_line_break: str - tag_prefixes: Incomplete - prepared_anchor: Incomplete - prepared_tag: Incomplete - analysis: Incomplete - style: Incomplete + best_line_break: _LineBreak + tag_prefixes: _TagHandleToPrefix | None + prepared_anchor: str | None + prepared_tag: str | None + analysis: ScalarAnalysis | None + style: _ScalarStyle | None scalar_after_indicator: bool alt_null: str def __init__( self, stream: StreamType, - canonical: Incomplete | None = None, + canonical: bool | None = None, indent: int | None = None, width: int | None = None, allow_unicode: bool | None = None, - line_break: Incomplete | None = None, + line_break: _LineBreak | None = None, block_seq_indent: int | None = None, top_level_colon_align: bool | None = None, - prefix_colon: Incomplete | None = None, + prefix_colon: str | None = None, brace_single_entry_mapping_in_flow_sequence: bool | None = None, - dumper: Incomplete | None = None, + dumper: YAML | None = None, ) -> None: ... @property - def stream(self): ... + def stream(self) -> StreamType: ... @stream.setter - def stream(self, val) -> None: ... + def stream(self, val: StreamType) -> None: ... @property - def serializer(self): ... + def serializer(self) -> Serializer: ... @property def flow_level(self) -> int: ... def dispose(self) -> None: ... - def emit(self, event) -> None: ... + def emit(self, event: Event) -> None: ... def need_more_events(self) -> bool: ... def need_events(self, count: int) -> bool: ... def increase_indent(self, flow: bool = False, sequence: bool | None = None, indentless: bool = False) -> None: ... def expect_stream_start(self) -> None: ... def expect_nothing(self) -> None: ... - def expect_first_document_start(self): ... + def expect_first_document_start(self) -> None: ... def expect_document_start(self, first: bool = False) -> None: ... def expect_document_end(self) -> None: ... def expect_document_root(self) -> None: ... @@ -137,7 +144,7 @@ class Emitter: def expect_flow_mapping_simple_value(self) -> None: ... def expect_flow_mapping_value(self) -> None: ... def expect_block_sequence(self) -> None: ... - def expect_first_block_sequence_item(self): ... + def expect_first_block_sequence_item(self) -> None: ... def expect_block_sequence_item(self, first: bool = False) -> None: ... def expect_block_mapping(self) -> None: ... def expect_first_block_mapping_key(self) -> None: ... @@ -148,34 +155,36 @@ class Emitter: def check_empty_mapping(self) -> bool: ... def check_empty_document(self) -> bool: ... def check_simple_key(self) -> bool: ... - def process_anchor(self, indicator) -> bool: ... + def process_anchor(self, indicator: str) -> bool: ... def process_tag(self) -> None: ... - def choose_scalar_style(self): ... + def choose_scalar_style(self) -> _ScalarStyle | None: ... def process_scalar(self) -> None: ... - def prepare_version(self, version): ... - def prepare_tag_handle(self, handle): ... - def prepare_tag_prefix(self, prefix): ... - def prepare_tag(self, tag): ... - def prepare_anchor(self, anchor): ... - def analyze_scalar(self, scalar): ... + def prepare_version(self, version: _VersionTuple) -> str: ... + def prepare_tag_handle(self, handle: str) -> str: ... + def prepare_tag_prefix(self, prefix: str) -> str: ... + def prepare_tag(self, tag: Tag) -> str: ... + def prepare_anchor(self, anchor: str) -> str: ... + def analyze_scalar(self, scalar: str) -> ScalarAnalysis: ... def flush_stream(self) -> None: ... def write_stream_start(self) -> None: ... def write_stream_end(self) -> None: ... - def write_indicator(self, indicator, need_whitespace, whitespace: bool = False, indention: bool = False) -> None: ... + def write_indicator( + self, indicator: str, need_whitespace: bool, whitespace: bool = False, indention: bool = False + ) -> None: ... def write_indent(self) -> None: ... - def write_line_break(self, data: Incomplete | None = None) -> None: ... - def write_version_directive(self, version_text) -> None: ... - def write_tag_directive(self, handle_text, prefix_text) -> None: ... - def write_single_quoted(self, text, split: bool = True) -> None: ... - ESCAPE_REPLACEMENTS: Incomplete - def write_double_quoted(self, text, split: bool = True) -> None: ... - def determine_block_hints(self, text): ... - def write_folded(self, text, comment) -> None: ... - def write_literal(self, text, comment: Incomplete | None = None) -> None: ... - def write_plain(self, text, split: bool = True) -> None: ... - def write_comment(self, comment, pre: bool = False) -> None: ... - def write_pre_comment(self, event) -> bool: ... - def write_post_comment(self, event) -> bool: ... + def write_line_break(self, data: str | None = None) -> None: ... + def write_version_directive(self, version_text: str) -> None: ... + def write_tag_directive(self, handle_text: str, prefix_text: str) -> None: ... + def write_single_quoted(self, text: str, split: bool = True) -> None: ... + ESCAPE_REPLACEMENTS: Final[dict[str, str]] + def write_double_quoted(self, text: str, split: bool = True) -> None: ... + def determine_block_hints(self, text: str) -> tuple[str, int, str]: ... + def write_folded(self, text: str, comment: str) -> None: ... + def write_literal(self, text: str, comment: str | None = None) -> None: ... + def write_plain(self, text: str, split: bool = True) -> None: ... + def write_comment(self, comment: CommentToken, pre: bool = False) -> None: ... + def write_pre_comment(self, event: Event) -> bool: ... + def write_post_comment(self, event: Event) -> bool: ... class RoundTripEmitter(Emitter): - def prepare_tag(self, ctag): ... + def prepare_tag(self, ctag: Tag) -> str: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/error.pyi b/stubs/ruamel.yaml/ruamel/yaml/error.pyi index 7eb7cc12bd32..9d60a77f261e 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/error.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/error.pyi @@ -1,4 +1,10 @@ -from _typeshed import Incomplete +from typing import ClassVar, Self, TypeAlias + +from _ruamel_yaml import Mark + +from .nodes import ScalarNode + +_Mark: TypeAlias = Mark | StreamMark __all__ = [ "FileMark", @@ -13,42 +19,42 @@ __all__ = [ ] class StreamMark: - name: Incomplete - index: Incomplete - line: Incomplete - column: Incomplete - def __init__(self, name, index: int, line: int, column: int) -> None: ... - def __eq__(self, other) -> bool: ... - def __ne__(self, other) -> bool: ... + name: str | None + index: int + line: int + column: int + def __init__(self, name: str | None, index: int, line: int, column: int) -> None: ... + def __eq__(self, other: Self, /) -> bool: ... + def __ne__(self, other: Self, /) -> bool: ... class FileMark(StreamMark): ... class StringMark(StreamMark): - buffer: Incomplete - pointer: Incomplete - def __init__(self, name, index: int, line: int, column: int, buffer, pointer) -> None: ... - def get_snippet(self, indent: int = 4, max_length: int = 75): ... + buffer: str + pointer: int + def __init__(self, name: str | None, index: int, line: int, column: int, buffer: str, pointer: int) -> None: ... + def get_snippet(self, indent: int = 4, max_length: int = 75) -> str: ... class CommentMark: - column: Incomplete - def __init__(self, column) -> None: ... + column: int + def __init__(self, column: int) -> None: ... class YAMLError(Exception): ... class MarkedYAMLError(YAMLError): - context: Incomplete - context_mark: Incomplete - problem: Incomplete - problem_mark: Incomplete - note: Incomplete + context: str | None + context_mark: _Mark | None + problem: str | None + problem_mark: _Mark | None + note: str | None def __init__( self, - context: Incomplete | None = None, - context_mark: Incomplete | None = None, - problem: Incomplete | None = None, - problem_mark: Incomplete | None = None, - note: Incomplete | None = None, - warn: Incomplete | None = None, + context: str | None = None, + context_mark: _Mark | None = None, + problem: str | None = None, + problem_mark: _Mark | None = None, + note: str | None = None, + warn: str | None = None, ) -> None: ... def check_append(self, lines: list[str], val: str | None) -> None: ... @@ -56,49 +62,49 @@ class YAMLStreamError(Exception): ... class YAMLWarning(Warning): ... class MarkedYAMLWarning(YAMLWarning): - context: Incomplete - context_mark: Incomplete - problem: Incomplete - problem_mark: Incomplete - note: Incomplete - warn: Incomplete + context: str | None + context_mark: _Mark | None + problem: str | None + problem_mark: _Mark | None + note: str | None + warn: str | None def __init__( self, - context: Incomplete | None = None, - context_mark: Incomplete | None = None, - problem: Incomplete | None = None, - problem_mark: Incomplete | None = None, - note: Incomplete | None = None, - warn: Incomplete | None = None, + context: str | None = None, + context_mark: _Mark | None = None, + problem: str | None = None, + problem_mark: _Mark | None = None, + note: str | None = None, + warn: str | None = None, ) -> None: ... def check_append(self, lines: list[str], val: str | None) -> None: ... class ReusedAnchorWarning(YAMLWarning): ... class UnsafeLoaderWarning(YAMLWarning): - text: str + text: ClassVar[str] class MantissaNoDotYAML1_1Warning(YAMLWarning): - node: Incomplete - flt: Incomplete - def __init__(self, node, flt_str) -> None: ... + node: ScalarNode + flt: str + def __init__(self, node: ScalarNode, flt_str: str) -> None: ... class YAMLFutureWarning(Warning): ... class MarkedYAMLFutureWarning(YAMLFutureWarning): - context: Incomplete - context_mark: Incomplete - problem: Incomplete - problem_mark: Incomplete - note: Incomplete - warn: Incomplete + context: str | None + context_mark: _Mark | None + problem: str | None + problem_mark: _Mark | None + note: str | None + warn: str | None def __init__( self, - context: Incomplete | None = None, - context_mark: Incomplete | None = None, - problem: Incomplete | None = None, - problem_mark: Incomplete | None = None, - note: Incomplete | None = None, - warn: Incomplete | None = None, + context: str | None = None, + context_mark: _Mark | None = None, + problem: str | None = None, + problem_mark: _Mark | None = None, + note: str | None = None, + warn: str | None = None, ) -> None: ... def check_append(self, lines: list[str], val: str | None) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/events.pyi b/stubs/ruamel.yaml/ruamel/yaml/events.pyi index a5f845aa5b1a..96adbfcb3737 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/events.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/events.pyi @@ -1,37 +1,46 @@ -from _typeshed import Incomplete +from _typeshed import sentinel +from typing import ClassVar, Final, Literal -SHOW_LINES: bool +from .error import _Mark +from .tag import Tag, _TagHandleToPrefix +from .tokens import _CommentGroup, _ScalarStyle, _VersionTuple -def CommentCheck() -> None: ... +SHOW_LINES: bool class Event: - crepr: str - start_mark: Incomplete - end_mark: Incomplete - comment: Incomplete - def __init__(self, start_mark: Incomplete | None = None, end_mark: Incomplete | None = None, comment=...) -> None: ... + crepr: ClassVar[str] + start_mark: _Mark | None + end_mark: _Mark | None + comment: _CommentGroup | None + def __init__( + self, start_mark: _Mark | None = None, end_mark: _Mark | None = None, comment: _CommentGroup | None = sentinel + ) -> None: ... def compact_repr(self) -> str: ... class NodeEvent(Event): - anchor: Incomplete + anchor: str | None def __init__( - self, anchor, start_mark: Incomplete | None = None, end_mark: Incomplete | None = None, comment: Incomplete | None = None + self, + anchor: str | None, + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + comment: _CommentGroup | None = None, ) -> None: ... class CollectionStartEvent(NodeEvent): - ctag: Incomplete - implicit: Incomplete - flow_style: Incomplete - nr_items: Incomplete + ctag: Tag | str | None + implicit: bool + flow_style: bool | None + nr_items: int | None def __init__( self, - anchor, - tag, - implicit, - start_mark: Incomplete | None = None, - end_mark: Incomplete | None = None, - flow_style: Incomplete | None = None, - comment: Incomplete | None = None, + anchor: str | None, + tag: Tag | str | None, + implicit: bool, + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + flow_style: bool | None = None, + comment: _CommentGroup | None = None, nr_items: int | None = None, ) -> None: ... @property @@ -39,94 +48,96 @@ class CollectionStartEvent(NodeEvent): class CollectionEndEvent(Event): ... +# Implementations. + class StreamStartEvent(Event): - crepr: str - encoding: Incomplete + crepr: Final = "+STR" + encoding: str | None def __init__( self, - start_mark: Incomplete | None = None, - end_mark: Incomplete | None = None, - encoding: Incomplete | None = None, - comment: Incomplete | None = None, + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + encoding: str | None = None, + comment: _CommentGroup | None = None, ) -> None: ... class StreamEndEvent(Event): - crepr: str + crepr: Final = "-STR" class DocumentStartEvent(Event): - crepr: str - explicit: Incomplete - version: Incomplete - tags: Incomplete + crepr: Final = "+DOC" + explicit: bool | None + version: _VersionTuple | None + tags: _TagHandleToPrefix | None def __init__( self, - start_mark: Incomplete | None = None, - end_mark: Incomplete | None = None, - explicit: Incomplete | None = None, - version: Incomplete | None = None, - tags: Incomplete | None = None, - comment: Incomplete | None = None, + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + explicit: bool | None = None, + version: _VersionTuple | None = None, + tags: _TagHandleToPrefix | None = None, + comment: _CommentGroup | None = None, ) -> None: ... def compact_repr(self) -> str: ... class DocumentEndEvent(Event): - crepr: str - explicit: Incomplete + crepr: Final = "-DOC" + explicit: bool | None def __init__( self, - start_mark: Incomplete | None = None, - end_mark: Incomplete | None = None, - explicit: Incomplete | None = None, - comment: Incomplete | None = None, + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + explicit: bool | None = None, + comment: _CommentGroup | None = None, ) -> None: ... def compact_repr(self) -> str: ... class AliasEvent(NodeEvent): - crepr: str - style: Incomplete + crepr: Final = "=ALI" + style: Literal["?"] | None def __init__( self, - anchor, - start_mark: Incomplete | None = None, - end_mark: Incomplete | None = None, - style: Incomplete | None = None, - comment: Incomplete | None = None, + anchor: str, + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + style: Literal["?"] | None = None, + comment: _CommentGroup | None = None, ) -> None: ... def compact_repr(self) -> str: ... class ScalarEvent(NodeEvent): - crepr: str - ctag: Incomplete - implicit: Incomplete - value: Incomplete - style: Incomplete + crepr: Final = "=VAL" + ctag: Tag | None + implicit: tuple[bool, bool] + value: str + style: _ScalarStyle | None def __init__( self, - anchor, - tag, - implicit, - value, - start_mark: Incomplete | None = None, - end_mark: Incomplete | None = None, - style: Incomplete | None = None, - comment: Incomplete | None = None, + anchor: str | None, + tag: Tag | None, + implicit: tuple[bool, bool], + value: str, + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + style: _ScalarStyle | None = None, + comment: _CommentGroup | None = None, ) -> None: ... @property def tag(self) -> str | None: ... @tag.setter - def tag(self, val) -> None: ... + def tag(self, val: Tag | str) -> None: ... def compact_repr(self) -> str: ... class SequenceStartEvent(CollectionStartEvent): - crepr: str + crepr: Final = "+SEQ" def compact_repr(self) -> str: ... class SequenceEndEvent(CollectionEndEvent): - crepr: str + crepr: Final = "-SEQ" class MappingStartEvent(CollectionStartEvent): - crepr: str + crepr: Final = "+MAP" def compact_repr(self) -> str: ... class MappingEndEvent(CollectionEndEvent): - crepr: str + crepr: Final = "-MAP" diff --git a/stubs/ruamel.yaml/ruamel/yaml/loader.pyi b/stubs/ruamel.yaml/ruamel/yaml/loader.pyi index cf526a50ec1f..4e01db1416f8 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/loader.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/loader.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Unused from .compat import StreamTextType, VersionType from .composer import Composer @@ -11,25 +11,19 @@ from .scanner import RoundTripScanner, Scanner __all__ = ["BaseLoader", "SafeLoader", "Loader", "RoundTripLoader"] class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, VersionedResolver): - comment_handling: Incomplete - def __init__( - self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None - ) -> None: ... + comment_handling: int | None + def __init__(self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, VersionedResolver): - comment_handling: Incomplete - def __init__( - self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None - ) -> None: ... + comment_handling: int | None + def __init__(self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... class Loader(Reader, Scanner, Parser, Composer, Constructor, VersionedResolver): - comment_handling: Incomplete - def __init__( - self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None - ) -> None: ... + comment_handling: int | None + def __init__(self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... class RoundTripLoader(Reader, RoundTripScanner, RoundTripParser, Composer, RoundTripConstructor, VersionedResolver): - comment_handling: Incomplete + comment_handling: int | None def __init__( self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi index 312a367d6f2d..f60874558d5e 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi @@ -1,62 +1,76 @@ -from _typeshed import Incomplete +from typing import Any, Final, Generic, Literal, TypeVar +from typing_extensions import TypeAlias + +from .anchor import Anchor +from .error import _Mark +from .tag import Tag +from .tokens import _CommentGroup, _ScalarStyle + +_T = TypeVar("_T") + +_ScalarNodeStyle: TypeAlias = Literal["?", "-"] | _ScalarStyle class Node: - ctag: Incomplete - value: Incomplete - start_mark: Incomplete - end_mark: Incomplete - comment: Incomplete - anchor: Incomplete + ctag: Tag + value: Any + start_mark: _Mark | None + end_mark: _Mark | None + comment: _CommentGroup | None + anchor: Anchor | str | None def __init__( - self, tag, value, start_mark, end_mark, comment: Incomplete | None = None, anchor: Incomplete | None = None + self, + tag: Tag | str | None, + value: Any, + start_mark: _Mark | None, + end_mark: _Mark | None, + *, + comment: _CommentGroup | None = None, + anchor: Anchor | str | None = None, ) -> None: ... @property def tag(self) -> str | None: ... @tag.setter - def tag(self, val) -> None: ... - def dump(self, indent: int = 0) -> None: ... + def tag(self, val: Tag | str | None, /) -> None: ... + def dump(self, *, indent: int = 0) -> None: ... class ScalarNode(Node): - id: str - style: Incomplete + id: Final = "scalar" + value: str + style: _ScalarNodeStyle | None def __init__( self, - tag, - value, - start_mark: Incomplete | None = None, - end_mark: Incomplete | None = None, - style: Incomplete | None = None, - comment: Incomplete | None = None, - anchor: Incomplete | None = None, + tag: Tag | str | None, + value: str, + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + *, + style: _ScalarNodeStyle | None = None, + comment: _CommentGroup | None = None, + anchor: Anchor | str | None = None, ) -> None: ... -class CollectionNode(Node): - flow_style: Incomplete - anchor: Incomplete +class _CollectionNode(Generic[_T]): + value: list[_T] + flow_style: bool | None def __init__( self, - tag, - value, - start_mark: Incomplete | None = None, - end_mark: Incomplete | None = None, - flow_style: Incomplete | None = None, - comment: Incomplete | None = None, - anchor: Incomplete | None = None, + tag: Tag | str, + value: list[_T], + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + *, + flow_style: bool | None = None, + comment: _CommentGroup | None = None, + anchor: Anchor | str | None = None, ) -> None: ... -class SequenceNode(CollectionNode): - id: str +class CollectionNode(_CollectionNode[Any], Node): ... +class _SequenceNode(_CollectionNode[Node]): ... +class _MappingNode(_CollectionNode[tuple[Node, Node]]): ... -class MappingNode(CollectionNode): - id: str - merge: Incomplete - def __init__( - self, - tag, - value, - start_mark: Incomplete | None = None, - end_mark: Incomplete | None = None, - flow_style: Incomplete | None = None, - comment: Incomplete | None = None, - anchor: Incomplete | None = None, - ) -> None: ... +class SequenceNode(_SequenceNode, CollectionNode): + id: Final = "sequence" + +class MappingNode(_MappingNode, CollectionNode): + id: Final = "mapping" + merge: list[tuple[Node, Node]] | None diff --git a/stubs/ruamel.yaml/ruamel/yaml/parser.pyi b/stubs/ruamel.yaml/ruamel/yaml/parser.pyi index 24404d47698b..43f318b47dbf 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/parser.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/parser.pyi @@ -1,66 +1,70 @@ -from _typeshed import Incomplete +from collections.abc import Callable +from typing import Final -from .error import MarkedYAMLError -from .events import * -from .tag import Tag -from .tokens import * +from .error import MarkedYAMLError, _Mark +from .events import Event +from .main import YAML +from .resolver import BaseResolver +from .scanner import Scanner +from .tag import Tag, _TagHandleToPrefix +from .tokens import CommentToken, Token, _VersionTuple __all__ = ["Parser", "RoundTripParser", "ParserError"] class ParserError(MarkedYAMLError): ... class Parser: - DEFAULT_TAGS: Incomplete - loader: Incomplete - def __init__(self, loader) -> None: ... - current_event: Incomplete - tag_handles: Incomplete - states: Incomplete - marks: Incomplete - state: Incomplete + DEFAULT_TAGS: Final[_TagHandleToPrefix] + loader: YAML + def __init__(self, loader: YAML) -> None: ... + current_event: Event | None + last_event: Event | None + tag_handles: _TagHandleToPrefix + states: list[Callable[[], Event]] + marks: list[_Mark] + state: Callable[[], Event] def reset_parser(self) -> None: ... def dispose(self) -> None: ... @property - def scanner(self): ... + def scanner(self) -> Scanner: ... @property - def resolver(self): ... - def check_event(self, *choices) -> bool: ... - def peek_event(self): ... - last_event: Incomplete - def get_event(self): ... - def parse_stream_start(self): ... - def parse_implicit_document_start(self): ... - def parse_document_start(self): ... - def parse_document_end(self): ... - def parse_document_content(self): ... - def process_directives(self): ... - def parse_block_node(self): ... - def parse_flow_node(self): ... - def parse_block_node_or_indentless_sequence(self): ... + def resolver(self) -> BaseResolver: ... + def check_event(self, *choices: type[Event]) -> bool: ... + def peek_event(self) -> Event: ... + def get_event(self) -> Event: ... + def parse_stream_start(self) -> Event: ... + def parse_implicit_document_start(self) -> Event: ... + def parse_document_start(self) -> Event: ... + def parse_document_end(self) -> Event: ... + def parse_document_content(self) -> Event: ... + def process_directives(self) -> tuple[_VersionTuple | None, _TagHandleToPrefix | None]: ... + def parse_block_node(self) -> Event: ... + def parse_flow_node(self) -> Event: ... + def parse_block_node_or_indentless_sequence(self) -> Event: ... def select_tag_transform(self, tag: Tag) -> None: ... - def parse_node(self, block: bool = False, indentless_sequence: bool = False): ... - def parse_block_sequence_first_entry(self): ... - def parse_block_sequence_entry(self): ... - def parse_indentless_sequence_entry(self): ... - def parse_block_mapping_first_key(self): ... - def parse_block_mapping_key(self): ... - def parse_block_mapping_value(self): ... - def parse_flow_sequence_first_entry(self): ... - def parse_flow_sequence_entry(self, first: bool = False): ... - def parse_flow_sequence_entry_mapping_key(self): ... - def parse_flow_sequence_entry_mapping_value(self): ... - def parse_flow_sequence_entry_mapping_end(self): ... - def parse_flow_mapping_first_key(self): ... - def parse_flow_mapping_key(self, first: bool = False): ... - def parse_flow_mapping_value(self): ... - def parse_flow_mapping_empty_value(self): ... - def process_empty_scalar(self, mark, comment: Incomplete | None = None): ... - def move_token_comment(self, token, nt: Incomplete = None, empty: bool | None = False): ... + def parse_node(self, block: bool = False, indentless_sequence: bool = False) -> Event: ... + def parse_block_sequence_first_entry(self) -> Event: ... + def parse_block_sequence_entry(self) -> Event: ... + def parse_indentless_sequence_entry(self) -> Event: ... + def parse_block_mapping_first_key(self) -> Event: ... + def parse_block_mapping_key(self) -> Event: ... + def parse_block_mapping_value(self) -> Event: ... + def parse_flow_sequence_first_entry(self) -> Event: ... + def parse_flow_sequence_entry(self, first: bool = False) -> Event: ... + def parse_flow_sequence_entry_mapping_key(self) -> Event: ... + def parse_flow_sequence_entry_mapping_value(self) -> Event: ... + def parse_flow_sequence_entry_mapping_end(self) -> Event: ... + def parse_flow_mapping_first_key(self) -> Event: ... + def parse_flow_mapping_key(self, first: bool = False) -> Event: ... + def parse_flow_mapping_value(self) -> Event: ... + def parse_flow_mapping_empty_value(self) -> Event: ... + def process_empty_scalar(self, mark: _Mark, comment: list[CommentToken | None] | list[None] | None = None) -> Event: ... + def move_token_comment(self, token: Token, nt: Token | None = None, empty: bool | None = False) -> None: ... class RoundTripParser(Parser): def select_tag_transform(self, tag: Tag) -> None: ... - def move_token_comment(self, token, nt: Incomplete = None, empty: bool | None = False): ... + def move_token_comment(self, token: Token, nt: Token | None = None, empty: bool | None = False) -> None: ... class RoundTripParserSC(RoundTripParser): - def move_token_comment(self, token, nt: Incomplete | None = None, empty: bool | None = False) -> None: ... - def distribute_comment(self, comment, line): ... + def move_token_comment(self, token: Token, nt: Token | None = None, empty: bool | None = False) -> None: ... + def distribute_comment(self, comment: list[list[int] | None] | None, line: int) -> list[list[int] | None]: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/reader.pyi b/stubs/ruamel.yaml/ruamel/yaml/reader.pyi index 5894127b229e..0ac524c67a3d 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/reader.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/reader.pyi @@ -1,43 +1,51 @@ -from _typeshed import Incomplete +from _typeshed import ReadableBuffer, SupportsRead +from re import Pattern +from typing import Final, Literal, Protocol -from .error import YAMLError +from .compat import StreamTextType +from .error import StreamMark, YAMLError +from .main import YAML + +# One of codecs.{utf_16_le_decode, utf_16_be_decode, utf_8_decode} +class _BufferDecoder(Protocol): + def __call__(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ... __all__ = ["Reader", "ReaderError"] class ReaderError(YAMLError): - name: Incomplete - character: Incomplete - position: Incomplete - encoding: Incomplete - reason: Incomplete - def __init__(self, name, position, character, encoding, reason) -> None: ... + name: str | None + character: int + position: int + encoding: str + reason: str + def __init__(self, name: str | None, position: int, character: int, encoding: str, reason: str) -> None: ... class Reader: - loader: Incomplete - def __init__(self, stream, loader: Incomplete | None = None) -> None: ... - name: Incomplete + loader: YAML | None + def __init__(self, stream: StreamTextType | None, loader: YAML | None = None) -> None: ... + name: str | None stream_pointer: int eof: bool buffer: str pointer: int - raw_buffer: Incomplete - raw_decode: Incomplete - encoding: Incomplete + raw_buffer: str | bytes | None + raw_decode: _BufferDecoder | None + encoding: Literal["utf-16-le", "utf-16-be", "utf-8"] | None index: int line: int column: int def reset_reader(self) -> None: ... @property - def stream(self): ... + def stream(self) -> SupportsRead[str | bytes] | None: ... @stream.setter - def stream(self, val) -> None: ... + def stream(self, val: StreamTextType | None, /) -> None: ... def peek(self, index: int = 0) -> str: ... - def prefix(self, length: int = 1): ... + def prefix(self, length: int = 1) -> str: ... def forward_1_1(self, length: int = 1) -> None: ... def forward(self, length: int = 1) -> None: ... - def get_mark(self): ... + def get_mark(self) -> StreamMark: ... def determine_encoding(self) -> None: ... - NON_PRINTABLE: Incomplete - def check_printable(self, data) -> None: ... + NON_PRINTABLE: Final[Pattern[str]] + def check_printable(self, data: str) -> None: ... def update(self, length: int) -> None: ... def update_raw(self, size: int | None = None) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi index e71b1b8a7e4b..5c05704673bb 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi @@ -1,100 +1,126 @@ -from _typeshed import Incomplete +from _typeshed import Unused +from collections import OrderedDict +from collections.abc import Collection, Mapping, Set as AbstractSet +from datetime import date, datetime +from types import ModuleType +from typing import Any, ClassVar, Final, NoReturn, Protocol, Self, TypeVar -from .error import * -from .nodes import * +from .anchor import Anchor +from .comments import CommentedMap, CommentedSeq, CommentedSet, TaggedScalar +from .error import YAMLError +from .main import YAML +from .nodes import MappingNode, Node, ScalarNode, SequenceNode +from .scalarbool import ScalarBoolean +from .scalarfloat import ScalarFloat +from .scalarint import BinaryInt, HexCapsInt, HexInt, OctalInt, ScalarInt, _Underscore +from .scalarstring import ( + DoubleQuotedScalarString, + FoldedScalarString, + LiteralScalarString, + PlainScalarString, + SingleQuotedScalarString, +) +from .serializer import Serializer +from .tag import Tag +from .timestamp import TimeStamp +from .tokens import _CommentGroup, _ScalarStyle + +_T = TypeVar("_T") +_T_contra = TypeVar("_T_contra", contravariant=True) +_Representer = TypeVar("_Representer", bound=BaseRepresenter, contravariant=True) + +class _RepresenterFunction(Protocol[_Representer, _T_contra]): + def __call__(self, dumper: _Representer, data: _T_contra, /) -> Node: ... __all__ = ["BaseRepresenter", "SafeRepresenter", "Representer", "RepresenterError", "RoundTripRepresenter"] class RepresenterError(YAMLError): ... class BaseRepresenter: - yaml_representers: dict - yaml_multi_representers: dict - dumper: Incomplete - default_style: Incomplete - default_flow_style: Incomplete - represented_objects: Incomplete - object_keeper: Incomplete - alias_key: Incomplete + yaml_representers: ClassVar[dict[type | None, _RepresenterFunction[Self, Any]]] + yaml_multi_representers: ClassVar[dict[type | None, _RepresenterFunction[Self, Any]]] + dumper: YAML | None + default_style: _ScalarStyle | None + default_flow_style: bool | None + represented_objects: dict[int, Node] + object_keeper: list[Any] + alias_key: int | None sort_base_mapping_type_on_output: bool def __init__( - self, - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, - dumper: Incomplete | None = None, + self, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, dumper: YAML | None = None ) -> None: ... @property - def serializer(self): ... - def represent(self, data) -> None: ... - def represent_data(self, data): ... - def represent_key(self, data): ... + def serializer(self) -> Serializer: ... + def represent(self, data: Any) -> None: ... + def represent_data(self, data: Any) -> Node: ... + def represent_key(self, data: Any) -> Node: ... @classmethod - def add_representer(cls, data_type, representer) -> None: ... + def add_representer(cls, data_type: type[_T] | None, representer: _RepresenterFunction[Self, _T]) -> None: ... @classmethod - def add_multi_representer(cls, data_type, representer) -> None: ... - def represent_scalar(self, tag, value, style: Incomplete | None = None, anchor: Incomplete | None = None) -> ScalarNode: ... - def represent_sequence(self, tag, sequence, flow_style: Incomplete | None = None) -> SequenceNode: ... - def represent_omap(self, tag, omap, flow_style: Incomplete | None = None) -> SequenceNode: ... - def represent_mapping(self, tag, mapping, flow_style: Incomplete | None = None) -> MappingNode: ... - def ignore_aliases(self, data) -> bool: ... + def add_multi_representer(cls, data_type: type[_T] | None, representer: _RepresenterFunction[Self, _T]) -> None: ... + def represent_scalar( + self, tag: Tag | str, value: str, style: _ScalarStyle | None = None, anchor: Anchor | None = None + ) -> ScalarNode: ... + def represent_sequence(self, tag: Tag | str, sequence: Collection[Any], flow_style: bool | None = None) -> SequenceNode: ... + def represent_omap(self, tag: Tag | str, omap: OrderedDict[Any, Any], flow_style: bool | None = None) -> SequenceNode: ... + def represent_mapping(self, tag: Tag | str, mapping: Mapping[Any, Any], flow_style: bool | None = None) -> MappingNode: ... + def ignore_aliases(self, data: Any) -> bool: ... class SafeRepresenter(BaseRepresenter): - def ignore_aliases(self, data) -> bool: ... - def represent_none(self, data) -> ScalarNode: ... - def represent_str(self, data): ... - def represent_binary(self, data) -> ScalarNode: ... - def represent_bool(self, data, anchor: Incomplete = None) -> ScalarNode: ... - def represent_int(self, data) -> ScalarNode: ... - inf_value: float - def represent_float(self, data) -> ScalarNode: ... - def represent_list(self, data) -> SequenceNode: ... - def represent_dict(self, data) -> MappingNode: ... - def represent_ordereddict(self, data) -> SequenceNode: ... - def represent_set(self, data) -> MappingNode: ... - def represent_date(self, data) -> ScalarNode: ... - def represent_datetime(self, data) -> ScalarNode: ... - def represent_yaml_object(self, tag, data, cls, flow_style: Incomplete | None = None) -> MappingNode: ... - def represent_undefined(self, data) -> None: ... + def ignore_aliases(self, data: Any) -> bool: ... + def represent_none(self, data: None) -> ScalarNode: ... + def represent_str(self, data: str) -> ScalarNode: ... + def represent_binary(self, data: bytes) -> ScalarNode: ... + def represent_bool(self, data: bool, anchor: Anchor | None = None) -> ScalarNode: ... + def represent_int(self, data: int) -> ScalarNode: ... + inf_value: Final[float] + def represent_float(self, data: float) -> ScalarNode: ... + def represent_list(self, data: Collection[Any]) -> SequenceNode: ... + def represent_dict(self, data: Mapping[Any, Any]) -> MappingNode: ... + def represent_ordereddict(self, data: OrderedDict[Any, Any]) -> SequenceNode: ... + def represent_set(self, data: AbstractSet[Any]) -> MappingNode: ... + def represent_date(self, data: date) -> ScalarNode: ... + def represent_datetime(self, data: datetime) -> ScalarNode: ... + def represent_yaml_object(self, tag: Tag | str, data: Any, cls: Unused, flow_style: bool | None = None) -> MappingNode: ... + def represent_undefined(self, data: object) -> NoReturn: ... class Representer(SafeRepresenter): - def represent_complex(self, data): ... - def represent_tuple(self, data) -> SequenceNode: ... - def represent_name(self, data) -> ScalarNode: ... - def represent_module(self, data) -> ScalarNode: ... - def represent_object(self, data) -> SequenceNode | MappingNode: ... + def represent_complex(self, data: complex) -> ScalarNode: ... + def represent_tuple(self, data: tuple[Any, ...]) -> SequenceNode: ... + def represent_name(self, data: Any) -> ScalarNode: ... + def represent_module(self, data: ModuleType) -> ScalarNode: ... + def represent_object(self, data: Any) -> Node: ... class RoundTripRepresenter(SafeRepresenter): def __init__( - self, - default_style: Incomplete | None = None, - default_flow_style: Incomplete | None = None, - dumper: Incomplete | None = None, + self, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, dumper: YAML | None = None ) -> None: ... - def ignore_aliases(self, data) -> bool: ... - def represent_none(self, data) -> ScalarNode: ... - def represent_literal_scalarstring(self, data) -> ScalarNode: ... + def ignore_aliases(self, data: Any) -> bool: ... + def represent_none(self, data: None) -> ScalarNode: ... + def represent_literal_scalarstring(self, data: LiteralScalarString) -> ScalarNode: ... represent_preserved_scalarstring = represent_literal_scalarstring - def represent_folded_scalarstring(self, data) -> ScalarNode: ... - def represent_single_quoted_scalarstring(self, data) -> ScalarNode: ... - def represent_double_quoted_scalarstring(self, data) -> ScalarNode: ... - def represent_plain_scalarstring(self, data) -> ScalarNode: ... - def insert_underscore(self, prefix, s, underscore, anchor: Incomplete | None = None) -> ScalarNode: ... - def represent_scalar_int(self, data) -> ScalarNode: ... - def represent_binary_int(self, data) -> ScalarNode: ... - def represent_octal_int(self, data) -> ScalarNode: ... - def represent_hex_int(self, data) -> ScalarNode: ... - def represent_hex_caps_int(self, data) -> ScalarNode: ... - def represent_scalar_float(self, data) -> ScalarNode: ... - def represent_sequence(self, tag, sequence, flow_style: Incomplete | None = None) -> SequenceNode: ... - def merge_comments(self, node, comments): ... - alias_key: Incomplete - def represent_key(self, data): ... - def represent_mapping(self, tag, mapping, flow_style: Incomplete | None = None) -> MappingNode: ... - def represent_omap(self, tag, omap, flow_style: Incomplete | None = None) -> SequenceNode: ... - def represent_set(self, setting) -> MappingNode: ... - def represent_dict(self, data) -> MappingNode: ... - def represent_list(self, data) -> SequenceNode: ... - def represent_datetime(self, data) -> ScalarNode: ... - def represent_tagged_scalar(self, data) -> ScalarNode: ... - def represent_scalar_bool(self, data) -> ScalarNode: ... - def represent_yaml_object(self, tag, data, cls, flow_style: Incomplete = None) -> MappingNode: ... + def represent_folded_scalarstring(self, data: FoldedScalarString) -> ScalarNode: ... + def represent_single_quoted_scalarstring(self, data: SingleQuotedScalarString) -> ScalarNode: ... + def represent_double_quoted_scalarstring(self, data: DoubleQuotedScalarString) -> ScalarNode: ... + def represent_plain_scalarstring(self, data: PlainScalarString) -> ScalarNode: ... + def insert_underscore( + self, prefix: str, s: str, underscore: _Underscore | None, anchor: Anchor | None = None + ) -> ScalarNode: ... + def represent_scalar_int(self, data: ScalarInt) -> ScalarNode: ... + def represent_binary_int(self, data: BinaryInt) -> ScalarNode: ... + def represent_octal_int(self, data: OctalInt) -> ScalarNode: ... + def represent_hex_int(self, data: HexInt) -> ScalarNode: ... + def represent_hex_caps_int(self, data: HexCapsInt) -> ScalarNode: ... + def represent_scalar_float(self, data: ScalarFloat) -> ScalarNode: ... + def represent_sequence(self, tag: Tag | str, sequence: Collection[Any], flow_style: bool | None = None) -> SequenceNode: ... + def merge_comments(self, node: Node, comments: _CommentGroup | None) -> Node: ... + def represent_key(self, data: Any) -> Node: ... + def represent_mapping(self, tag: Tag | str, mapping: Mapping[Any, Any], flow_style: bool | None = None) -> MappingNode: ... + def represent_omap(self, tag: Tag | str, omap: OrderedDict[Any, Any], flow_style: bool | None = None) -> SequenceNode: ... + def represent_set(self, setting: CommentedSet[Any]) -> MappingNode: ... + def represent_dict(self, data: CommentedMap[Any, Any]) -> MappingNode: ... + def represent_list(self, data: CommentedSeq[Any]) -> SequenceNode: ... + def represent_datetime(self, data: TimeStamp) -> ScalarNode: ... + def represent_tagged_scalar(self, data: TaggedScalar) -> ScalarNode: ... + def represent_scalar_bool(self, data: ScalarBoolean) -> ScalarNode: ... + def represent_yaml_object(self, tag: Tag | str, data: Any, cls: Unused, flow_style: bool | None = None) -> MappingNode: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi index 02db7d47c839..09db08b3cbaf 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi @@ -1,47 +1,63 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from re import Pattern +from typing import Any, Final, TypeAlias, overload from .compat import VersionType -from .error import * +from .error import YAMLError +from .main import YAML +from .nodes import CollectionNode, MappingNode, Node, ScalarNode, SequenceNode +from .parser import Parser +from .tag import Tag +from .tokens import _VersionTuple + +_TagStr: TypeAlias = str +_First: TypeAlias = str | None __all__ = ["BaseResolver", "Resolver", "VersionedResolver"] +implicit_resolvers: list[tuple[list[_VersionTuple], _TagStr, Pattern[str], list[_First]]] + class ResolverError(YAMLError): ... class BaseResolver: - DEFAULT_SCALAR_TAG: Incomplete - DEFAULT_SEQUENCE_TAG: Incomplete - DEFAULT_MAPPING_TAG: Incomplete - yaml_implicit_resolvers: dict - yaml_path_resolvers: dict - loadumper: Incomplete - resolver_exact_paths: Incomplete - resolver_prefix_paths: Incomplete - def __init__(self, loadumper: Incomplete | None = None) -> None: ... + DEFAULT_SCALAR_TAG: Final[Tag] + DEFAULT_SEQUENCE_TAG: Final[Tag] + DEFAULT_MAPPING_TAG: Final[Tag] + yaml_implicit_resolvers: dict[_First, list[tuple[_TagStr, Pattern[str]]]] + yaml_path_resolvers: dict[Any, _TagStr] + loadumper: YAML | None + resolver_exact_paths: list[Any] + resolver_prefix_paths: list[Any] + def __init__(self, loadumper: YAML | None = None) -> None: ... @property - def parser(self): ... + def parser(self) -> Parser | None: ... @classmethod - def add_implicit_resolver_base(cls, tag, regexp, first) -> None: ... + def add_implicit_resolver_base(cls, tag: _TagStr, regexp: Pattern[str], first: list[_First] | None) -> None: ... @classmethod - def add_implicit_resolver(cls, tag, regexp, first) -> None: ... + def add_implicit_resolver(cls, tag: _TagStr, regexp: Pattern[str], first: list[_First] | None) -> None: ... @classmethod - def add_path_resolver(cls, tag, path, kind: Incomplete | None = None) -> None: ... - def descend_resolver(self, current_node, current_index) -> None: ... + def add_path_resolver(cls, tag: _TagStr, path: Iterable[Any], kind: type | None = None) -> None: ... + def descend_resolver(self, current_node: CollectionNode | None, current_index: int | Node | None) -> None: ... def ascend_resolver(self) -> None: ... def check_resolver_prefix(self, depth: int, path, kind, current_node, current_index) -> bool: ... - def resolve(self, kind, value, implicit): ... + @overload + def resolve(self, kind: type[ScalarNode], value: str, implicit: tuple[bool, bool]) -> Tag: ... + @overload + def resolve(self, kind: type[SequenceNode], value: list[Node] | None, implicit: bool) -> Tag: ... + @overload + def resolve(self, kind: type[MappingNode], value: list[tuple[Node, Node]] | None, implicit: bool) -> Tag: ... @property def processing_version(self) -> None: ... class Resolver(BaseResolver): ... class VersionedResolver(BaseResolver): - def __init__( - self, version: VersionType | None = None, loader: Incomplete | None = None, loadumper: Incomplete | None = None + def __init__(self, version: VersionType | None = None, loader: YAML | None = None, loadumper: YAML | None = None) -> None: ... + def add_version_implicit_resolver( + self, version: VersionType, tag: _TagStr, regexp: Pattern[str], first: list[_First] | None ) -> None: ... - def add_version_implicit_resolver(self, version: VersionType, tag, regexp, first) -> None: ... - def get_loader_version(self, version: VersionType | None): ... + def get_loader_version(self, version: VersionType | None) -> _VersionTuple | None: ... @property - def versioned_resolver(self): ... - def resolve(self, kind, value, implicit): ... + def versioned_resolver(self) -> dict[_First, list[tuple[_TagStr, Pattern[str]]]]: ... @property - def processing_version(self): ... + def processing_version(self) -> _VersionTuple: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi index a7502d1126a6..f3819e541329 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi @@ -1,8 +1,10 @@ +from .anchor import Anchor + __all__ = ["ScalarBoolean"] class ScalarBoolean(int): - def __new__(cls, *args, **kw): ... + def __new__(cls, value: bool, /, *, anchor: str | None = None): ... @property - def anchor(self): ... - def yaml_anchor(self, any: bool = False): ... - def yaml_set_anchor(self, value, always_dump: bool = False) -> None: ... + def anchor(self) -> Anchor: ... + def yaml_anchor(self, *, any: bool = False): ... + def yaml_set_anchor(self, value: str, /, *, always_dump: bool = False) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi index 49b306403f4a..22271ae9bced 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi @@ -1,22 +1,48 @@ -from _typeshed import Incomplete +from _typeshed import SupportsWrite +from typing import Literal, Self + +from .anchor import Anchor +from .scalarint import _Underscore __all__ = ["ScalarFloat", "ExponentialFloat", "ExponentialCapsFloat"] class ScalarFloat(float): - def __new__(cls, *args, **kw): ... - def __iadd__(self, a): ... - def __ifloordiv__(self, a): ... - def __imul__(self, a): ... - def __ipow__(self, a): ... - def __isub__(self, a): ... + _width: int + _prec: int + _m_sign: Literal[False, "+", "-"] + _m_lead0: int + _exp: Literal["e", "E"] | None + _e_width: int | None + _e_sign: bool | None + _underscore: _Underscore | None + def __new__( + cls, + value: float, + /, + *, + width: int, + prec: int, + m_sign: Literal[False, "+", "-"], + m_lead0: int, + exp: Literal["e", "E"] | None = None, + e_width: int | None = None, + e_sign: bool | None = None, + underscore: _Underscore | None = None, + anchor: str | None = None, + ) -> Self: ... + def __iadd__(self, a: float, /) -> float: ... # noqa: Y034 # Explicitly returns float + def __ifloordiv__(self, a: float, /) -> float: ... # noqa: Y034 # Explicitly returns float + def __imul__(self, a: float, /) -> float: ... # noqa: Y034 # Explicitly returns float + def __ipow__(self, a: float, /) -> float: ... # noqa: Y034 # Explicitly returns float + def __isub__(self, a: float, /) -> float: ... # noqa: Y034 # Explicitly returns float @property - def anchor(self): ... - def yaml_anchor(self, any: bool = False): ... - def yaml_set_anchor(self, value, always_dump: bool = False) -> None: ... - def dump(self, out=...) -> None: ... + def anchor(self) -> Anchor: ... + def yaml_anchor(self, *, any: bool = False) -> Anchor: ... + def yaml_set_anchor(self, value: str, /, *, always_dump: bool = False) -> None: ... + def dump(self, out: SupportsWrite[str] = ...) -> None: ... class ExponentialFloat(ScalarFloat): - def __new__(cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None): ... + def __new__(cls, value: float, /, *, width: int | None = None, underscore: _Underscore | None = None): ... class ExponentialCapsFloat(ScalarFloat): - def __new__(cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None): ... + def __new__(cls, value: float, /, *, width: int | None = None, underscore: _Underscore | None = None): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi index 3d9b8fbe2ced..c930b121de83 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi @@ -1,40 +1,49 @@ -from _typeshed import Incomplete +from typing import Self +from typing_extensions import TypeAlias + +from .anchor import Anchor __all__ = ["ScalarInt", "BinaryInt", "OctalInt", "HexInt", "HexCapsInt", "DecimalInt"] +_Underscore: TypeAlias = list[int | bool] # [int, bool, bool] + class ScalarInt(int): - def __new__(cls, *args, **kw): ... - def __iadd__(self, a): ... - def __ifloordiv__(self, a): ... - def __imul__(self, a): ... - def __ipow__(self, a): ... - def __isub__(self, a): ... + _width: int | None + _underscore: _Underscore | None + def __new__( + cls, value: int, /, *, width: int | None = None, underscore: _Underscore | None = None, anchor: str | None = None + ) -> Self: ... + def __iadd__(self, a: int, /) -> Self: ... + def __ifloordiv__(self, a: int, /) -> Self: ... + def __imul__(self, a: int, /) -> Self: ... + def __ipow__(self, a: int, /) -> Self: ... + def __isub__(self, a: int, /) -> Self: ... @property - def anchor(self): ... - def yaml_anchor(self, any: bool = False): ... - def yaml_set_anchor(self, value, always_dump: bool = False) -> None: ... + def anchor(self) -> Anchor: ... + def yaml_anchor(self, *, any: bool = False) -> Anchor | None: ... + def yaml_set_anchor(self, value: str, /, *, always_dump: bool = False) -> None: ... class BinaryInt(ScalarInt): def __new__( - cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None, anchor: Incomplete | None = None - ): ... + cls, value: int, /, *, width: int | None = None, underscore: _Underscore | None = None, anchor: str | None = None + ) -> Self: ... class OctalInt(ScalarInt): def __new__( - cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None, anchor: Incomplete | None = None - ): ... + cls, value: int, /, *, width: int | None = None, underscore: _Underscore | None = None, anchor: str | None = None + ) -> Self: ... class HexInt(ScalarInt): def __new__( - cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None, anchor: Incomplete | None = None - ): ... + cls, value: int, /, *, width: int | None = None, underscore: _Underscore | None = None, anchor: str | None = None + ) -> Self: ... class HexCapsInt(ScalarInt): def __new__( - cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None, anchor: Incomplete | None = None - ): ... + cls, value: int, /, *, width: int | None = None, underscore: _Underscore | None = None, anchor: str | None = None + ) -> Self: ... class DecimalInt(ScalarInt): def __new__( - cls, value, width: Incomplete | None = None, underscore: Incomplete | None = None, anchor: Incomplete | None = None - ): ... + cls, value: int, /, *, width: int | None = None, underscore: _Underscore | None = None, anchor: str | None = None + ) -> Self: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi index 7df59f91949b..e5e1237c0a23 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi @@ -1,6 +1,9 @@ -from _typeshed import Incomplete +from collections.abc import Callable, Mapping +from typing import Any, Final, Self, SupportsIndex -from .compat import SupportsIndex +from .anchor import Anchor +from .comments import CommentedMap, CommentedSeq +from .nodes import _ScalarNodeStyle __all__ = [ "ScalarString", @@ -13,31 +16,39 @@ __all__ = [ ] class ScalarString(str): - def __new__(cls, *args, **kw): ... - def replace(self, old, new, maxreplace: SupportsIndex = -1): ... + def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... + def replace(self, old: str, new: str, maxreplace: SupportsIndex = -1, /) -> Self: ... @property - def anchor(self): ... - def yaml_anchor(self, any: bool = False): ... - def yaml_set_anchor(self, value, always_dump: bool = False) -> None: ... + def anchor(self) -> Anchor: ... + def yaml_anchor(self, *, any: bool = False) -> Anchor: ... + def yaml_set_anchor(self, value: str, /, *, always_dump: bool = False) -> None: ... class LiteralScalarString(ScalarString): - style: str - def __new__(cls, value: str, anchor: Incomplete | None = None): ... + style: Final[_ScalarNodeStyle] = "|" + comment: str + def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... PreservedScalarString = LiteralScalarString class FoldedScalarString(ScalarString): - style: str - def __new__(cls, value: str, anchor: Incomplete | None = None): ... + style: Final[_ScalarNodeStyle] = ">" + fold_pos: list[int] + comment: str + def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... class SingleQuotedScalarString(ScalarString): - style: str - def __new__(cls, value: str, anchor: Incomplete | None = None): ... + style: Final[_ScalarNodeStyle] = "'" + def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... class DoubleQuotedScalarString(ScalarString): - style: str - def __new__(cls, value: str, anchor: Incomplete | None = None): ... + style: Final[_ScalarNodeStyle] = '"' + def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... class PlainScalarString(ScalarString): - style: str - def __new__(cls, value: str, anchor: Incomplete | None = None): ... + style: Final[_ScalarNodeStyle] = "" + def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... + +def preserve_literal(s: str, /) -> str: ... +def walk_tree( + base: CommentedMap[Any, Any] | CommentedSeq[Any], map: Mapping[str, Callable[[str], str]] | None = None +) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi index fc4da8bf49f9..e94f7f966e22 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi @@ -1,67 +1,89 @@ -from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Iterator +from typing import ClassVar, Final -from .error import MarkedYAMLError -from .tokens import * +from .error import MarkedYAMLError, StreamMark +from .main import YAML +from .reader import Reader +from .tokens import ( + AliasToken, + AnchorToken, + BlockEndToken, + DirectiveToken, + DocumentEndToken, + DocumentStartToken, + FlowMappingEndToken, + FlowMappingStartToken, + FlowSequenceEndToken, + FlowSequenceStartToken, + ScalarToken, + TagToken, + Token, + _BlockScalarStyle, + _FlowScalarStyle, + _TagDirective, + _VersionTuple, +) __all__ = ["Scanner", "RoundTripScanner", "ScannerError"] class ScannerError(MarkedYAMLError): ... class SimpleKey: - token_number: Incomplete - required: Incomplete - index: Incomplete - line: Incomplete - column: Incomplete - mark: Incomplete - def __init__(self, token_number, required, index: int, line: int, column: int, mark) -> None: ... + token_number: int + required: bool + index: int + line: int + column: int + mark: StreamMark + def __init__(self, token_number: int, required: bool, index: int, line: int, column: int, mark: StreamMark) -> None: ... class Scanner: - loader: Incomplete + loader: YAML | None first_time: bool - def __init__(self, loader: Incomplete | None = None) -> None: ... + def __init__(self, loader: YAML | None = None) -> None: ... @property def flow_level(self) -> int: ... done: bool - flow_context: Incomplete - tokens: Incomplete + flow_context: list[str] + tokens: list[Token] tokens_taken: int indent: int - indents: Incomplete + indents: list[int] allow_simple_key: bool - possible_simple_keys: Incomplete - yaml_version: Incomplete - tag_directives: Incomplete + possible_simple_keys: dict[int, SimpleKey] + yaml_version: _VersionTuple | None + tag_directives: list[_TagDirective] def reset_scanner(self) -> None: ... @property - def reader(self): ... + def reader(self) -> Reader: ... @property - def scanner_processing_version(self): ... - def check_token(self, *choices) -> bool: ... - def peek_token(self): ... - def get_token(self): ... + def scanner_processing_version(self) -> _VersionTuple: ... + def check_token(self, *choices: type[Token]) -> bool: ... + def peek_token(self) -> Token: ... + def get_token(self) -> Token: ... def need_more_tokens(self) -> bool: ... def fetch_comment(self, comment) -> None: ... - def fetch_more_tokens(self): ... - def next_possible_simple_key(self): ... + def fetch_more_tokens(self) -> None: ... + def next_possible_simple_key(self) -> int | None: ... def stale_possible_simple_keys(self) -> None: ... def save_possible_simple_key(self) -> None: ... def remove_possible_simple_key(self) -> None: ... - def unwind_indent(self, column) -> None: ... + def unwind_indent(self, column: int) -> None: ... def add_indent(self, column: int) -> bool: ... def fetch_stream_start(self) -> None: ... def fetch_stream_end(self) -> None: ... def fetch_directive(self) -> None: ... def fetch_document_start(self) -> None: ... def fetch_document_end(self) -> None: ... - def fetch_document_indicator(self, TokenClass) -> None: ... + def fetch_document_indicator(self, TokenClass: type[DocumentStartToken | DocumentEndToken]) -> None: ... def fetch_flow_sequence_start(self) -> None: ... def fetch_flow_mapping_start(self) -> None: ... - def fetch_flow_collection_start(self, TokenClass, to_push: str) -> None: ... + def fetch_flow_collection_start( + self, TokenClass: type[FlowSequenceStartToken | FlowMappingStartToken], to_push: str + ) -> None: ... def fetch_flow_sequence_end(self) -> None: ... def fetch_flow_mapping_end(self) -> None: ... - def fetch_flow_collection_end(self, TokenClass) -> None: ... + def fetch_flow_collection_end(self, TokenClass: type[FlowSequenceEndToken | FlowMappingEndToken]) -> None: ... def fetch_flow_entry(self) -> None: ... def fetch_block_entry(self) -> None: ... def fetch_key(self) -> None: ... @@ -71,106 +93,97 @@ class Scanner: def fetch_tag(self) -> None: ... def fetch_literal(self) -> None: ... def fetch_folded(self) -> None: ... - def fetch_block_scalar(self, style) -> None: ... + def fetch_block_scalar(self, style: _BlockScalarStyle) -> None: ... def fetch_single(self) -> None: ... def fetch_double(self) -> None: ... - def fetch_flow_scalar(self, style) -> None: ... + def fetch_flow_scalar(self, style: _FlowScalarStyle) -> None: ... def fetch_plain(self) -> None: ... def check_directive(self): ... def check_document_start(self): ... def check_document_end(self): ... - def check_block_entry(self): ... - def check_key(self): ... - def check_value(self): ... - def check_plain(self): ... + def check_block_entry(self) -> bool: ... + def check_key(self) -> bool: ... + def check_value(self) -> bool: ... + def check_plain(self) -> bool: ... def scan_to_next_token(self) -> None: ... - def scan_directive(self): ... - def scan_directive_name(self, start_mark): ... - def scan_yaml_directive_value(self, start_mark): ... - def scan_yaml_directive_number(self, start_mark): ... - def scan_tag_directive_value(self, start_mark): ... - def scan_tag_directive_handle(self, start_mark): ... - def scan_tag_directive_prefix(self, start_mark): ... - def scan_directive_ignored_line(self, start_mark) -> None: ... - def scan_anchor(self, TokenClass): ... - def scan_tag(self): ... - def scan_block_scalar(self, style, rt: bool | None = False): ... - def scan_block_scalar_indicators(self, start_mark): ... - def scan_block_scalar_ignored_line(self, start_mark): ... - def scan_block_scalar_indentation(self): ... - def scan_block_scalar_breaks(self, indent: int): ... - def scan_flow_scalar(self, style): ... - ESCAPE_REPLACEMENTS: Incomplete - ESCAPE_CODES: Incomplete - def scan_flow_scalar_non_spaces(self, double, start_mark): ... - def scan_flow_scalar_spaces(self, double, start_mark): ... - def scan_flow_scalar_breaks(self, double, start_mark): ... - def scan_plain(self): ... - def scan_plain_spaces(self, indent, start_mark): ... - def scan_tag_handle(self, name, start_mark): ... - def scan_tag_uri(self, name, start_mark): ... - def scan_uri_escapes(self, name, start_mark): ... - def scan_line_break(self): ... + def scan_directive(self) -> DirectiveToken: ... + def scan_directive_name(self, start_mark: StreamMark) -> str: ... + def scan_yaml_directive_value(self, start_mark: StreamMark) -> _VersionTuple: ... + def scan_yaml_directive_number(self, start_mark: StreamMark) -> int: ... + def scan_tag_directive_value(self, start_mark: StreamMark) -> _TagDirective: ... + def scan_tag_directive_handle(self, start_mark: StreamMark) -> str: ... + def scan_tag_directive_prefix(self, start_mark: StreamMark) -> str: ... + def scan_directive_ignored_line(self, start_mark: StreamMark) -> None: ... + def scan_anchor(self, TokenClass: type[AliasToken | AnchorToken]) -> AliasToken | AnchorToken: ... + def scan_tag(self) -> TagToken: ... + def scan_block_scalar(self, style: _BlockScalarStyle, rt: bool | None = False) -> ScalarToken: ... + def scan_block_scalar_indicators(self, start_mark: StreamMark) -> tuple[bool | None, int | None]: ... + def scan_block_scalar_ignored_line(self, start_mark: StreamMark) -> str | None: ... + def scan_block_scalar_indentation(self) -> tuple[list[str], int, StreamMark]: ... + def scan_block_scalar_breaks(self, indent: int) -> tuple[list[str], StreamMark]: ... + def scan_flow_scalar(self, style: _FlowScalarStyle) -> ScalarToken: ... + ESCAPE_REPLACEMENTS: Final[dict[str, str]] + ESCAPE_CODES: Final[dict[str, int]] + def scan_flow_scalar_non_spaces(self, double: bool, start_mark: StreamMark) -> list[str]: ... + def scan_flow_scalar_spaces(self, double: bool, start_mark: StreamMark) -> list[str]: ... + def scan_flow_scalar_breaks(self, double: bool, start_mark: StreamMark) -> list[str]: ... + def scan_plain(self) -> ScalarToken: ... + def scan_plain_spaces(self, indent: int, start_mark: StreamMark) -> list[str]: ... + def scan_tag_handle(self, name: str, start_mark: StreamMark) -> str: ... + def scan_tag_uri(self, name: str, start_mark: StreamMark) -> str: ... + def scan_uri_escapes(self, name: str, start_mark: StreamMark) -> str: ... + def scan_line_break(self) -> str: ... class RoundTripScanner(Scanner): - def check_token(self, *choices) -> bool: ... - def peek_token(self): ... - def get_token(self): ... - def fetch_comment(self, comment) -> None: ... - allow_simple_key: bool - def scan_to_next_token(self): ... + def check_token(self, *choices: type[Token]) -> bool: ... + def peek_token(self) -> Token: ... + def get_token(self) -> Token: ... + def fetch_comment(self, comment: tuple[str, StreamMark, StreamMark]) -> None: ... + def scan_to_next_token(self) -> tuple[str, StreamMark, StreamMark]: ... def scan_line_break(self, empty_line: bool = False) -> str: ... - def scan_block_scalar(self, style, rt: bool | None = True): ... - def scan_uri_escapes(self, name, start_mark): ... + def scan_block_scalar(self, style: _BlockScalarStyle, rt: bool | None = True) -> ScalarToken: ... + def scan_uri_escapes(self, name: str, start_mark: StreamMark) -> str: ... -class CommentBase: - value: Incomplete - line: Incomplete - column: Incomplete +class CommentBase: # RTSC + name: ClassVar[str] + value: str + line: int + column: int used: str - function: Incomplete - fline: Incomplete - ufun: Incomplete - uline: Incomplete - def __init__(self, value, line, column) -> None: ... + def __init__(self, value: str, line: int, column: int) -> None: ... def set_used(self, v: str = "+") -> None: ... def set_assigned(self) -> None: ... def info(self) -> str: ... class EOLComment(CommentBase): - name: str - def __init__(self, value, line, column) -> None: ... + name: Final = "EOLC" class FullLineComment(CommentBase): - name: str - def __init__(self, value, line, column) -> None: ... + name: Final = "FULL" class BlankLineComment(CommentBase): - name: str - def __init__(self, value, line, column) -> None: ... + name: Final = "BLNK" -class ScannedComments: - comments: Incomplete - unused: Incomplete +class ScannedComments: # RTSC + comments: dict[int, CommentBase] + unused: list[int] def __init__(self) -> None: ... - def add_eol_comment(self, comment, column, line): ... - def add_blank_line(self, comment, column, line): ... - def add_full_line_comment(self, comment, column, line): ... - def __getitem__(self, idx): ... + def add_eol_comment(self, comment: str, column: int, line: int) -> EOLComment: ... + def add_blank_line(self, comment: str, column: int, line: int) -> BlankLineComment: ... + def add_full_line_comment(self, comment: str, column: int, line: int) -> FullLineComment: ... + def __getitem__(self, idx: int) -> CommentBase: ... def last(self) -> str: ... def any_unprocessed(self) -> bool: ... - def unprocessed(self, use: bool = False) -> Generator[Incomplete, None, None]: ... - def assign_pre(self, token): ... - def assign_eol(self, tokens) -> None: ... - def assign_post(self, token): ... - def str_unprocessed(self): ... + def unprocessed(self, use: bool = False) -> Iterator[tuple[int, CommentBase]]: ... + def assign_pre(self, token: Token) -> bool: ... + def assign_eol(self, tokens: list[Token]) -> None: ... + def assign_post(self, token: BlockEndToken) -> bool: ... + def str_unprocessed(self) -> str: ... class RoundTripScannerSC(Scanner): - comments: Incomplete - def __init__(self, *arg, **kw) -> None: ... - def get_token(self): ... + comments: ScannedComments | None + def get_token(self) -> Token: ... def need_more_tokens(self) -> bool: ... - allow_simple_key: bool def scan_to_next_token(self) -> None: ... def scan_empty_or_full_line_comments(self) -> None: ... def scan_block_scalar_ignored_line(self, start_mark) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi b/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi index 3f9184ec80e3..b3215c27bcaa 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi @@ -1,41 +1,48 @@ -from _typeshed import Incomplete +from re import Pattern +from typing import Final, Literal from .compat import VersionType +from .emitter import Emitter from .error import YAMLError +from .main import YAML +from .nodes import CollectionNode, Node +from .resolver import BaseResolver +from .tag import _TagHandleToPrefix +from .tokens import _VersionTuple __all__ = ["Serializer", "SerializerError"] class SerializerError(YAMLError): ... class Serializer: - ANCHOR_TEMPLATE: str - ANCHOR_RE: Incomplete - dumper: Incomplete - use_encoding: Incomplete - use_explicit_start: Incomplete - use_explicit_end: Incomplete - use_version: Incomplete - use_tags: Incomplete - serialized_nodes: Incomplete - anchors: Incomplete + ANCHOR_TEMPLATE: Final[str] + ANCHOR_RE: Final[Pattern[str]] + dumper: YAML | None + use_encoding: str | None + use_explicit_start: bool | None + use_explicit_end: bool | None + use_version: _VersionTuple | None + use_tags: _TagHandleToPrefix | None + serialized_nodes: dict[Node, Literal[True]] + anchors: dict[Node, str | None] last_anchor_id: int - closed: Incomplete + closed: bool | None def __init__( self, - encoding: Incomplete | None = None, + encoding: str | None = None, explicit_start: bool | None = None, explicit_end: bool | None = None, version: VersionType | None = None, - tags: Incomplete | None = None, - dumper: Incomplete | None = None, + tags: _TagHandleToPrefix | None = None, + dumper: YAML | None = None, ) -> None: ... @property - def emitter(self): ... + def emitter(self) -> Emitter: ... @property - def resolver(self): ... + def resolver(self) -> BaseResolver: ... def open(self) -> None: ... def close(self) -> None: ... - def serialize(self, node) -> None: ... - def anchor_node(self, node) -> None: ... - def generate_anchor(self, node): ... - def serialize_node(self, node, parent, index) -> None: ... + def serialize(self, node: Node) -> None: ... + def anchor_node(self, node: Node) -> None: ... + def generate_anchor(self, node: Node) -> str: ... + def serialize_node(self, node: Node, parent: CollectionNode | None, index: int | Node | None) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/tag.pyi b/stubs/ruamel.yaml/ruamel/yaml/tag.pyi index d253d8a75dc5..b629bfac1b0c 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/tag.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/tag.pyi @@ -1,22 +1,24 @@ -from _typeshed import Incomplete +from typing import Final, TypeAlias -tag_attrib: str +_TagHandleToPrefix: TypeAlias = dict[str, str] + +tag_attrib: Final = "_yaml_tag" class Tag: - attrib = tag_attrib - handle: Incomplete - suffix: Incomplete - handles: Incomplete + attrib: Final = tag_attrib + handle: str | None + suffix: str | None + handles: _TagHandleToPrefix | None def __init__( - self, handle: Incomplete | None = None, suffix: Incomplete | None = None, handles: Incomplete | None = None + self, *, handle: str | None = None, suffix: str | None = None, handles: _TagHandleToPrefix | None = None ) -> None: ... def __hash__(self) -> int: ... - def __eq__(self, other) -> bool: ... - def startswith(self, x: str) -> bool: ... + def __eq__(self, other: Tag | str, /) -> bool: ... + def startswith(self, x: str, /) -> bool: ... @property def trval(self) -> str | None: ... value = trval @property def uri_decoded_suffix(self) -> str | None: ... - def select_transform(self, val: bool) -> None: ... + def select_transform(self, val: bool, /) -> None: ... def check_handle(self) -> bool: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi b/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi index 2d6e474073d6..319849518d11 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/timestamp.pyi @@ -1,19 +1,5 @@ -import datetime -from _typeshed import Incomplete +from _typeshed import Unused +from datetime import datetime -class TimeStamp(datetime.datetime): - def __init__(self, *args, **kw) -> None: ... - def __new__(cls, *args, **kw): ... - def __deepcopy__(self, memo): ... - def replace( - self, - year: Incomplete | None = None, - month: Incomplete | None = None, - day: Incomplete | None = None, - hour: Incomplete | None = None, - minute: Incomplete | None = None, - second: Incomplete | None = None, - microsecond: Incomplete | None = None, - tzinfo: bool = True, - fold: Incomplete | None = None, - ): ... +class TimeStamp(datetime): + def __deepcopy__(self, memo: Unused) -> TimeStamp: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi index 67ef20fa839e..a5c0af7348cb 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi @@ -1,115 +1,135 @@ -from _typeshed import Incomplete +from typing import ClassVar, Final, Literal, Self, overload +from typing_extensions import TypeAlias -from .compat import nprintf as nprintf -from .error import StreamMark +from .error import CommentMark, StreamMark, _Mark SHOW_LINES: bool +_PostComment: TypeAlias = CommentToken +_PreComments: TypeAlias = list[CommentToken] | list[str] +_CommentGroup: TypeAlias = list[_PostComment | _PreComments | None] +_VersionTuple: TypeAlias = tuple[int, int] +_TagDirective: TypeAlias = tuple[str, str] +_FlowScalarStyle: TypeAlias = Literal['"', "'"] +_BlockScalarStyle: TypeAlias = Literal["|", ">"] +_ScalarStyle: TypeAlias = _FlowScalarStyle | _BlockScalarStyle | Literal[""] + class Token: - start_mark: Incomplete - end_mark: Incomplete - def __init__(self, start_mark: StreamMark, end_mark: StreamMark) -> None: ... + id: ClassVar[str] + start_mark: _Mark + end_mark: _Mark + def __init__(self, start_mark: _Mark, end_mark: _Mark) -> None: ... @property def column(self) -> int: ... @column.setter - def column(self, pos) -> None: ... - def add_post_comment(self, comment) -> None: ... - def add_pre_comments(self, comments) -> None: ... - def add_comment_pre(self, comment) -> None: ... - def add_comment_eol(self, comment, comment_type) -> None: ... - def add_comment_post(self, comment) -> None: ... + def column(self, pos: int, /) -> None: ... + def add_post_comment(self, comment: _PostComment, /) -> None: ... + def add_pre_comments(self, comments: _PreComments, /) -> None: ... + def add_comment_pre(self, comment: int) -> None: ... # RTSC + def add_comment_eol(self, comment: int, comment_type: int) -> None: ... # RTSC + def add_comment_post(self, comment: int) -> None: ... # RTSC @property - def comment(self): ... - def move_old_comment(self, target, empty: bool = False): ... - def split_old_comment(self): ... - def move_new_comment(self, target, empty: bool = False): ... + def comment(self) -> _CommentGroup | None: ... + def move_old_comment(self, target: Token, *, empty: bool = False) -> Self | None: ... + def split_old_comment(self) -> list[CommentToken | None]: ... + def move_new_comment(self, target: Token, *, empty: bool = False) -> Self | None: ... class DirectiveToken(Token): - id: str - name: Incomplete - value: Incomplete - def __init__(self, name, value, start_mark, end_mark) -> None: ... + id: Final = "" + name: str + value: _VersionTuple | _TagDirective | None + @overload + def __init__(self, name: Literal["YAML"], value: _VersionTuple, start_mark: _Mark, end_mark: _Mark) -> None: ... + @overload + def __init__(self, name: Literal["TAG"], value: _TagDirective, start_mark: _Mark, end_mark: _Mark) -> None: ... + @overload + def __init__(self, name: str, value: None, start_mark: _Mark, end_mark: _Mark) -> None: ... class DocumentStartToken(Token): - id: str + id: Final = "" class DocumentEndToken(Token): - id: str + id: Final = "" class StreamStartToken(Token): - id: str - encoding: Incomplete - def __init__( - self, start_mark: Incomplete | None = None, end_mark: Incomplete | None = None, encoding: Incomplete | None = None - ) -> None: ... + id: Final = "" + encoding: str | None + def __init__(self, start_mark: _Mark, end_mark: _Mark, encoding: str | None = None) -> None: ... class StreamEndToken(Token): - id: str + id: Final = "" class BlockSequenceStartToken(Token): - id: str + id: Final = "" class BlockMappingStartToken(Token): - id: str + id: Final = "" class BlockEndToken(Token): - id: str + id: Final = "" class FlowSequenceStartToken(Token): - id: str + id: Final = "[" class FlowMappingStartToken(Token): - id: str + id: Final = "{" class FlowSequenceEndToken(Token): - id: str + id: Final = "]" class FlowMappingEndToken(Token): - id: str + id: Final = "}" class KeyToken(Token): - id: str + id: Final = "?" class ValueToken(Token): - id: str + id: Final = ":" class BlockEntryToken(Token): - id: str + id: Final = "-" class FlowEntryToken(Token): - id: str + id: Final = "," class AliasToken(Token): - id: str - value: Incomplete - def __init__(self, value, start_mark, end_mark) -> None: ... + id: Final = "" + value: str + def __init__(self, value: str, start_mark: _Mark, end_mark: _Mark) -> None: ... class AnchorToken(Token): - id: str - value: Incomplete - def __init__(self, value, start_mark, end_mark) -> None: ... + id: Final = "" + value: str + def __init__(self, value: str, start_mark: _Mark, end_mark: _Mark) -> None: ... class TagToken(Token): - id: str - value: Incomplete - def __init__(self, value, start_mark, end_mark) -> None: ... + id: Final = "" + value: tuple[str | None, str] + def __init__(self, value: tuple[str | None, str], start_mark: _Mark, end_mark: _Mark) -> None: ... class ScalarToken(Token): - id: str - value: Incomplete - plain: Incomplete - style: Incomplete - def __init__(self, value, plain, start_mark, end_mark, style: Incomplete | None = None) -> None: ... + id: Final = "" + value: str + plain: bool + style: _ScalarStyle | None + def __init__( + self, value: str, plain: bool, start_mark: _Mark, end_mark: _Mark, style: _ScalarStyle | None = None + ) -> None: ... class CommentToken(Token): - id: str + id: Final = "" + pre_done: bool def __init__( - self, value, start_mark: Incomplete | None = None, end_mark: Incomplete | None = None, column: Incomplete | None = None + self, + value: str, + start_mark: CommentMark | StreamMark | None = None, + end_mark: StreamMark | None = None, + column: int | None = None, ) -> None: ... @property def value(self) -> str: ... @value.setter - def value(self, val) -> None: ... + def value(self, val: str, /) -> None: ... def reset(self) -> None: ... - def __eq__(self, other) -> bool: ... - def __ne__(self, other) -> bool: ... + def __eq__(self, other: CommentToken, /) -> bool: ... + def __ne__(self, other: CommentToken, /) -> bool: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/util.pyi b/stubs/ruamel.yaml/ruamel/yaml/util.pyi index d89ce73788d7..66f7db18ca03 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/util.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/util.pyi @@ -1,20 +1,34 @@ -import datetime -from _typeshed import Incomplete -from collections.abc import Generator -from typing import Any, Callable +import re +from collections.abc import Callable, Iterator +from datetime import date, datetime +from typing import Any, Final -from .compat import StreamTextType as StreamTextType +from configobj import ConfigObj + +from .compat import StreamTextType class LazyEval: def __init__(self, func: Callable[..., Any], *args, **kwargs) -> None: ... - def __getattribute__(self, name: str): ... - def __setattr__(self, name: str, value) -> None: ... + def __getattribute__(self, name: str, /) -> Any: ... + def __setattr__(self, name: str, value: Any, /) -> None: ... -RegExp: Incomplete -timestamp_regexp: Incomplete +RegExp: Final = re.compile +timestamp_regexp: Final[re.Pattern[str]] def create_timestamp( - year, month, day, t, hour, minute, second, fraction, tz, tz_sign, tz_hour, tz_minute -) -> datetime.datetime | datetime.date: ... -def load_yaml_guess_indent(stream: StreamTextType, **kw): ... -def configobj_walker(cfg) -> Generator[Incomplete, None, None]: ... + *, + year: str, + month: str, + day: str, + t: str | None, + hour: str | None, + minute: str | None, + second: str | None, + fraction: str | None, + tz: str | None, + tz_sign: str | None, + tz_hour: str | None, + tz_minute: str | None, +) -> date | datetime: ... +def load_yaml_guess_indent(stream: StreamTextType, /) -> tuple[Any, int | None, int | None]: ... +def configobj_walker(cfg: ConfigObj, /) -> Iterator[str]: ... From ca065c45d5da9ed0d4dd477c2bd8c312b8166567 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Thu, 12 Sep 2024 19:45:38 +0000 Subject: [PATCH 06/15] Small fixes --- stubs/ruamel.yaml/ruamel/yaml/dumper.pyi | 12 ++++++++---- stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi | 11 ++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi index df14d579b69f..e5615257cd8a 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi @@ -1,4 +1,5 @@ from _typeshed import Unused +from typing import TypeAlias from .compat import StreamType, VersionType from .emitter import Emitter, _LineBreak @@ -10,6 +11,9 @@ from .tokens import _ScalarStyle __all__ = ["BaseDumper", "SafeDumper", "Dumper", "RoundTripDumper"] +# https://github.com/python/typeshed/pull/8973 +_Inf: TypeAlias = float + class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): def __init__( self, @@ -18,7 +22,7 @@ class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): default_flow_style: bool | None = None, canonical: bool | None = None, indent: int | None = None, - width: int | None = None, + width: int | _Inf | None = None, allow_unicode: bool | None = None, line_break: _LineBreak | None = None, encoding: str | None = None, @@ -39,7 +43,7 @@ class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): default_flow_style: bool | None = None, canonical: bool | None = None, indent: int | None = None, - width: int | None = None, + width: int | _Inf | None = None, allow_unicode: bool | None = None, line_break: _LineBreak | None = None, encoding: str | None = None, @@ -60,7 +64,7 @@ class Dumper(Emitter, Serializer, Representer, Resolver): default_flow_style: bool | None = None, canonical: bool | None = None, indent: int | None = None, - width: int | None = None, + width: int | _Inf | None = None, allow_unicode: bool | None = None, line_break: _LineBreak | None = None, encoding: str | None = None, @@ -81,7 +85,7 @@ class RoundTripDumper(Emitter, Serializer, RoundTripRepresenter, VersionedResolv default_flow_style: bool | None = None, canonical: bool | None = None, indent: int | None = None, - width: int | None = None, + width: int | _Inf | None = None, allow_unicode: bool | None = None, line_break: _LineBreak | None = None, encoding: str | None = None, diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi index 22271ae9bced..dab7071414fd 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi @@ -30,11 +30,12 @@ class ScalarFloat(float): underscore: _Underscore | None = None, anchor: str | None = None, ) -> Self: ... - def __iadd__(self, a: float, /) -> float: ... # noqa: Y034 # Explicitly returns float - def __ifloordiv__(self, a: float, /) -> float: ... # noqa: Y034 # Explicitly returns float - def __imul__(self, a: float, /) -> float: ... # noqa: Y034 # Explicitly returns float - def __ipow__(self, a: float, /) -> float: ... # noqa: Y034 # Explicitly returns float - def __isub__(self, a: float, /) -> float: ... # noqa: Y034 # Explicitly returns float + # The following methods explicitly return floats + def __iadd__(self, a: float, /) -> float: ... # noqa: Y034 + def __ifloordiv__(self, a: float, /) -> float: ... # noqa: Y034 + def __imul__(self, a: float, /) -> float: ... # noqa: Y034 + def __ipow__(self, a: float, /) -> float: ... # noqa: Y034 + def __isub__(self, a: float, /) -> float: ... # noqa: Y034 @property def anchor(self) -> Anchor: ... def yaml_anchor(self, *, any: bool = False) -> Anchor: ... From acc6f20287c96914b695efab17364036c71a1125 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Thu, 12 Sep 2024 19:57:19 +0000 Subject: [PATCH 07/15] configobj is an optional dependency --- stubs/ruamel.yaml/METADATA.toml | 1 - stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/util.pyi | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/stubs/ruamel.yaml/METADATA.toml b/stubs/ruamel.yaml/METADATA.toml index 00f0dd37f445..25f7cf3bc5df 100644 --- a/stubs/ruamel.yaml/METADATA.toml +++ b/stubs/ruamel.yaml/METADATA.toml @@ -1,3 +1,2 @@ version = "0.18.*" -requires = ["configobj"] upstream_repository = "https://sourceforge.net/p/ruamel-yaml/code/" diff --git a/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi b/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi index 0711b22f845e..c2e054ab5827 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi @@ -1,7 +1,7 @@ from collections.abc import Iterator from typing_extensions import deprecated -from configobj import ConfigObj +from configobj import ConfigObj # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] @deprecated("configobj_walker has moved to ruamel.yaml.util") def configobj_walker(cfg: ConfigObj, /) -> Iterator[str]: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/util.pyi b/stubs/ruamel.yaml/ruamel/yaml/util.pyi index 66f7db18ca03..0095c8416789 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/util.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/util.pyi @@ -3,7 +3,7 @@ from collections.abc import Callable, Iterator from datetime import date, datetime from typing import Any, Final -from configobj import ConfigObj +from configobj import ConfigObj # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] from .compat import StreamTextType From 6a551f5dcdfb1958c0d1a27e582244cd1eea2ed5 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Sun, 15 Sep 2024 18:41:43 +0000 Subject: [PATCH 08/15] Finish main plus style fixes and PyYAML stubs parity --- stubs/ruamel.yaml/ruamel/yaml/__init__.pyi | 9 + stubs/ruamel.yaml/ruamel/yaml/comments.pyi | 22 +- stubs/ruamel.yaml/ruamel/yaml/compat.pyi | 13 +- stubs/ruamel.yaml/ruamel/yaml/composer.pyi | 5 +- stubs/ruamel.yaml/ruamel/yaml/constructor.pyi | 11 +- stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi | 14 +- stubs/ruamel.yaml/ruamel/yaml/dumper.pyi | 17 +- stubs/ruamel.yaml/ruamel/yaml/emitter.pyi | 28 +- stubs/ruamel.yaml/ruamel/yaml/error.pyi | 4 +- stubs/ruamel.yaml/ruamel/yaml/loader.pyi | 15 +- stubs/ruamel.yaml/ruamel/yaml/main.pyi | 338 +++++++++--------- stubs/ruamel.yaml/ruamel/yaml/nodes.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/parser.pyi | 5 +- stubs/ruamel.yaml/ruamel/yaml/reader.pyi | 13 +- stubs/ruamel.yaml/ruamel/yaml/representer.pyi | 51 ++- stubs/ruamel.yaml/ruamel/yaml/resolver.pyi | 17 +- stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi | 6 +- stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi | 4 +- stubs/ruamel.yaml/ruamel/yaml/scanner.pyi | 13 +- stubs/ruamel.yaml/ruamel/yaml/serializer.pyi | 5 +- stubs/ruamel.yaml/ruamel/yaml/tokens.pyi | 4 +- stubs/ruamel.yaml/ruamel/yaml/util.pyi | 4 +- 22 files changed, 321 insertions(+), 279 deletions(-) diff --git a/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi b/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi index 2c7113d49a48..efcc4377c1f2 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi @@ -1,5 +1,14 @@ +from .comments import CommentedMap as CommentedMap, CommentedSeq as CommentedSeq +from .constructor import * from .cyaml import * +from .dumper import * +from .events import * +from .loader import * from .main import * +from .nodes import * +from .representer import * +from .resolver import * +from .tokens import * version_info: tuple[int, int, int] __version__: str diff --git a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi index f88a6e4f3af9..054d7e7440a8 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi @@ -9,16 +9,6 @@ from .nodes import _ScalarNodeStyle from .tag import Tag from .tokens import CommentToken, _CommentGroup -_Index: TypeAlias = int -_Key: TypeAlias = Hashable - -_T = TypeVar("_T") -_KT = TypeVar("_KT") -_VT = TypeVar("_VT") -_KT_co = TypeVar("_KT_co", covariant=True) -_VT_co = TypeVar("_VT_co", covariant=True) -_Commented = TypeVar("_Commented", bound=CommentedBase) - __all__ = [ "CommentedSeq", "CommentedKeySeq", @@ -34,6 +24,16 @@ __all__ = [ "C_BLANK_LINE_PRESERVE_SPACE", ] +_Index: TypeAlias = int +_Key: TypeAlias = Hashable + +_T = TypeVar("_T") +_KT = TypeVar("_KT") +_VT = TypeVar("_VT") +_KT_co = TypeVar("_KT_co", covariant=True) +_VT_co = TypeVar("_VT_co", covariant=True) +_Commented = TypeVar("_Commented", bound=CommentedBase) + C_POST: Final = 0b00 C_PRE: Final = 0b01 C_SPLIT_ON_FIRST_BLANK: Final = 0b10 @@ -108,7 +108,7 @@ class CommentedBase: class CommentedSeq(MutableSliceableSequence[_T], list[_T], CommentedBase): def __getsingleitem__(self, idx: int) -> _T: ... def __setsingleitem__(self, idx: int, value: _T) -> None: ... - def __delsingleitem__(self, idx: int): ... + def __delsingleitem__(self, idx: int) -> None: ... def __deepcopy__(self, memo: dict[int, Any]) -> Self: ... class CommentedKeySeq(tuple[_T, ...], CommentedBase): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi index a8da97e4204a..b07c909c612d 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi @@ -2,7 +2,7 @@ from _typeshed import SupportsRead, SupportsWrite from abc import ABCMeta, abstractmethod from collections import OrderedDict from collections.abc import Iterable, MutableSequence -from typing import Final, Self, TypeVar, overload +from typing import IO, Any, Final, Self, TypeVar, overload from typing_extensions import TypeAlias from .docinfo import Version @@ -11,8 +11,11 @@ _T = TypeVar("_T") _KT = TypeVar("_KT") _VT = TypeVar("_VT") -StreamType: TypeAlias = SupportsWrite[str | bytes] -StreamTextType: TypeAlias = str | bytes | SupportsRead[str | bytes] +_ReadStream: TypeAlias = str | bytes | SupportsRead[str] | SupportsRead[bytes] +_WriteStream: TypeAlias = SupportsWrite[str] | SupportsWrite[bytes] + +StreamType: TypeAlias = _WriteStream +StreamTextType: TypeAlias = _ReadStream VersionType: TypeAlias = str | tuple[int, int] | list[int] | Version | None class ordereddict(OrderedDict[_KT, _VT]): @@ -32,14 +35,14 @@ class Nprint: def __init__(self, file_name: str | None = None) -> None: ... def __call__(self, *args, **kw) -> None: ... def set_max_print(self, i: int) -> None: ... - def fp(self, mode: str = "a"): ... + def fp(self, mode: str = "a") -> IO[Any]: ... nprint: Nprint nprintf: Nprint def check_namespace_char(ch: str) -> bool: ... def check_anchorname_char(ch: str) -> bool: ... -def version_tnf(t1: tuple[int, ...], t2: tuple[int, ...] | None = None): ... +def version_tnf(t1: tuple[int, ...], t2: tuple[int, ...] | None = None) -> bool | None: ... class MutableSliceableSequence(MutableSequence[_T], metaclass=ABCMeta): @overload diff --git a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi index ce598cfe5343..3427c7d4452a 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/composer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/composer.pyi @@ -1,5 +1,6 @@ from .error import MarkedYAMLError from .events import MappingEndEvent, SequenceEndEvent +from .loader import _Loader from .main import YAML from .nodes import CollectionNode, MappingNode, Node, ScalarNode, SequenceNode from .parser import Parser @@ -10,10 +11,10 @@ __all__ = ["Composer", "ComposerError"] class ComposerError(MarkedYAMLError): ... class Composer: - loader: YAML | None + loader: YAML | _Loader | None anchors: dict[str, Node] warn_double_anchors: bool - def __init__(self, loader: YAML | None = None) -> None: ... + def __init__(self, loader: YAML | _Loader | None = None) -> None: ... @property def parser(self) -> Parser: ... @property diff --git a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi index 293eb854769b..eba3c15519de 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi @@ -8,6 +8,7 @@ from .comments import CommentedMap, CommentedOrderedMap, CommentedSeq, Commented from .compat import ordereddict from .composer import Composer from .error import MarkedYAMLError, MarkedYAMLFutureWarning, _Mark +from .loader import _Loader from .main import YAML from .nodes import MappingNode, Node, ScalarNode, SequenceNode from .resolver import BaseResolver @@ -17,6 +18,8 @@ from .scanner import ScannedComments, Scanner from .tag import Tag from .timestamp import TimeStamp +__all__ = ["BaseConstructor", "SafeConstructor", "Constructor", "ConstructorError", "RoundTripConstructor"] + _T = TypeVar("_T") _Constructor = TypeVar("_Constructor", bound=BaseConstructor, contravariant=True) @@ -26,8 +29,6 @@ class _ConstructorFunction(Protocol[_Constructor]): class _MultiConstructorFunction(Protocol[_Constructor]): def __call__(self, loader: _Constructor, tag_suffix: str, node: Node, /) -> Any: ... -__all__ = ["BaseConstructor", "SafeConstructor", "Constructor", "ConstructorError", "RoundTripConstructor"] - class ConstructorError(MarkedYAMLError): ... class DuplicateKeyFutureWarning(MarkedYAMLFutureWarning): ... class DuplicateKeyError(MarkedYAMLError): ... @@ -35,7 +36,7 @@ class DuplicateKeyError(MarkedYAMLError): ... class BaseConstructor: yaml_constructors: ClassVar[dict[str | None, _ConstructorFunction[Self]]] yaml_multi_constructors: ClassVar[dict[str | None, _MultiConstructorFunction[Self]]] - loader: YAML | None + loader: YAML | _Loader | None yaml_base_dict_type: type[dict[Any, Any]] yaml_base_list_type: type[list[Any]] constructed_objects: dict[Node, Any] @@ -43,7 +44,7 @@ class BaseConstructor: state_generators: list[Generator[Any, Any, Any]] deep_construct: bool allow_duplicate_keys: bool | None - def __init__(self, preserve_quotes: bool | None = None, loader: YAML | None = None) -> None: ... + def __init__(self, preserve_quotes: bool | None = None, loader: YAML | _Loader | None = None) -> None: ... @property def composer(self) -> Composer: ... @property @@ -67,7 +68,7 @@ class BaseConstructor: cls, tag: Tag | str | None, constructor: _ConstructorFunction[Self] ) -> _ConstructorFunction[Self] | None: ... @classmethod - def add_multi_constructor(cls, tag_prefix: str, multi_constructor: _MultiConstructorFunction[Self]) -> None: ... + def add_multi_constructor(cls, tag_prefix: str | None, multi_constructor: _MultiConstructorFunction[Self]) -> None: ... @classmethod def add_default_constructor(cls, tag: str, method: str | None = None, tag_base: str = "tag:yaml.org,2002:") -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi b/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi index 90562f29b711..534985a95ce8 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/cyaml.pyi @@ -2,7 +2,7 @@ from _typeshed import Unused from _ruamel_yaml import CEmitter, CParser -from .compat import StreamTextType, StreamType +from .compat import _ReadStream, _WriteStream from .constructor import BaseConstructor, Constructor, SafeConstructor from .emitter import _LineBreak from .representer import BaseRepresenter, Representer, SafeRepresenter @@ -13,18 +13,18 @@ from .tokens import _ScalarStyle, _VersionTuple __all__ = ["CBaseLoader", "CSafeLoader", "CLoader", "CBaseDumper", "CSafeDumper", "CDumper"] class CBaseLoader(CParser, BaseConstructor, BaseResolver): - def __init__(self, stream: StreamTextType, version: Unused = None, preserve_quotes: Unused = None) -> None: ... + def __init__(self, stream: _ReadStream, version: Unused = None, preserve_quotes: Unused = None) -> None: ... class CSafeLoader(CParser, SafeConstructor, Resolver): - def __init__(self, stream: StreamTextType, version: Unused = None, preserve_quotes: Unused = None) -> None: ... + def __init__(self, stream: _ReadStream, version: Unused = None, preserve_quotes: Unused = None) -> None: ... class CLoader(CParser, Constructor, Resolver): - def __init__(self, stream: StreamTextType, version: Unused = None, preserve_quotes: Unused = None) -> None: ... + def __init__(self, stream: _ReadStream, version: Unused = None, preserve_quotes: Unused = None) -> None: ... class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver): def __init__( self, - stream: StreamType, + stream: _WriteStream, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, canonical: bool | None = None, @@ -45,7 +45,7 @@ class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver): class CSafeDumper(CEmitter, SafeRepresenter, Resolver): def __init__( self, - stream: StreamType, + stream: _WriteStream, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, canonical: bool | None = None, @@ -66,7 +66,7 @@ class CSafeDumper(CEmitter, SafeRepresenter, Resolver): class CDumper(CEmitter, Representer, Resolver): def __init__( self, - stream: StreamType, + stream: _WriteStream, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, canonical: bool | None = None, diff --git a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi index e5615257cd8a..d99122171235 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi @@ -1,8 +1,8 @@ from _typeshed import Unused from typing import TypeAlias -from .compat import StreamType, VersionType -from .emitter import Emitter, _LineBreak +from .compat import VersionType, _WriteStream +from .emitter import Emitter, _Inf, _LineBreak from .representer import BaseRepresenter, Representer, RoundTripRepresenter, SafeRepresenter from .resolver import BaseResolver, Resolver, VersionedResolver from .serializer import Serializer @@ -11,13 +11,12 @@ from .tokens import _ScalarStyle __all__ = ["BaseDumper", "SafeDumper", "Dumper", "RoundTripDumper"] -# https://github.com/python/typeshed/pull/8973 -_Inf: TypeAlias = float +_Dumper: TypeAlias = BaseDumper | SafeDumper | Dumper | RoundTripDumper # noqa: Y047 class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): def __init__( self, - stream: StreamType, + stream: _WriteStream, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, canonical: bool | None = None, @@ -38,7 +37,7 @@ class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): def __init__( self, - stream: StreamType, + stream: _WriteStream, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, canonical: bool | None = None, @@ -59,7 +58,7 @@ class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): class Dumper(Emitter, Serializer, Representer, Resolver): def __init__( self, - stream: StreamType, + stream: _WriteStream, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, canonical: bool | None = None, @@ -80,7 +79,7 @@ class Dumper(Emitter, Serializer, Representer, Resolver): class RoundTripDumper(Emitter, Serializer, RoundTripRepresenter, VersionedResolver): def __init__( self, - stream: StreamType, + stream: _WriteStream, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, canonical: bool | None = None, @@ -94,6 +93,6 @@ class RoundTripDumper(Emitter, Serializer, RoundTripRepresenter, VersionedResolv version: VersionType | None = None, tags: _TagHandleToPrefix | None = None, block_seq_indent: int | None = None, - top_level_colon_align: bool | None = None, + top_level_colon_align: int | None = None, prefix_colon: str | None = None, ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi index c6f6e1e847a9..688a10d7e969 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi @@ -1,7 +1,8 @@ from collections.abc import Callable from typing import Final, Literal, TypeAlias -from .compat import StreamType +from .compat import _WriteStream +from .dumper import _Dumper from .error import YAMLError from .events import Event from .main import YAML @@ -9,10 +10,13 @@ from .serializer import Serializer from .tag import Tag, _TagHandleToPrefix from .tokens import CommentToken, _ScalarStyle, _VersionTuple -_LineBreak: TypeAlias = Literal["\r", "\n", "\r\n"] - __all__ = ["Emitter", "EmitterError"] +# https://github.com/python/typeshed/pull/8973 +_Inf: TypeAlias = float + +_LineBreak: TypeAlias = Literal["\r", "\n", "\r\n"] + class EmitterError(YAMLError): ... class ScalarAnalysis: @@ -55,7 +59,7 @@ class Emitter: flow_map_start: Final = "{" flow_map_end: Final = "}" flow_map_separator: Final = "," - dumper: YAML | None + dumper: YAML | _Dumper | None encoding: str | None allow_space_break: bool | None states: list[Callable[[], None]] @@ -84,11 +88,11 @@ class Emitter: allow_unicode: bool | None unicode_supplementary: bool sequence_dash_offset: int - top_level_colon_align: bool | None + top_level_colon_align: int | None best_sequence_indent: int requested_indent: int | None best_map_indent: int - best_width: int + best_width: int | _Inf best_line_break: _LineBreak tag_prefixes: _TagHandleToPrefix | None prepared_anchor: str | None @@ -99,22 +103,22 @@ class Emitter: alt_null: str def __init__( self, - stream: StreamType, + stream: _WriteStream, canonical: bool | None = None, indent: int | None = None, - width: int | None = None, + width: int | _Inf | None = None, allow_unicode: bool | None = None, line_break: _LineBreak | None = None, block_seq_indent: int | None = None, - top_level_colon_align: bool | None = None, + top_level_colon_align: int | None = None, prefix_colon: str | None = None, brace_single_entry_mapping_in_flow_sequence: bool | None = None, - dumper: YAML | None = None, + dumper: YAML | _Dumper | None = None, ) -> None: ... @property - def stream(self) -> StreamType: ... + def stream(self) -> _WriteStream: ... @stream.setter - def stream(self, val: StreamType) -> None: ... + def stream(self, val: _WriteStream) -> None: ... @property def serializer(self) -> Serializer: ... @property diff --git a/stubs/ruamel.yaml/ruamel/yaml/error.pyi b/stubs/ruamel.yaml/ruamel/yaml/error.pyi index 9d60a77f261e..1e4e03939f09 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/error.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/error.pyi @@ -4,8 +4,6 @@ from _ruamel_yaml import Mark from .nodes import ScalarNode -_Mark: TypeAlias = Mark | StreamMark - __all__ = [ "FileMark", "StringMark", @@ -18,6 +16,8 @@ __all__ = [ "MarkedYAMLFutureWarning", ] +_Mark: TypeAlias = Mark | StreamMark + class StreamMark: name: str | None index: int diff --git a/stubs/ruamel.yaml/ruamel/yaml/loader.pyi b/stubs/ruamel.yaml/ruamel/yaml/loader.pyi index 4e01db1416f8..8de2c711fe78 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/loader.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/loader.pyi @@ -1,6 +1,7 @@ from _typeshed import Unused +from typing import TypeAlias -from .compat import StreamTextType, VersionType +from .compat import VersionType, _ReadStream from .composer import Composer from .constructor import BaseConstructor, Constructor, RoundTripConstructor, SafeConstructor from .parser import Parser, RoundTripParser @@ -10,20 +11,20 @@ from .scanner import RoundTripScanner, Scanner __all__ = ["BaseLoader", "SafeLoader", "Loader", "RoundTripLoader"] +_Loader: TypeAlias = Loader | BaseLoader | SafeLoader | RoundTripLoader # noqa: Y047 + class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, VersionedResolver): comment_handling: int | None - def __init__(self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... + def __init__(self, stream: _ReadStream, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, VersionedResolver): comment_handling: int | None - def __init__(self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... + def __init__(self, stream: _ReadStream, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... class Loader(Reader, Scanner, Parser, Composer, Constructor, VersionedResolver): comment_handling: int | None - def __init__(self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... + def __init__(self, stream: _ReadStream, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... class RoundTripLoader(Reader, RoundTripScanner, RoundTripParser, Composer, RoundTripConstructor, VersionedResolver): comment_handling: int | None - def __init__( - self, stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None - ) -> None: ... + def __init__(self, stream: _ReadStream, version: VersionType | None = None, preserve_quotes: bool | None = None) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/main.pyi b/stubs/ruamel.yaml/ruamel/yaml/main.pyi index dfb33b0dfe45..5740c41639b2 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/main.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/main.pyi @@ -1,28 +1,35 @@ -from _typeshed import Incomplete, SupportsWrite +from _typeshed import Unused +from collections.abc import Callable, Iterable, Iterator, Sequence from pathlib import Path +from re import Pattern from types import ModuleType, TracebackType -from typing import Callable, Final, Literal, NoReturn, Protocol, overload +from typing import Any, ClassVar, Final, Literal, NoReturn, Protocol, TypeVar, overload from typing_extensions import Never, Self, TypeAlias, deprecated +from _ruamel_yaml import CEmitter, CParser + from .comments import CommentedMap, CommentedSeq -from .compat import StreamTextType as StreamTextType, StreamType as StreamType, VersionType as VersionType, nprintf as nprintf +from .compat import VersionType, _ReadStream, _WriteStream from .composer import Composer -from .constructor import BaseConstructor, Constructor, RoundTripConstructor +from .constructor import BaseConstructor, Constructor, RoundTripConstructor, _ConstructorFunction, _MultiConstructorFunction from .docinfo import DocInfo -from .dumper import _Inf -from .emitter import Emitter, RoundTripEmitter -from .error import UnsafeLoaderWarning as UnsafeLoaderWarning -from .events import * -from .nodes import * +from .emitter import Emitter, RoundTripEmitter, _Inf, _LineBreak +from .events import Event +from .nodes import Node from .parser import Parser, RoundTripParser from .reader import Reader -from .representer import BaseRepresenter, Representer, RoundTripRepresenter -from .resolver import BaseResolver, VersionedResolver as VersionedResolver +from .representer import BaseRepresenter, Representer, RoundTripRepresenter, _RepresenterFunction +from .resolver import BaseResolver, _First, _TagStr from .scanner import RoundTripScanner, Scanner from .serializer import Serializer -from .tokens import * +from .tag import Tag, _TagHandleToPrefix +from .tokens import Token, _ScalarStyle, _VersionTuple + +_T = TypeVar("_T") +_Constructor = TypeVar("_Constructor", bound=BaseConstructor) +_Representer = TypeVar("_Representer", bound=BaseRepresenter) -_YAMLType: TypeAlias = str | Literal["rt", "safe", "unsafe", "full", "base"] +_YAMLType: TypeAlias = str | Literal["rt", "safe", "unsafe", "full", "base"] # noqa: Y051 class YAML: typ: list[_YAMLType] @@ -36,22 +43,22 @@ class YAML: Scanner: type[Scanner] | None Serializer: type[Serializer] | None default_flow_style: bool | None - comment_handling: None - Emitter: type[Emitter] # TODO: CEmitter - Parser: type[Parser] # TODO: CParser + comment_handling: int | None + Emitter: type[Emitter | CEmitter] + Parser: type[Parser | CParser] Composer: type[Composer] stream: None canonical: bool | None old_indent: int | None width: int | _Inf | None - line_break: str | None + line_break: _LineBreak | None map_indent: int | None sequence_indent: int | None sequence_dash_offset: int compact_seq_seq: bool | None compact_seq_map: bool | None sort_base_mapping_type_on_output: bool | None - top_level_colon_align: bool | None + top_level_colon_align: int | Literal[True] | None prefix_colon: str | None preserve_quotes: bool | None allow_duplicate_keys: bool @@ -59,17 +66,18 @@ class YAML: explicit_start: bool | None explicit_end: bool | None doc_infos: list[DocInfo] - default_style: str | None + default_style: _ScalarStyle | None top_level_block_style_scalar_no_indent_error_1_1: bool scalar_after_indicator: bool | None brace_single_entry_mapping_in_flow_sequence: bool + boolean_representation: Sequence[str] @overload def __new__( cls, *, typ: Literal["rt"] | list[Literal["rt"]] | None = None, pure: bool = False, - output: Path | SupportsWrite[str] | None = None, + output: Path | _WriteStream | None = None, plug_ins: list[str] | None = None, ) -> _RoundTripYAML: ... @overload @@ -78,7 +86,7 @@ class YAML: *, typ: Literal["full"] | list[Literal["full"]], pure: bool = False, - output: Path | SupportsWrite[str] | None = None, + output: Path | _WriteStream | None = None, plug_ins: list[str] | None = None, ) -> _FullYAML: ... @overload @@ -87,7 +95,7 @@ class YAML: *, typ: _YAMLType | list[_YAMLType], pure: bool = False, - output: Path | SupportsWrite[str] | None = None, + output: Path | _WriteStream | None = None, plug_ins: list[str] | None = None, ) -> Self: ... # This redundant overload prevents type checkers from matching the deprecated "unsafe" overload @@ -98,7 +106,7 @@ class YAML: *, typ: Literal["rt"] | list[Literal["rt"]] | None = None, pure: bool = False, - output: Path | SupportsWrite[str] | None = None, + output: Path | _WriteStream | None = None, plug_ins: list[str] | None = None, ) -> None: ... @overload @@ -108,7 +116,7 @@ class YAML: *, typ: Literal["unsafe"] | list[Literal["unsafe"]], pure: bool = False, - output: Path | SupportsWrite[str] | None = None, + output: Path | _WriteStream | None = None, plug_ins: list[str] | None = None, ) -> None: ... @overload @@ -117,7 +125,7 @@ class YAML: *, typ: _YAMLType | list[_YAMLType], pure: bool = False, - output: Path | SupportsWrite[str] | None = None, + output: Path | _WriteStream | None = None, plug_ins: list[str] | None = None, ) -> None: ... @property @@ -125,7 +133,7 @@ class YAML: @property def scanner(self) -> Scanner: ... @property - def parser(self) -> Parser | None: ... # TODO: CParser + def parser(self) -> Parser | CParser | None: ... @property def composer(self) -> Composer: ... @property @@ -133,39 +141,51 @@ class YAML: @property def resolver(self) -> BaseResolver: ... @property - def emitter(self) -> Emitter | None: ... # TODO: CEmitter + def emitter(self) -> Emitter | CEmitter | None: ... @property def serializer(self) -> Serializer: ... @property def representer(self) -> BaseRepresenter: ... - def scan(self, stream: StreamTextType): ... - def parse(self, stream: StreamTextType): ... - def compose(self, stream: Path | StreamTextType): ... - def compose_all(self, stream: Path | StreamTextType): ... - def load(self, stream: Path | StreamTextType): ... - def load_all(self, stream: Path | StreamTextType): ... - def get_constructor_parser(self, stream: StreamTextType): ... - def emit(self, events, stream) -> None: ... - def serialize(self, node, stream: StreamType | None): ... - def serialize_all(self, nodes, stream: StreamType | None): ... - def dump(self, data: Path | StreamType, stream: Incomplete | None = None, *, transform: Incomplete | None = None): ... - def dump_all(self, documents, stream: Path | StreamType, *, transform: Incomplete | None = None): ... - def Xdump_all(self, documents, stream, *, transform: Incomplete | None = None): ... - def get_serializer_representer_emitter(self, stream: StreamType, tlca): ... - def map(self, **kw) -> dict: ... - def seq(self, *args) -> list: ... + def scan(self, stream: _ReadStream) -> Iterator[Token]: ... + def parse(self, stream: _ReadStream) -> Iterator[Event]: ... + def compose(self, stream: Path | _ReadStream) -> Node: ... + def compose_all(self, stream: _ReadStream) -> Iterator[Node]: ... + def load(self, stream: Path | _ReadStream) -> Any: ... + def load_all(self, stream: Path | _ReadStream) -> Iterator[Any]: ... + def get_constructor_parser(self, stream: _ReadStream) -> tuple[BaseConstructor, Parser | CParser]: ... + def emit(self, events: Iterable[Event], stream: _WriteStream) -> None: ... + def serialize(self, node: Node, stream: _WriteStream) -> None: ... + def serialize_all(self, nodes: Iterable[Node], stream: _WriteStream) -> None: ... + def dump(self, data: Any, stream: Path | _WriteStream, *, transform: Callable[[str], str] | None = None) -> None: ... + def dump_all( + self, documents: Iterable[Any], stream: Path | _WriteStream, *, transform: Callable[[str], str] | None = None + ) -> None: ... + def Xdump_all( + self, documents: Iterable[Any], stream: Path | _WriteStream, *, transform: Callable[[str], str] | None = None + ) -> None: ... + def get_serializer_representer_emitter( + self, stream: _WriteStream, tlca: int | None + ) -> tuple[Serializer, BaseRepresenter, Emitter | CEmitter]: ... + @overload + def map(self) -> dict[Any, Any]: ... + @overload + def map(self, **kw: _T) -> dict[str, _T]: ... + @overload + def seq(self) -> list[Any]: ... + @overload + def seq(self, iterable: Iterable[_T], /) -> list[_T]: ... def official_plug_ins(self) -> list[str]: ... def register_class(self, cls: _RegistrableClass) -> _RegistrableClass: ... def __enter__(self) -> _YAMLContext: ... def __exit__(self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None) -> None: ... @property - def version(self) -> tuple[int, int] | None: ... + def version(self) -> _VersionTuple | None: ... @version.setter def version(self, val: VersionType) -> None: ... @property - def tags(self): ... + def tags(self) -> _TagHandleToPrefix | None: ... @tags.setter - def tags(self, val) -> None: ... + def tags(self, val: _TagHandleToPrefix | None) -> None: ... @property def indent(self) -> _IndentSetter: ... @indent.setter @@ -186,8 +206,14 @@ class _RoundTripYAML(YAML): Scanner: type[RoundTripScanner] Emitter: type[RoundTripEmitter] Parser: type[RoundTripParser] - def map(self, **kw) -> CommentedMap: ... - def seq(self, *args) -> CommentedSeq: ... + @overload + def map(self) -> CommentedMap[Any, Any]: ... + @overload + def map(self, **kw: _T) -> CommentedMap[str, _T]: ... + @overload + def seq(self) -> CommentedSeq[Any]: ... + @overload + def seq(self, iterable: Iterable[_T], /) -> CommentedSeq[_T]: ... def __enter__(self) -> _RoundTripYAMLContext: ... class _FullYAML(YAML): @@ -199,31 +225,32 @@ class _FullYAML(YAML): @property def constructor(self) -> NoReturn: ... @deprecated("You can only use YAML(typ='full') for dumping") - def scan(self, stream: Incomplete) -> NoReturn: ... + def scan(self, stream) -> NoReturn: ... @deprecated("You can only use YAML(typ='full') for dumping") - def parse(self, stream: Incomplete) -> NoReturn: ... + def parse(self, stream) -> NoReturn: ... @deprecated("You can only use YAML(typ='full') for dumping") - def compose(self, stream: Path | Incomplete) -> NoReturn: ... + def compose(self, stream) -> NoReturn: ... @deprecated("You can only use YAML(typ='full') for dumping") - def compose_all(self, stream: Path | Incomplete) -> NoReturn: ... + def compose_all(self, stream) -> NoReturn: ... @deprecated("You can only use YAML(typ='full') for dumping") - def load(self, stream: Path | Incomplete) -> NoReturn: ... + def load(self, stream) -> NoReturn: ... @deprecated("You can only use YAML(typ='full') for dumping") - def load_all(self, stream: Path | Incomplete) -> NoReturn: ... - def get_constructor_parser(self, stream: StreamTextType) -> NoReturn: ... + def load_all(self, stream) -> NoReturn: ... + def get_constructor_parser(self, stream) -> NoReturn: ... def __enter__(self) -> _FullYAMLContext: ... class _YAMLContext(YAML): - def dump_all(self, documents, stream: Path | Incomplete, *, transform: Incomplete | None = ...) -> NoReturn: ... + def dump(self, data: Any, stream: Unused = None, *, transform: None = None) -> None: ... + def dump_all(self, documents, stream=None, *, transform=None) -> NoReturn: ... class _RoundTripYAMLContext(_YAMLContext, _RoundTripYAML): ... class _FullYAMLContext(_YAMLContext, _FullYAML): ... class YAMLContextManager: - def __init__(self, yaml, transform: Incomplete | None = None) -> None: ... + def __init__(self, yaml: YAML, transform: Callable[[str], str] | None = None) -> None: ... def teardown_output(self) -> None: ... - def init_output(self, first_data) -> None: ... - def dump(self, data) -> None: ... + def init_output(self, first_data: Any) -> None: ... + def dump(self, data: Any) -> None: ... # This is because we can't mark protocol fields as not required # See https://github.com/python/typing/issues/601 @@ -240,144 +267,105 @@ def yaml_object(yml: YAML) -> Callable[[_RegistrableClass], _RegistrableClass]: def warn_deprecation(fun: str, method: str, arg: str = "") -> None: ... def error_deprecation(fun: str, method: str, arg: str = "", comment: str = "instead of") -> NoReturn: ... @deprecated("Use YAML().scan() instead") -def scan(stream: StreamTextType, Loader=...) -> NoReturn: ... +def scan(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML().parse() instead") -def parse(stream: StreamTextType, Loader=...) -> NoReturn: ... +def parse(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML().compose() instead") -def compose(stream: StreamTextType, Loader=...) -> NoReturn: ... +def compose(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML().compose_all() instead") -def compose_all(stream: StreamTextType, Loader=...) -> NoReturn: ... +def compose_all(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML().load() instead") -def load(stream, Loader=None, version=None, preserve_quotes=None) -> NoReturn: ... +def load(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML().load_all() instead") -def load_all(stream, Loader=None, version=None, preserve_quotes=None) -> NoReturn: ... +def load_all(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML(typ='safe', pure=True).load() instead") -def safe_load(stream: StreamTextType, version: VersionType | None = None) -> NoReturn: ... +def safe_load(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML(typ='safe', pure=True).load_all() instead") -def safe_load_all(stream: StreamTextType, version: VersionType | None = None) -> NoReturn: ... +def safe_load_all(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML().load() instead") -def round_trip_load( - stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None -) -> NoReturn: ... +def round_trip_load(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML().load_all() instead") -def round_trip_load_all( - stream: StreamTextType, version: VersionType | None = None, preserve_quotes: bool | None = None -) -> NoReturn: ... +def round_trip_load_all(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML(typ='safe', pure=True).emit() instead") -def emit( - events, - stream: StreamType | None = None, - Dumper=..., - canonical: bool | None = None, - indent: int | None = None, - width: int | None = None, - allow_unicode: bool | None = None, - line_break=None, -) -> NoReturn: ... - -enc: None - +def emit(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML(typ='safe', pure=True).serialize_all() instead") -def serialize_all( - nodes, - stream: StreamType | None = None, - Dumper=..., - canonical=None, - indent: int | None = None, - width: int | None = None, - allow_unicode: bool | None = None, - line_break=None, - encoding=None, - explicit_start: bool | None = None, - explicit_end: bool | None = None, - version: VersionType | None = None, - tags=None, -) -> NoReturn: ... +def serialize_all(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML(typ='safe', pure=True).serialize() instead") -def serialize(node, stream: StreamType | None = None, Dumper=..., **kwds) -> NoReturn: ... +def serialize(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML(typ='unsafe', pure=True).dump_all() instead") -def dump_all( - documents, - stream: StreamType | None = None, - Dumper=..., - default_style=None, - default_flow_style=None, - canonical: bool | None = None, - indent: int | None = None, - width: int | None = None, - allow_unicode: bool | None = None, - line_break=None, - encoding=None, - explicit_start: bool | None = None, - explicit_end: bool | None = None, - version=None, - tags=None, - block_seq_indent=None, - top_level_colon_align=None, - prefix_colon=None, -) -> NoReturn: ... +def dump_all(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML(typ='unsafe', pure=True).dump() instead") -def dump( - data, - stream: StreamType | None = None, - Dumper=..., - default_style=None, - default_flow_style=None, - canonical: bool | None = None, - indent: int | None = None, - width: int | None = None, - allow_unicode: bool | None = None, - line_break=None, - encoding=None, - explicit_start: bool | None = None, - explicit_end: bool | None = None, - version: VersionType | None = None, - tags=None, - block_seq_indent=None, -) -> NoReturn: ... +def dump(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML(typ='safe', pure=True).dump() instead") -def safe_dump(data, stream: StreamType | None = None, **kwds) -> NoReturn: ... +def safe_dump(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML().dump() instead") -def round_trip_dump( - data, - stream: StreamType | None = None, - Dumper=..., - default_style=None, - default_flow_style=None, - canonical: bool | None = None, - indent: int | None = None, - width: int | None = None, - allow_unicode: bool | None = None, - line_break=None, - encoding=None, - explicit_start: bool | None = None, - explicit_end: bool | None = None, - version: VersionType | None = None, - tags=None, - block_seq_indent=None, - top_level_colon_align=None, - prefix_colon=None, -) -> NoReturn: ... +def round_trip_dump(*args, **kwargs) -> NoReturn: ... def add_implicit_resolver( - tag, regexp, first: Incomplete | None = None, Loader: Incomplete | None = None, Dumper: Incomplete | None = None, resolver=... + tag: _TagStr, + regexp: Pattern[str], + first: list[_First] | None = None, + Loader: type[BaseResolver] | None = None, + Dumper: type[BaseResolver] | None = None, + resolver: type[BaseResolver] = ..., ) -> None: ... def add_path_resolver( - tag, path, kind: Incomplete | None = None, Loader: Incomplete | None = None, Dumper: Incomplete | None = None, resolver=... + tag: _TagStr, + path: Iterable[Any], + kind: type | None = None, + Loader: type[BaseResolver] | None = None, + Dumper: type[BaseResolver] | None = None, + resolver: type[BaseResolver] = ..., +) -> None: ... +@overload +def add_constructor( + tag: Tag | str | None, object_constructor: _ConstructorFunction[_Constructor], *, constructor: type[_Constructor] +) -> None: ... +@overload +def add_constructor( + tag: Tag | str | None, object_constructor: _ConstructorFunction[_Constructor], Loader: type[_Constructor] +) -> None: ... +@overload +def add_constructor(tag: Tag | str | None, object_constructor: _ConstructorFunction[Constructor]) -> None: ... +@overload +def add_multi_constructor( + tag_prefix: str | None, multi_constructor: _MultiConstructorFunction[_Constructor], *, constructor: type[_Constructor] +) -> None: ... +@overload +def add_multi_constructor( + tag_prefix: str | None, multi_constructor: _MultiConstructorFunction[_Constructor], Loader: type[_Constructor] +) -> None: ... +@overload +def add_multi_constructor(tag_prefix: str | None, multi_constructor: _MultiConstructorFunction[Constructor]) -> None: ... +@overload +def add_representer( + data_type: type[_T] | None, object_representer: _RepresenterFunction[_Representer, _T], *, representer: type[_Representer] +) -> None: ... +@overload +def add_representer( + data_type: type[_T] | None, object_representer: _RepresenterFunction[_Representer, _T], Dumper: type[_Representer] +) -> None: ... +@overload +def add_representer(data_type: type[_T] | None, object_representer: _RepresenterFunction[Representer, _T]) -> None: ... +@overload +def add_multi_representer( + data_type: type[_T] | None, multi_representer: _RepresenterFunction[_Representer, _T], *, representer: type[_Representer] +) -> None: ... +@overload +def add_multi_representer( + data_type: type[_T] | None, multi_representer: _RepresenterFunction[_Representer, _T], Dumper: type[_Representer] ) -> None: ... -def add_constructor(tag, object_constructor, Loader: Incomplete | None = None, constructor=...) -> None: ... -def add_multi_constructor(tag_prefix, multi_constructor, Loader: Incomplete | None = None, constructor=...) -> None: ... -def add_representer(data_type, object_representer, Dumper: Incomplete | None = None, representer=...) -> None: ... -def add_multi_representer(data_type, multi_representer, Dumper: Incomplete | None = None, representer=...) -> None: ... +@overload +def add_multi_representer(data_type: type[_T] | None, multi_representer: _RepresenterFunction[Representer, _T]) -> None: ... class YAMLObjectMetaclass(type): - def __init__(cls, name, bases, kwds) -> None: ... + def __init__(cls, name: str, bases: tuple[type, ...], kwds: dict[str, Any], /) -> None: ... -class YAMLObject(Incomplete): - yaml_constructor = Constructor - yaml_representer = Representer - yaml_tag: Incomplete - yaml_flow_style: Incomplete +class YAMLObject(metaclass=YAMLObjectMetaclass): + yaml_constructor: ClassVar[type[BaseConstructor]] + yaml_representer: ClassVar[type[BaseRepresenter]] + yaml_tag: Tag | str | None + yaml_flow_style: bool | None @classmethod - def from_yaml(cls, constructor, node): ... + def from_yaml(cls, constructor: BaseConstructor, node: Node) -> Self: ... @classmethod - def to_yaml(cls, representer, data): ... + def to_yaml(cls, representer: BaseRepresenter, data: Self) -> Node: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi index f60874558d5e..df60a22cd83b 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi @@ -54,7 +54,7 @@ class _CollectionNode(Generic[_T]): flow_style: bool | None def __init__( self, - tag: Tag | str, + tag: Tag | str | None, value: list[_T], start_mark: _Mark | None = None, end_mark: _Mark | None = None, diff --git a/stubs/ruamel.yaml/ruamel/yaml/parser.pyi b/stubs/ruamel.yaml/ruamel/yaml/parser.pyi index 43f318b47dbf..73fd419f2314 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/parser.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/parser.pyi @@ -3,6 +3,7 @@ from typing import Final from .error import MarkedYAMLError, _Mark from .events import Event +from .loader import _Loader from .main import YAML from .resolver import BaseResolver from .scanner import Scanner @@ -15,8 +16,8 @@ class ParserError(MarkedYAMLError): ... class Parser: DEFAULT_TAGS: Final[_TagHandleToPrefix] - loader: YAML - def __init__(self, loader: YAML) -> None: ... + loader: YAML | _Loader + def __init__(self, loader: YAML | _Loader) -> None: ... current_event: Event | None last_event: Event | None tag_handles: _TagHandleToPrefix diff --git a/stubs/ruamel.yaml/ruamel/yaml/reader.pyi b/stubs/ruamel.yaml/ruamel/yaml/reader.pyi index 0ac524c67a3d..919a7e32b124 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/reader.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/reader.pyi @@ -2,16 +2,17 @@ from _typeshed import ReadableBuffer, SupportsRead from re import Pattern from typing import Final, Literal, Protocol -from .compat import StreamTextType +from .compat import _ReadStream from .error import StreamMark, YAMLError +from .loader import _Loader from .main import YAML +__all__ = ["Reader", "ReaderError"] + # One of codecs.{utf_16_le_decode, utf_16_be_decode, utf_8_decode} class _BufferDecoder(Protocol): def __call__(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ... -__all__ = ["Reader", "ReaderError"] - class ReaderError(YAMLError): name: str | None character: int @@ -21,8 +22,8 @@ class ReaderError(YAMLError): def __init__(self, name: str | None, position: int, character: int, encoding: str, reason: str) -> None: ... class Reader: - loader: YAML | None - def __init__(self, stream: StreamTextType | None, loader: YAML | None = None) -> None: ... + loader: YAML | _Loader | None + def __init__(self, stream: _ReadStream | None, loader: YAML | _Loader | None = None) -> None: ... name: str | None stream_pointer: int eof: bool @@ -38,7 +39,7 @@ class Reader: @property def stream(self) -> SupportsRead[str | bytes] | None: ... @stream.setter - def stream(self, val: StreamTextType | None, /) -> None: ... + def stream(self, val: _ReadStream | None, /) -> None: ... def peek(self, index: int = 0) -> str: ... def prefix(self, length: int = 1) -> str: ... def forward_1_1(self, length: int = 1) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi index 5c05704673bb..676bc0722bd6 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi @@ -7,6 +7,7 @@ from typing import Any, ClassVar, Final, NoReturn, Protocol, Self, TypeVar from .anchor import Anchor from .comments import CommentedMap, CommentedSeq, CommentedSet, TaggedScalar +from .dumper import _Dumper from .error import YAMLError from .main import YAML from .nodes import MappingNode, Node, ScalarNode, SequenceNode @@ -25,6 +26,8 @@ from .tag import Tag from .timestamp import TimeStamp from .tokens import _CommentGroup, _ScalarStyle +__all__ = ["BaseRepresenter", "SafeRepresenter", "Representer", "RepresenterError", "RoundTripRepresenter"] + _T = TypeVar("_T") _T_contra = TypeVar("_T_contra", contravariant=True) _Representer = TypeVar("_Representer", bound=BaseRepresenter, contravariant=True) @@ -32,14 +35,12 @@ _Representer = TypeVar("_Representer", bound=BaseRepresenter, contravariant=True class _RepresenterFunction(Protocol[_Representer, _T_contra]): def __call__(self, dumper: _Representer, data: _T_contra, /) -> Node: ... -__all__ = ["BaseRepresenter", "SafeRepresenter", "Representer", "RepresenterError", "RoundTripRepresenter"] - class RepresenterError(YAMLError): ... class BaseRepresenter: yaml_representers: ClassVar[dict[type | None, _RepresenterFunction[Self, Any]]] yaml_multi_representers: ClassVar[dict[type | None, _RepresenterFunction[Self, Any]]] - dumper: YAML | None + dumper: YAML | _Dumper | None default_style: _ScalarStyle | None default_flow_style: bool | None represented_objects: dict[int, Node] @@ -47,7 +48,10 @@ class BaseRepresenter: alias_key: int | None sort_base_mapping_type_on_output: bool def __init__( - self, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, dumper: YAML | None = None + self, + default_style: _ScalarStyle | None = None, + default_flow_style: bool | None = None, + dumper: YAML | _Dumper | None = None, ) -> None: ... @property def serializer(self) -> Serializer: ... @@ -59,11 +63,17 @@ class BaseRepresenter: @classmethod def add_multi_representer(cls, data_type: type[_T] | None, representer: _RepresenterFunction[Self, _T]) -> None: ... def represent_scalar( - self, tag: Tag | str, value: str, style: _ScalarStyle | None = None, anchor: Anchor | None = None + self, tag: Tag | str | None, value: str, style: _ScalarStyle | None = None, anchor: Anchor | None = None ) -> ScalarNode: ... - def represent_sequence(self, tag: Tag | str, sequence: Collection[Any], flow_style: bool | None = None) -> SequenceNode: ... - def represent_omap(self, tag: Tag | str, omap: OrderedDict[Any, Any], flow_style: bool | None = None) -> SequenceNode: ... - def represent_mapping(self, tag: Tag | str, mapping: Mapping[Any, Any], flow_style: bool | None = None) -> MappingNode: ... + def represent_sequence( + self, tag: Tag | str | None, sequence: Collection[Any], flow_style: bool | None = None + ) -> SequenceNode: ... + def represent_omap( + self, tag: Tag | str | None, omap: OrderedDict[Any, Any], flow_style: bool | None = None + ) -> SequenceNode: ... + def represent_mapping( + self, tag: Tag | str | None, mapping: Mapping[Any, Any], flow_style: bool | None = None + ) -> MappingNode: ... def ignore_aliases(self, data: Any) -> bool: ... class SafeRepresenter(BaseRepresenter): @@ -81,7 +91,9 @@ class SafeRepresenter(BaseRepresenter): def represent_set(self, data: AbstractSet[Any]) -> MappingNode: ... def represent_date(self, data: date) -> ScalarNode: ... def represent_datetime(self, data: datetime) -> ScalarNode: ... - def represent_yaml_object(self, tag: Tag | str, data: Any, cls: Unused, flow_style: bool | None = None) -> MappingNode: ... + def represent_yaml_object( + self, tag: Tag | str | None, data: Any, cls: Unused, flow_style: bool | None = None + ) -> MappingNode: ... def represent_undefined(self, data: object) -> NoReturn: ... class Representer(SafeRepresenter): @@ -93,7 +105,10 @@ class Representer(SafeRepresenter): class RoundTripRepresenter(SafeRepresenter): def __init__( - self, default_style: _ScalarStyle | None = None, default_flow_style: bool | None = None, dumper: YAML | None = None + self, + default_style: _ScalarStyle | None = None, + default_flow_style: bool | None = None, + dumper: YAML | _Dumper | None = None, ) -> None: ... def ignore_aliases(self, data: Any) -> bool: ... def represent_none(self, data: None) -> ScalarNode: ... @@ -112,15 +127,23 @@ class RoundTripRepresenter(SafeRepresenter): def represent_hex_int(self, data: HexInt) -> ScalarNode: ... def represent_hex_caps_int(self, data: HexCapsInt) -> ScalarNode: ... def represent_scalar_float(self, data: ScalarFloat) -> ScalarNode: ... - def represent_sequence(self, tag: Tag | str, sequence: Collection[Any], flow_style: bool | None = None) -> SequenceNode: ... + def represent_sequence( + self, tag: Tag | str | None, sequence: Collection[Any], flow_style: bool | None = None + ) -> SequenceNode: ... def merge_comments(self, node: Node, comments: _CommentGroup | None) -> Node: ... def represent_key(self, data: Any) -> Node: ... - def represent_mapping(self, tag: Tag | str, mapping: Mapping[Any, Any], flow_style: bool | None = None) -> MappingNode: ... - def represent_omap(self, tag: Tag | str, omap: OrderedDict[Any, Any], flow_style: bool | None = None) -> SequenceNode: ... + def represent_mapping( + self, tag: Tag | str | None, mapping: Mapping[Any, Any], flow_style: bool | None = None + ) -> MappingNode: ... + def represent_omap( + self, tag: Tag | str | None, omap: OrderedDict[Any, Any], flow_style: bool | None = None + ) -> SequenceNode: ... def represent_set(self, setting: CommentedSet[Any]) -> MappingNode: ... def represent_dict(self, data: CommentedMap[Any, Any]) -> MappingNode: ... def represent_list(self, data: CommentedSeq[Any]) -> SequenceNode: ... def represent_datetime(self, data: TimeStamp) -> ScalarNode: ... def represent_tagged_scalar(self, data: TaggedScalar) -> ScalarNode: ... def represent_scalar_bool(self, data: ScalarBoolean) -> ScalarNode: ... - def represent_yaml_object(self, tag: Tag | str, data: Any, cls: Unused, flow_style: bool | None = None) -> MappingNode: ... + def represent_yaml_object( + self, tag: Tag | str | None, data: Any, cls: Unused, flow_style: bool | None = None + ) -> MappingNode: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi index 09db08b3cbaf..46b0780c9b37 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi @@ -3,18 +3,20 @@ from re import Pattern from typing import Any, Final, TypeAlias, overload from .compat import VersionType +from .dumper import _Dumper from .error import YAMLError +from .loader import _Loader from .main import YAML from .nodes import CollectionNode, MappingNode, Node, ScalarNode, SequenceNode from .parser import Parser from .tag import Tag from .tokens import _VersionTuple +__all__ = ["BaseResolver", "Resolver", "VersionedResolver"] + _TagStr: TypeAlias = str _First: TypeAlias = str | None -__all__ = ["BaseResolver", "Resolver", "VersionedResolver"] - implicit_resolvers: list[tuple[list[_VersionTuple], _TagStr, Pattern[str], list[_First]]] class ResolverError(YAMLError): ... @@ -25,10 +27,10 @@ class BaseResolver: DEFAULT_MAPPING_TAG: Final[Tag] yaml_implicit_resolvers: dict[_First, list[tuple[_TagStr, Pattern[str]]]] yaml_path_resolvers: dict[Any, _TagStr] - loadumper: YAML | None + loadumper: YAML | _Loader | _Dumper | None resolver_exact_paths: list[Any] resolver_prefix_paths: list[Any] - def __init__(self, loadumper: YAML | None = None) -> None: ... + def __init__(self, loadumper: YAML | _Loader | _Dumper | None = None) -> None: ... @property def parser(self) -> Parser | None: ... @classmethod @@ -52,7 +54,12 @@ class BaseResolver: class Resolver(BaseResolver): ... class VersionedResolver(BaseResolver): - def __init__(self, version: VersionType | None = None, loader: YAML | None = None, loadumper: YAML | None = None) -> None: ... + def __init__( + self, + version: VersionType | None = None, + loader: YAML | _Loader | _Dumper | None = None, + loadumper: YAML | _Loader | _Dumper | None = None, + ) -> None: ... def add_version_implicit_resolver( self, version: VersionType, tag: _TagStr, regexp: Pattern[str], first: list[_First] | None ) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi index f3819e541329..54f117988317 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi @@ -1,10 +1,12 @@ +from typing import Self + from .anchor import Anchor __all__ = ["ScalarBoolean"] class ScalarBoolean(int): - def __new__(cls, value: bool, /, *, anchor: str | None = None): ... + def __new__(cls, value: bool, /, *, anchor: str | None = None) -> Self: ... @property def anchor(self) -> Anchor: ... - def yaml_anchor(self, *, any: bool = False): ... + def yaml_anchor(self, *, any: bool = False) -> Anchor | None: ... def yaml_set_anchor(self, value: str, /, *, always_dump: bool = False) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi index dab7071414fd..382e08d5605e 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi @@ -43,7 +43,7 @@ class ScalarFloat(float): def dump(self, out: SupportsWrite[str] = ...) -> None: ... class ExponentialFloat(ScalarFloat): - def __new__(cls, value: float, /, *, width: int | None = None, underscore: _Underscore | None = None): ... + def __new__(cls, value: float, /, *, width: int | None = None, underscore: _Underscore | None = None) -> Self: ... class ExponentialCapsFloat(ScalarFloat): - def __new__(cls, value: float, /, *, width: int | None = None, underscore: _Underscore | None = None): ... + def __new__(cls, value: float, /, *, width: int | None = None, underscore: _Underscore | None = None) -> Self: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi index e94f7f966e22..d5bbade1c8dd 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi @@ -1,7 +1,8 @@ from collections.abc import Iterator -from typing import ClassVar, Final +from typing import ClassVar, Final, Literal from .error import MarkedYAMLError, StreamMark +from .loader import _Loader from .main import YAML from .reader import Reader from .tokens import ( @@ -38,9 +39,9 @@ class SimpleKey: def __init__(self, token_number: int, required: bool, index: int, line: int, column: int, mark: StreamMark) -> None: ... class Scanner: - loader: YAML | None + loader: YAML | _Loader | None first_time: bool - def __init__(self, loader: YAML | None = None) -> None: ... + def __init__(self, loader: YAML | _Loader | None = None) -> None: ... @property def flow_level(self) -> int: ... done: bool @@ -98,9 +99,9 @@ class Scanner: def fetch_double(self) -> None: ... def fetch_flow_scalar(self, style: _FlowScalarStyle) -> None: ... def fetch_plain(self) -> None: ... - def check_directive(self): ... - def check_document_start(self): ... - def check_document_end(self): ... + def check_directive(self) -> Literal[True] | None: ... + def check_document_start(self) -> Literal[True] | None: ... + def check_document_end(self) -> Literal[True] | None: ... def check_block_entry(self) -> bool: ... def check_key(self) -> bool: ... def check_value(self) -> bool: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi b/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi index b3215c27bcaa..13aa0c2e6d03 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/serializer.pyi @@ -2,6 +2,7 @@ from re import Pattern from typing import Final, Literal from .compat import VersionType +from .dumper import _Dumper from .emitter import Emitter from .error import YAMLError from .main import YAML @@ -17,7 +18,7 @@ class SerializerError(YAMLError): ... class Serializer: ANCHOR_TEMPLATE: Final[str] ANCHOR_RE: Final[Pattern[str]] - dumper: YAML | None + dumper: YAML | _Dumper | None use_encoding: str | None use_explicit_start: bool | None use_explicit_end: bool | None @@ -34,7 +35,7 @@ class Serializer: explicit_end: bool | None = None, version: VersionType | None = None, tags: _TagHandleToPrefix | None = None, - dumper: YAML | None = None, + dumper: YAML | _Dumper | None = None, ) -> None: ... @property def emitter(self) -> Emitter: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi index a5c0af7348cb..b58f44edaf9c 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi @@ -3,8 +3,6 @@ from typing_extensions import TypeAlias from .error import CommentMark, StreamMark, _Mark -SHOW_LINES: bool - _PostComment: TypeAlias = CommentToken _PreComments: TypeAlias = list[CommentToken] | list[str] _CommentGroup: TypeAlias = list[_PostComment | _PreComments | None] @@ -14,6 +12,8 @@ _FlowScalarStyle: TypeAlias = Literal['"', "'"] _BlockScalarStyle: TypeAlias = Literal["|", ">"] _ScalarStyle: TypeAlias = _FlowScalarStyle | _BlockScalarStyle | Literal[""] +SHOW_LINES: bool + class Token: id: ClassVar[str] start_mark: _Mark diff --git a/stubs/ruamel.yaml/ruamel/yaml/util.pyi b/stubs/ruamel.yaml/ruamel/yaml/util.pyi index 0095c8416789..e4a1b82f17ae 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/util.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/util.pyi @@ -5,7 +5,7 @@ from typing import Any, Final from configobj import ConfigObj # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] -from .compat import StreamTextType +from .compat import _ReadStream class LazyEval: def __init__(self, func: Callable[..., Any], *args, **kwargs) -> None: ... @@ -30,5 +30,5 @@ def create_timestamp( tz_hour: str | None, tz_minute: str | None, ) -> date | datetime: ... -def load_yaml_guess_indent(stream: StreamTextType, /) -> tuple[Any, int | None, int | None]: ... +def load_yaml_guess_indent(stream: _ReadStream, /) -> tuple[Any, int | None, int | None]: ... def configobj_walker(cfg: ConfigObj, /) -> Iterator[str]: ... From 92cea96d9227090345a3e7eb9d24cfcd2dd44993 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Sun, 15 Sep 2024 20:07:39 +0000 Subject: [PATCH 09/15] Fix or ignore mypy errors --- stubs/ruamel.yaml/ruamel/yaml/comments.pyi | 30 ++++++----- stubs/ruamel.yaml/ruamel/yaml/compat.pyi | 4 +- stubs/ruamel.yaml/ruamel/yaml/constructor.pyi | 11 ++-- stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/dumper.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/emitter.pyi | 3 +- stubs/ruamel.yaml/ruamel/yaml/error.pyi | 7 +-- stubs/ruamel.yaml/ruamel/yaml/events.pyi | 22 ++++---- stubs/ruamel.yaml/ruamel/yaml/loader.pyi | 10 ++-- stubs/ruamel.yaml/ruamel/yaml/main.pyi | 34 +++++++------ stubs/ruamel.yaml/ruamel/yaml/nodes.pyi | 8 +-- stubs/ruamel.yaml/ruamel/yaml/representer.pyi | 11 ++-- stubs/ruamel.yaml/ruamel/yaml/resolver.pyi | 5 +- stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi | 5 +- stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi | 5 +- .../ruamel.yaml/ruamel/yaml/scalarstring.pyi | 3 +- stubs/ruamel.yaml/ruamel/yaml/scanner.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/tag.pyi | 5 +- stubs/ruamel.yaml/ruamel/yaml/tokens.pyi | 50 +++++++++---------- 20 files changed, 115 insertions(+), 106 deletions(-) diff --git a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi index 054d7e7440a8..0c29ea884b18 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi @@ -1,7 +1,8 @@ import sys from _typeshed import SupportsWrite, sentinel from collections.abc import Hashable, Iterable, Iterator, Mapping, MutableSet, Set as AbstractSet, Sized -from typing import Any, Final, Generic, NoReturn, Self, TypeAlias, TypeVar +from typing import Any, Final, Generic, NoReturn, TypeVar +from typing_extensions import Self, TypeAlias from .anchor import Anchor from .compat import MutableSliceableSequence, ordereddict @@ -105,7 +106,7 @@ class CommentedBase: def yaml_set_ctag(self, value: Tag, /) -> None: ... def copy_attributes(self, t: _Commented, memo: dict[int, Any] | None = None) -> _Commented: ... -class CommentedSeq(MutableSliceableSequence[_T], list[_T], CommentedBase): +class CommentedSeq(MutableSliceableSequence[_T], list[_T], CommentedBase): # type: ignore[misc] def __getsingleitem__(self, idx: int) -> _T: ... def __setsingleitem__(self, idx: int, value: _T) -> None: ... def __delsingleitem__(self, idx: int) -> None: ... @@ -136,9 +137,9 @@ class CommentedMap(ordereddict[_KT, _VT], CommentedBase): def insert(self, pos: int, key: _KT, value: _VT, comment: str | None = None) -> None: ... def mlget(self, key: list[_Index | _Key], default: Any = None, list_ok: bool = False) -> Any: ... def non_merged_items(self) -> Iterator[tuple[_KT, _VT]]: ... - def keys(self) -> CommentedMapKeysView[_KT]: ... - def values(self) -> CommentedMapValuesView[_VT]: ... - def items(self) -> CommentedMapItemsView[_KT, _VT]: ... + def keys(self) -> CommentedMapKeysView[_KT]: ... # type: ignore[override] + def values(self) -> CommentedMapValuesView[_VT]: ... # type: ignore[override] + def items(self) -> CommentedMapItemsView[_KT, _VT]: ... # type: ignore[override] @property def merge(self) -> list[tuple[int, Self]]: ... def add_referent(self, cm: Self) -> None: ... @@ -146,18 +147,15 @@ class CommentedMap(ordereddict[_KT, _VT], CommentedBase): def update_key_value(self, key: _KT) -> None: ... def __deepcopy__(self, memo: dict[int, Any]) -> Self: ... -@classmethod -def raise_immutable(cls, *args, **kwargs) -> NoReturn: ... - class CommentedKeyMap(CommentedBase, Mapping[_KT, _VT]): - __init__ = ordereddict[_KT, _VT].__init__ - __delitem__ = raise_immutable - __setitem__ = raise_immutable - clear = raise_immutable - pop = raise_immutable - popitem = raise_immutable - setdefault = raise_immutable - update = raise_immutable + __init__ = ordereddict[_KT, _VT].__init__ # type: ignore[assignment] + def __delitem__(self, *args, **kwargs) -> NoReturn: ... + def __setitem__(self, *args, **kwargs) -> NoReturn: ... + def clear(self, *args, **kwargs) -> NoReturn: ... + def pop(self, *args, **kwargs) -> NoReturn: ... + def popitem(self, *args, **kwargs) -> NoReturn: ... + def setdefault(self, *args, **kwargs) -> NoReturn: ... + def update(self, *args, **kwargs) -> NoReturn: ... def __getitem__(self, index: _KT) -> _VT: ... def __iter__(self) -> Iterator[_KT]: ... def __len__(self) -> int: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi index b07c909c612d..81084de1213b 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/compat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/compat.pyi @@ -2,8 +2,8 @@ from _typeshed import SupportsRead, SupportsWrite from abc import ABCMeta, abstractmethod from collections import OrderedDict from collections.abc import Iterable, MutableSequence -from typing import IO, Any, Final, Self, TypeVar, overload -from typing_extensions import TypeAlias +from typing import IO, Any, Final, TypeVar, overload +from typing_extensions import Self, TypeAlias from .docinfo import Version diff --git a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi index eba3c15519de..bb76fa4a91a0 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi @@ -1,7 +1,8 @@ from collections.abc import Generator, Iterable, Iterator, Mapping, Set as AbstractSet from datetime import date, datetime from types import ModuleType -from typing import Any, ClassVar, Final, NoReturn, Protocol, Self, TypeVar, overload +from typing import Any, ClassVar, Final, NoReturn, Protocol, TypeVar, overload +from typing_extensions import Self from . import util from .comments import CommentedMap, CommentedOrderedMap, CommentedSeq, CommentedSet, TaggedScalar @@ -74,7 +75,7 @@ class BaseConstructor: class SafeConstructor(BaseConstructor): def construct_scalar(self, node: ScalarNode) -> str: ... - def flatten_mapping(self, node: MappingNode) -> None: ... + def flatten_mapping(self, node: MappingNode) -> list[Any] | None: ... def construct_mapping(self, node: MappingNode, deep: bool = False) -> dict[Any, Any]: ... def construct_yaml_null(self, node: ScalarNode) -> None: ... bool_values: Final[dict[str, bool]] @@ -129,10 +130,10 @@ class RoundTripConstructor(SafeConstructor): def construct_scalar(self, node: ScalarNode) -> str: ... def construct_yaml_int(self, node: ScalarNode) -> int: ... def construct_yaml_float(self, node: ScalarNode) -> float | ScalarFloat: ... - def construct_yaml_str(self, node: ScalarNode) -> str | TaggedScalar: ... + def construct_yaml_str(self, node: ScalarNode) -> str | TaggedScalar: ... # type: ignore[override] def construct_rt_sequence(self, node: SequenceNode, seqtyp: CommentedSeq[_T], deep: bool = False) -> list[_T]: ... def flatten_mapping(self, node: MappingNode) -> list[tuple[int, CommentedMap[Any, Any]]]: ... - def construct_mapping(self, node: MappingNode, maptyp: CommentedMap[Any, Any], deep: bool = False) -> None: ... + def construct_mapping(self, node: MappingNode, maptyp: CommentedMap[Any, Any], deep: bool = False) -> None: ... # type: ignore[override] def construct_setting(self, node: MappingNode, typ: CommentedSet[Any], deep: bool = False) -> None: ... def construct_yaml_seq(self, node: SequenceNode) -> Iterator[CommentedSeq[Any]]: ... def construct_yaml_map(self, node: MappingNode) -> Iterator[CommentedMap[Any, Any]]: ... @@ -141,7 +142,7 @@ class RoundTripConstructor(SafeConstructor): ) -> None: ... def construct_yaml_object(self, node: MappingNode, cls: type[_T]) -> Iterator[_T]: ... def construct_yaml_omap(self, node: SequenceNode) -> Iterator[CommentedOrderedMap[Any, Any]]: ... - def construct_yaml_set(self, node: MappingNode) -> Iterator[CommentedSet[Any]]: ... + def construct_yaml_set(self, node: MappingNode) -> Iterator[CommentedSet[Any]]: ... # type: ignore[override] @overload def construct_unknown(self, node: ScalarNode) -> Iterator[TaggedScalar]: ... @overload diff --git a/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi b/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi index 6c054f47d1b5..7a87a03539d7 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/docinfo.pyi @@ -4,7 +4,7 @@ class Version: def major(self) -> int: ... @property def minor(self) -> int: ... - def __eq__(self, v: Version) -> bool: ... + def __eq__(self, v: object) -> bool: ... def __lt__(self, v: Version) -> bool: ... def __le__(self, v: Version) -> bool: ... def __gt__(self, v: Version) -> bool: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi index d99122171235..a2400c08177f 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/dumper.pyi @@ -1,5 +1,5 @@ from _typeshed import Unused -from typing import TypeAlias +from typing_extensions import TypeAlias from .compat import VersionType, _WriteStream from .emitter import Emitter, _Inf, _LineBreak diff --git a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi index 688a10d7e969..13e2f767cf5d 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/emitter.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import Final, Literal, TypeAlias +from typing import Final, Literal +from typing_extensions import TypeAlias from .compat import _WriteStream from .dumper import _Dumper diff --git a/stubs/ruamel.yaml/ruamel/yaml/error.pyi b/stubs/ruamel.yaml/ruamel/yaml/error.pyi index 1e4e03939f09..ac5e4a7d8c3f 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/error.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/error.pyi @@ -1,4 +1,5 @@ -from typing import ClassVar, Self, TypeAlias +from typing import ClassVar +from typing_extensions import Self, TypeAlias from _ruamel_yaml import Mark @@ -24,8 +25,8 @@ class StreamMark: line: int column: int def __init__(self, name: str | None, index: int, line: int, column: int) -> None: ... - def __eq__(self, other: Self, /) -> bool: ... - def __ne__(self, other: Self, /) -> bool: ... + def __eq__(self, other: Self, /) -> bool: ... # type: ignore[override] + def __ne__(self, other: Self, /) -> bool: ... # type: ignore[override] class FileMark(StreamMark): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/events.pyi b/stubs/ruamel.yaml/ruamel/yaml/events.pyi index 96adbfcb3737..89a3076d371c 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/events.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/events.pyi @@ -1,5 +1,5 @@ from _typeshed import sentinel -from typing import ClassVar, Final, Literal +from typing import ClassVar, Literal from .error import _Mark from .tag import Tag, _TagHandleToPrefix @@ -51,7 +51,7 @@ class CollectionEndEvent(Event): ... # Implementations. class StreamStartEvent(Event): - crepr: Final = "+STR" + crepr: ClassVar[Literal["+STR"]] encoding: str | None def __init__( self, @@ -62,10 +62,10 @@ class StreamStartEvent(Event): ) -> None: ... class StreamEndEvent(Event): - crepr: Final = "-STR" + crepr: ClassVar[Literal["-STR"]] class DocumentStartEvent(Event): - crepr: Final = "+DOC" + crepr: ClassVar[Literal["+DOC"]] explicit: bool | None version: _VersionTuple | None tags: _TagHandleToPrefix | None @@ -81,7 +81,7 @@ class DocumentStartEvent(Event): def compact_repr(self) -> str: ... class DocumentEndEvent(Event): - crepr: Final = "-DOC" + crepr: ClassVar[Literal["-DOC"]] explicit: bool | None def __init__( self, @@ -93,7 +93,7 @@ class DocumentEndEvent(Event): def compact_repr(self) -> str: ... class AliasEvent(NodeEvent): - crepr: Final = "=ALI" + crepr: ClassVar[Literal["=ALI"]] style: Literal["?"] | None def __init__( self, @@ -106,7 +106,7 @@ class AliasEvent(NodeEvent): def compact_repr(self) -> str: ... class ScalarEvent(NodeEvent): - crepr: Final = "=VAL" + crepr: ClassVar[Literal["=VAL"]] ctag: Tag | None implicit: tuple[bool, bool] value: str @@ -129,15 +129,15 @@ class ScalarEvent(NodeEvent): def compact_repr(self) -> str: ... class SequenceStartEvent(CollectionStartEvent): - crepr: Final = "+SEQ" + crepr: ClassVar[Literal["+SEQ"]] def compact_repr(self) -> str: ... class SequenceEndEvent(CollectionEndEvent): - crepr: Final = "-SEQ" + crepr: ClassVar[Literal["-SEQ"]] class MappingStartEvent(CollectionStartEvent): - crepr: Final = "+MAP" + crepr: ClassVar[Literal["+MAP"]] def compact_repr(self) -> str: ... class MappingEndEvent(CollectionEndEvent): - crepr: Final = "-MAP" + crepr: ClassVar[Literal["-MAP"]] diff --git a/stubs/ruamel.yaml/ruamel/yaml/loader.pyi b/stubs/ruamel.yaml/ruamel/yaml/loader.pyi index 8de2c711fe78..7aa09cc47aa5 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/loader.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/loader.pyi @@ -1,5 +1,5 @@ from _typeshed import Unused -from typing import TypeAlias +from typing_extensions import TypeAlias from .compat import VersionType, _ReadStream from .composer import Composer @@ -13,18 +13,18 @@ __all__ = ["BaseLoader", "SafeLoader", "Loader", "RoundTripLoader"] _Loader: TypeAlias = Loader | BaseLoader | SafeLoader | RoundTripLoader # noqa: Y047 -class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, VersionedResolver): +class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, VersionedResolver): # type: ignore[misc] comment_handling: int | None def __init__(self, stream: _ReadStream, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... -class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, VersionedResolver): +class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, VersionedResolver): # type: ignore[misc] comment_handling: int | None def __init__(self, stream: _ReadStream, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... -class Loader(Reader, Scanner, Parser, Composer, Constructor, VersionedResolver): +class Loader(Reader, Scanner, Parser, Composer, Constructor, VersionedResolver): # type: ignore[misc] comment_handling: int | None def __init__(self, stream: _ReadStream, version: VersionType | None = None, preserve_quotes: Unused = None) -> None: ... -class RoundTripLoader(Reader, RoundTripScanner, RoundTripParser, Composer, RoundTripConstructor, VersionedResolver): +class RoundTripLoader(Reader, RoundTripScanner, RoundTripParser, Composer, RoundTripConstructor, VersionedResolver): # type: ignore[misc] comment_handling: int | None def __init__(self, stream: _ReadStream, version: VersionType | None = None, preserve_quotes: bool | None = None) -> None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/main.pyi b/stubs/ruamel.yaml/ruamel/yaml/main.pyi index 5740c41639b2..8b00f4445120 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/main.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/main.pyi @@ -4,7 +4,7 @@ from pathlib import Path from re import Pattern from types import ModuleType, TracebackType from typing import Any, ClassVar, Final, Literal, NoReturn, Protocol, TypeVar, overload -from typing_extensions import Never, Self, TypeAlias, deprecated +from typing_extensions import Self, TypeAlias, deprecated from _ruamel_yaml import CEmitter, CParser @@ -31,6 +31,14 @@ _Representer = TypeVar("_Representer", bound=BaseRepresenter) _YAMLType: TypeAlias = str | Literal["rt", "safe", "unsafe", "full", "base"] # noqa: Y051 +# type aliases to avoid name clashes and make mypy happy +_Reader: TypeAlias = Reader +_Scanner: TypeAlias = Scanner +_Parser: TypeAlias = Parser +_Composer: TypeAlias = Composer +_Emitter: TypeAlias = Emitter +_Serializer: TypeAlias = Serializer + class YAML: typ: list[_YAMLType] pure: Final[bool] @@ -129,21 +137,21 @@ class YAML: plug_ins: list[str] | None = None, ) -> None: ... @property - def reader(self) -> Reader: ... + def reader(self) -> _Reader: ... @property - def scanner(self) -> Scanner: ... + def scanner(self) -> _Scanner: ... @property - def parser(self) -> Parser | CParser | None: ... + def parser(self) -> _Parser | CParser | None: ... @property - def composer(self) -> Composer: ... + def composer(self) -> _Composer: ... @property - def constructor(self) -> Constructor: ... + def constructor(self) -> BaseConstructor: ... @property def resolver(self) -> BaseResolver: ... @property - def emitter(self) -> Emitter | CEmitter | None: ... + def emitter(self) -> _Emitter | CEmitter | None: ... @property - def serializer(self) -> Serializer: ... + def serializer(self) -> _Serializer: ... @property def representer(self) -> BaseRepresenter: ... def scan(self, stream: _ReadStream) -> Iterator[Token]: ... @@ -152,7 +160,7 @@ class YAML: def compose_all(self, stream: _ReadStream) -> Iterator[Node]: ... def load(self, stream: Path | _ReadStream) -> Any: ... def load_all(self, stream: Path | _ReadStream) -> Iterator[Any]: ... - def get_constructor_parser(self, stream: _ReadStream) -> tuple[BaseConstructor, Parser | CParser]: ... + def get_constructor_parser(self, stream: _ReadStream) -> tuple[BaseConstructor, _Parser | CParser]: ... def emit(self, events: Iterable[Event], stream: _WriteStream) -> None: ... def serialize(self, node: Node, stream: _WriteStream) -> None: ... def serialize_all(self, nodes: Iterable[Node], stream: _WriteStream) -> None: ... @@ -165,7 +173,7 @@ class YAML: ) -> None: ... def get_serializer_representer_emitter( self, stream: _WriteStream, tlca: int | None - ) -> tuple[Serializer, BaseRepresenter, Emitter | CEmitter]: ... + ) -> tuple[_Serializer, BaseRepresenter, _Emitter | CEmitter]: ... @overload def map(self) -> dict[Any, Any]: ... @overload @@ -200,7 +208,6 @@ class _IndentSetter(Protocol): def __call__(self, mapping: int | None = None, sequence: int | None = None, offset: int | None = None) -> None: ... class _RoundTripYAML(YAML): - typ: list[Literal["rt"]] Representer: type[RoundTripRepresenter] Constructor: type[RoundTripConstructor] Scanner: type[RoundTripScanner] @@ -217,9 +224,6 @@ class _RoundTripYAML(YAML): def __enter__(self) -> _RoundTripYAMLContext: ... class _FullYAML(YAML): - typ: list[Literal["full"]] - Composer: None - Constructor: Never @property def composer(self) -> NoReturn: ... @property @@ -240,7 +244,7 @@ class _FullYAML(YAML): def __enter__(self) -> _FullYAMLContext: ... class _YAMLContext(YAML): - def dump(self, data: Any, stream: Unused = None, *, transform: None = None) -> None: ... + def dump(self, data: Any, stream: Unused = None, *, transform: None = None) -> None: ... # type: ignore[override] def dump_all(self, documents, stream=None, *, transform=None) -> NoReturn: ... class _RoundTripYAMLContext(_YAMLContext, _RoundTripYAML): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi index df60a22cd83b..00eca32eff0b 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi @@ -1,4 +1,4 @@ -from typing import Any, Final, Generic, Literal, TypeVar +from typing import Any, ClassVar, Generic, Literal, TypeVar from typing_extensions import TypeAlias from .anchor import Anchor @@ -34,7 +34,7 @@ class Node: def dump(self, *, indent: int = 0) -> None: ... class ScalarNode(Node): - id: Final = "scalar" + id: ClassVar[Literal["scalar"]] value: str style: _ScalarNodeStyle | None def __init__( @@ -69,8 +69,8 @@ class _SequenceNode(_CollectionNode[Node]): ... class _MappingNode(_CollectionNode[tuple[Node, Node]]): ... class SequenceNode(_SequenceNode, CollectionNode): - id: Final = "sequence" + id: ClassVar[Literal["sequence"]] class MappingNode(_MappingNode, CollectionNode): - id: Final = "mapping" + id: ClassVar[Literal["mapping"]] merge: list[tuple[Node, Node]] | None diff --git a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi index 676bc0722bd6..90ebf2c889cc 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi @@ -3,7 +3,8 @@ from collections import OrderedDict from collections.abc import Collection, Mapping, Set as AbstractSet from datetime import date, datetime from types import ModuleType -from typing import Any, ClassVar, Final, NoReturn, Protocol, Self, TypeVar +from typing import Any, ClassVar, Final, NoReturn, Protocol, TypeVar +from typing_extensions import Self from .anchor import Anchor from .comments import CommentedMap, CommentedSeq, CommentedSet, TaggedScalar @@ -138,10 +139,10 @@ class RoundTripRepresenter(SafeRepresenter): def represent_omap( self, tag: Tag | str | None, omap: OrderedDict[Any, Any], flow_style: bool | None = None ) -> SequenceNode: ... - def represent_set(self, setting: CommentedSet[Any]) -> MappingNode: ... - def represent_dict(self, data: CommentedMap[Any, Any]) -> MappingNode: ... - def represent_list(self, data: CommentedSeq[Any]) -> SequenceNode: ... - def represent_datetime(self, data: TimeStamp) -> ScalarNode: ... + def represent_set(self, setting: CommentedSet[Any]) -> MappingNode: ... # type: ignore[override] + def represent_dict(self, data: CommentedMap[Any, Any]) -> MappingNode: ... # type: ignore[override] + def represent_list(self, data: CommentedSeq[Any]) -> SequenceNode: ... # type: ignore[override] + def represent_datetime(self, data: TimeStamp) -> ScalarNode: ... # type: ignore[override] def represent_tagged_scalar(self, data: TaggedScalar) -> ScalarNode: ... def represent_scalar_bool(self, data: ScalarBoolean) -> ScalarNode: ... def represent_yaml_object( diff --git a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi index 46b0780c9b37..725aeea87ef1 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/resolver.pyi @@ -1,6 +1,7 @@ from collections.abc import Iterable from re import Pattern -from typing import Any, Final, TypeAlias, overload +from typing import Any, Final, overload +from typing_extensions import TypeAlias from .compat import VersionType from .dumper import _Dumper @@ -49,7 +50,7 @@ class BaseResolver: @overload def resolve(self, kind: type[MappingNode], value: list[tuple[Node, Node]] | None, implicit: bool) -> Tag: ... @property - def processing_version(self) -> None: ... + def processing_version(self) -> _VersionTuple | None: ... class Resolver(BaseResolver): ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi index 54f117988317..7f99a221b08f 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarbool.pyi @@ -1,4 +1,4 @@ -from typing import Self +from typing_extensions import Self from .anchor import Anchor diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi index 382e08d5605e..9b2ef7b50590 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarfloat.pyi @@ -1,5 +1,6 @@ from _typeshed import SupportsWrite -from typing import Literal, Self +from typing import Literal +from typing_extensions import Self from .anchor import Anchor from .scalarint import _Underscore @@ -34,7 +35,7 @@ class ScalarFloat(float): def __iadd__(self, a: float, /) -> float: ... # noqa: Y034 def __ifloordiv__(self, a: float, /) -> float: ... # noqa: Y034 def __imul__(self, a: float, /) -> float: ... # noqa: Y034 - def __ipow__(self, a: float, /) -> float: ... # noqa: Y034 + def __ipow__(self, a: float, /) -> float: ... # type: ignore[override, misc] # noqa: Y034 def __isub__(self, a: float, /) -> float: ... # noqa: Y034 @property def anchor(self) -> Anchor: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi index c930b121de83..019f4bb51c09 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarint.pyi @@ -1,5 +1,4 @@ -from typing import Self -from typing_extensions import TypeAlias +from typing_extensions import Self, TypeAlias from .anchor import Anchor @@ -16,7 +15,7 @@ class ScalarInt(int): def __iadd__(self, a: int, /) -> Self: ... def __ifloordiv__(self, a: int, /) -> Self: ... def __imul__(self, a: int, /) -> Self: ... - def __ipow__(self, a: int, /) -> Self: ... + def __ipow__(self, a: int, /) -> Self: ... # type: ignore[override, misc] def __isub__(self, a: int, /) -> Self: ... @property def anchor(self) -> Anchor: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi index e5e1237c0a23..024eb0bfee64 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Mapping -from typing import Any, Final, Self, SupportsIndex +from typing import Any, Final, SupportsIndex +from typing_extensions import Self from .anchor import Anchor from .comments import CommentedMap, CommentedSeq diff --git a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi index d5bbade1c8dd..63a541c6933d 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scanner.pyi @@ -106,7 +106,7 @@ class Scanner: def check_key(self) -> bool: ... def check_value(self) -> bool: ... def check_plain(self) -> bool: ... - def scan_to_next_token(self) -> None: ... + def scan_to_next_token(self) -> tuple[str, StreamMark, StreamMark] | None: ... def scan_directive(self) -> DirectiveToken: ... def scan_directive_name(self, start_mark: StreamMark) -> str: ... def scan_yaml_directive_value(self, start_mark: StreamMark) -> _VersionTuple: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/tag.pyi b/stubs/ruamel.yaml/ruamel/yaml/tag.pyi index b629bfac1b0c..6f86910b6850 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/tag.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/tag.pyi @@ -1,4 +1,5 @@ -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias _TagHandleToPrefix: TypeAlias = dict[str, str] @@ -13,7 +14,7 @@ class Tag: self, *, handle: str | None = None, suffix: str | None = None, handles: _TagHandleToPrefix | None = None ) -> None: ... def __hash__(self) -> int: ... - def __eq__(self, other: Tag | str, /) -> bool: ... + def __eq__(self, other: Tag | str, /) -> bool: ... # type: ignore[override] def startswith(self, x: str, /) -> bool: ... @property def trval(self) -> str | None: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi index b58f44edaf9c..de7d83e64e3f 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi @@ -1,5 +1,5 @@ -from typing import ClassVar, Final, Literal, Self, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, overload +from typing_extensions import Self, TypeAlias from .error import CommentMark, StreamMark, _Mark @@ -35,7 +35,7 @@ class Token: def move_new_comment(self, target: Token, *, empty: bool = False) -> Self | None: ... class DirectiveToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] name: str value: _VersionTuple | _TagDirective | None @overload @@ -46,69 +46,69 @@ class DirectiveToken(Token): def __init__(self, name: str, value: None, start_mark: _Mark, end_mark: _Mark) -> None: ... class DocumentStartToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] class DocumentEndToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] class StreamStartToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] encoding: str | None def __init__(self, start_mark: _Mark, end_mark: _Mark, encoding: str | None = None) -> None: ... class StreamEndToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] class BlockSequenceStartToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] class BlockMappingStartToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] class BlockEndToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] class FlowSequenceStartToken(Token): - id: Final = "[" + id: ClassVar[Literal["["]] class FlowMappingStartToken(Token): - id: Final = "{" + id: ClassVar[Literal["{"]] class FlowSequenceEndToken(Token): - id: Final = "]" + id: ClassVar[Literal["]"]] class FlowMappingEndToken(Token): - id: Final = "}" + id: ClassVar[Literal["}"]] class KeyToken(Token): - id: Final = "?" + id: ClassVar[Literal["?"]] class ValueToken(Token): - id: Final = ":" + id: ClassVar[Literal[":"]] class BlockEntryToken(Token): - id: Final = "-" + id: ClassVar[Literal["-"]] class FlowEntryToken(Token): - id: Final = "," + id: ClassVar[Literal[","]] class AliasToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] value: str def __init__(self, value: str, start_mark: _Mark, end_mark: _Mark) -> None: ... class AnchorToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] value: str def __init__(self, value: str, start_mark: _Mark, end_mark: _Mark) -> None: ... class TagToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] value: tuple[str | None, str] def __init__(self, value: tuple[str | None, str], start_mark: _Mark, end_mark: _Mark) -> None: ... class ScalarToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] value: str plain: bool style: _ScalarStyle | None @@ -117,7 +117,7 @@ class ScalarToken(Token): ) -> None: ... class CommentToken(Token): - id: Final = "" + id: ClassVar[Literal[""]] pre_done: bool def __init__( self, @@ -131,5 +131,5 @@ class CommentToken(Token): @value.setter def value(self, val: str, /) -> None: ... def reset(self) -> None: ... - def __eq__(self, other: CommentToken, /) -> bool: ... - def __ne__(self, other: CommentToken, /) -> bool: ... + def __eq__(self, other: CommentToken, /) -> bool: ... # type: ignore[override] + def __ne__(self, other: CommentToken, /) -> bool: ... # type: ignore[override] From a758f2c9d8b6c73d0381336860b47ba78d59f40d Mon Sep 17 00:00:00 2001 From: stevenlele Date: Sun, 15 Sep 2024 20:31:53 +0000 Subject: [PATCH 10/15] Fix some errors reported by mypy_primer --- stubs/ruamel.yaml/ruamel/yaml/__init__.pyi | 1 + stubs/ruamel.yaml/ruamel/yaml/representer.pyi | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi b/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi index efcc4377c1f2..cda76b6fa666 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/__init__.pyi @@ -2,6 +2,7 @@ from .comments import CommentedMap as CommentedMap, CommentedSeq as CommentedSeq from .constructor import * from .cyaml import * from .dumper import * +from .error import YAMLError as YAMLError from .events import * from .loader import * from .main import * diff --git a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi index 90ebf2c889cc..cb0fcaf589df 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi @@ -7,7 +7,7 @@ from typing import Any, ClassVar, Final, NoReturn, Protocol, TypeVar from typing_extensions import Self from .anchor import Anchor -from .comments import CommentedMap, CommentedSeq, CommentedSet, TaggedScalar +from .comments import CommentedSet, TaggedScalar from .dumper import _Dumper from .error import YAMLError from .main import YAML @@ -140,8 +140,8 @@ class RoundTripRepresenter(SafeRepresenter): self, tag: Tag | str | None, omap: OrderedDict[Any, Any], flow_style: bool | None = None ) -> SequenceNode: ... def represent_set(self, setting: CommentedSet[Any]) -> MappingNode: ... # type: ignore[override] - def represent_dict(self, data: CommentedMap[Any, Any]) -> MappingNode: ... # type: ignore[override] - def represent_list(self, data: CommentedSeq[Any]) -> SequenceNode: ... # type: ignore[override] + def represent_dict(self, data: Mapping[Any, Any]) -> MappingNode: ... # type: ignore[override] + def represent_list(self, data: Collection[Any]) -> SequenceNode: ... # type: ignore[override] def represent_datetime(self, data: TimeStamp) -> ScalarNode: ... # type: ignore[override] def represent_tagged_scalar(self, data: TaggedScalar) -> ScalarNode: ... def represent_scalar_bool(self, data: ScalarBoolean) -> ScalarNode: ... From e29899ab76fb1e26b12a59ed2c192d72f9b2a2a7 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Sun, 15 Sep 2024 21:26:15 +0000 Subject: [PATCH 11/15] Attempt to fix pytype errors --- stubs/ruamel.yaml/METADATA.toml | 3 ++ stubs/ruamel.yaml/ruamel/yaml/comments.pyi | 2 +- stubs/ruamel.yaml/ruamel/yaml/constructor.pyi | 4 +- stubs/ruamel.yaml/ruamel/yaml/nodes.pyi | 42 +++++++++++++------ tests/pytype_exclude_list.txt | 4 ++ 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/stubs/ruamel.yaml/METADATA.toml b/stubs/ruamel.yaml/METADATA.toml index 25f7cf3bc5df..fe5da0015c1e 100644 --- a/stubs/ruamel.yaml/METADATA.toml +++ b/stubs/ruamel.yaml/METADATA.toml @@ -1,2 +1,5 @@ version = "0.18.*" upstream_repository = "https://sourceforge.net/p/ruamel-yaml/code/" + +[tool.stubtest] +stubtest_requirements = ["configobj"] diff --git a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi index 0c29ea884b18..843692522fd7 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/comments.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/comments.pyi @@ -148,7 +148,7 @@ class CommentedMap(ordereddict[_KT, _VT], CommentedBase): def __deepcopy__(self, memo: dict[int, Any]) -> Self: ... class CommentedKeyMap(CommentedBase, Mapping[_KT, _VT]): - __init__ = ordereddict[_KT, _VT].__init__ # type: ignore[assignment] + def __init__(self, *args, **kwargs) -> None: ... def __delitem__(self, *args, **kwargs) -> NoReturn: ... def __setitem__(self, *args, **kwargs) -> NoReturn: ... def clear(self, *args, **kwargs) -> NoReturn: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi index bb76fa4a91a0..1abc99aa3740 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/constructor.pyi @@ -1,10 +1,10 @@ from collections.abc import Generator, Iterable, Iterator, Mapping, Set as AbstractSet from datetime import date, datetime +from re import Pattern from types import ModuleType from typing import Any, ClassVar, Final, NoReturn, Protocol, TypeVar, overload from typing_extensions import Self -from . import util from .comments import CommentedMap, CommentedOrderedMap, CommentedSeq, CommentedSet, TaggedScalar from .compat import ordereddict from .composer import Composer @@ -85,7 +85,7 @@ class SafeConstructor(BaseConstructor): nan_value: Final[float] def construct_yaml_float(self, node: ScalarNode) -> float: ... def construct_yaml_binary(self, node: ScalarNode) -> bytes: ... - timestamp_regexp: Final = util.timestamp_regexp + timestamp_regexp: Final[Pattern[str]] def construct_yaml_timestamp(self, node: ScalarNode, values: dict[str, str | None] | None = None) -> date | datetime: ... def construct_yaml_omap(self, node: SequenceNode) -> Iterator[ordereddict[Any, Any]]: ... def construct_yaml_pairs(self, node: SequenceNode) -> Iterator[list[tuple[Any, Any]]]: ... diff --git a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi index 00eca32eff0b..3553bc976391 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Generic, Literal, TypeVar +from typing import Any, ClassVar, Literal from typing_extensions import TypeAlias from .anchor import Anchor @@ -6,8 +6,6 @@ from .error import _Mark from .tag import Tag from .tokens import _CommentGroup, _ScalarStyle -_T = TypeVar("_T") - _ScalarNodeStyle: TypeAlias = Literal["?", "-"] | _ScalarStyle class Node: @@ -49,13 +47,13 @@ class ScalarNode(Node): anchor: Anchor | str | None = None, ) -> None: ... -class _CollectionNode(Generic[_T]): - value: list[_T] +class CollectionNode(Node): + value: list[Any] flow_style: bool | None def __init__( self, tag: Tag | str | None, - value: list[_T], + value: list[Any], start_mark: _Mark | None = None, end_mark: _Mark | None = None, *, @@ -64,13 +62,33 @@ class _CollectionNode(Generic[_T]): anchor: Anchor | str | None = None, ) -> None: ... -class CollectionNode(_CollectionNode[Any], Node): ... -class _SequenceNode(_CollectionNode[Node]): ... -class _MappingNode(_CollectionNode[tuple[Node, Node]]): ... - -class SequenceNode(_SequenceNode, CollectionNode): +class SequenceNode(CollectionNode): id: ClassVar[Literal["sequence"]] + value: list[Node] + def __init__( + self, + tag: Tag | str | None, + value: list[Node], + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + *, + flow_style: bool | None = None, + comment: _CommentGroup | None = None, + anchor: Anchor | str | None = None, + ) -> None: ... -class MappingNode(_MappingNode, CollectionNode): +class MappingNode(CollectionNode): id: ClassVar[Literal["mapping"]] + value: list[tuple[Node, Node]] merge: list[tuple[Node, Node]] | None + def __init__( + self, + tag: Tag | str | None, + value: list[tuple[Node, Node]], + start_mark: _Mark | None = None, + end_mark: _Mark | None = None, + *, + flow_style: bool | None = None, + comment: _CommentGroup | None = None, + anchor: Anchor | str | None = None, + ) -> None: ... diff --git a/tests/pytype_exclude_list.txt b/tests/pytype_exclude_list.txt index 0355bc94076e..8e967f45fe40 100644 --- a/tests/pytype_exclude_list.txt +++ b/tests/pytype_exclude_list.txt @@ -18,3 +18,7 @@ stubs/openpyxl/openpyxl/descriptors/nested.pyi # matplotlib not installed during tests stubs/shapely/shapely/plotting.pyi + +# configobj not installed during tests +stubs/ruamel.yaml/ruamel/yaml/configobjwalker.pyi +stubs/ruamel.yaml/ruamel/yaml/util.pyi From 3ea806f181427d95667c6ae3d2405a5754f36b19 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Sun, 15 Sep 2024 21:33:08 +0000 Subject: [PATCH 12/15] Remove debug variables to make pytype happy --- stubs/ruamel.yaml/ruamel/yaml/events.pyi | 2 -- stubs/ruamel.yaml/ruamel/yaml/tokens.pyi | 2 -- 2 files changed, 4 deletions(-) diff --git a/stubs/ruamel.yaml/ruamel/yaml/events.pyi b/stubs/ruamel.yaml/ruamel/yaml/events.pyi index 89a3076d371c..db8f1000ffb6 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/events.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/events.pyi @@ -5,8 +5,6 @@ from .error import _Mark from .tag import Tag, _TagHandleToPrefix from .tokens import _CommentGroup, _ScalarStyle, _VersionTuple -SHOW_LINES: bool - class Event: crepr: ClassVar[str] start_mark: _Mark | None diff --git a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi index de7d83e64e3f..fd57b768bc92 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/tokens.pyi @@ -12,8 +12,6 @@ _FlowScalarStyle: TypeAlias = Literal['"', "'"] _BlockScalarStyle: TypeAlias = Literal["|", ">"] _ScalarStyle: TypeAlias = _FlowScalarStyle | _BlockScalarStyle | Literal[""] -SHOW_LINES: bool - class Token: id: ClassVar[str] start_mark: _Mark From 1f10574d189b7b3ab56fc59c77a96741e217e852 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Sun, 15 Sep 2024 22:17:32 +0000 Subject: [PATCH 13/15] Minor fixes --- stubs/ruamel.yaml/ruamel/yaml/main.pyi | 8 ++++---- stubs/ruamel.yaml/ruamel/yaml/nodes.pyi | 1 + stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/stubs/ruamel.yaml/ruamel/yaml/main.pyi b/stubs/ruamel.yaml/ruamel/yaml/main.pyi index 8b00f4445120..6657ca089ee4 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/main.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/main.pyi @@ -19,7 +19,7 @@ from .nodes import Node from .parser import Parser, RoundTripParser from .reader import Reader from .representer import BaseRepresenter, Representer, RoundTripRepresenter, _RepresenterFunction -from .resolver import BaseResolver, _First, _TagStr +from .resolver import BaseResolver from .scanner import RoundTripScanner, Scanner from .serializer import Serializer from .tag import Tag, _TagHandleToPrefix @@ -305,15 +305,15 @@ def safe_dump(*args, **kwargs) -> NoReturn: ... @deprecated("Use YAML().dump() instead") def round_trip_dump(*args, **kwargs) -> NoReturn: ... def add_implicit_resolver( - tag: _TagStr, + tag: str, regexp: Pattern[str], - first: list[_First] | None = None, + first: list[str] | None = None, Loader: type[BaseResolver] | None = None, Dumper: type[BaseResolver] | None = None, resolver: type[BaseResolver] = ..., ) -> None: ... def add_path_resolver( - tag: _TagStr, + tag: str, path: Iterable[Any], kind: type | None = None, Loader: type[BaseResolver] | None = None, diff --git a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi index 3553bc976391..524ce7218565 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/nodes.pyi @@ -9,6 +9,7 @@ from .tokens import _CommentGroup, _ScalarStyle _ScalarNodeStyle: TypeAlias = Literal["?", "-"] | _ScalarStyle class Node: + id: ClassVar[str] ctag: Tag value: Any start_mark: _Mark | None diff --git a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi index 024eb0bfee64..09a331ca0f58 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/scalarstring.pyi @@ -4,7 +4,7 @@ from typing_extensions import Self from .anchor import Anchor from .comments import CommentedMap, CommentedSeq -from .nodes import _ScalarNodeStyle +from .tokens import _ScalarStyle __all__ = [ "ScalarString", @@ -25,28 +25,28 @@ class ScalarString(str): def yaml_set_anchor(self, value: str, /, *, always_dump: bool = False) -> None: ... class LiteralScalarString(ScalarString): - style: Final[_ScalarNodeStyle] = "|" + style: Final[_ScalarStyle] = "|" comment: str def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... PreservedScalarString = LiteralScalarString class FoldedScalarString(ScalarString): - style: Final[_ScalarNodeStyle] = ">" + style: Final[_ScalarStyle] = ">" fold_pos: list[int] comment: str def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... class SingleQuotedScalarString(ScalarString): - style: Final[_ScalarNodeStyle] = "'" + style: Final[_ScalarStyle] = "'" def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... class DoubleQuotedScalarString(ScalarString): - style: Final[_ScalarNodeStyle] = '"' + style: Final[_ScalarStyle] = '"' def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... class PlainScalarString(ScalarString): - style: Final[_ScalarNodeStyle] = "" + style: Final[_ScalarStyle] = "" def __new__(cls, value: str, /, *, anchor: str | None = None) -> Self: ... def preserve_literal(s: str, /) -> str: ... From bab20d81a8585266c39081b169f5180786afb0e0 Mon Sep 17 00:00:00 2001 From: stevenlele Date: Mon, 16 Sep 2024 17:54:33 +0000 Subject: [PATCH 14/15] Disable stubtest --- stubs/ruamel.yaml/METADATA.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/ruamel.yaml/METADATA.toml b/stubs/ruamel.yaml/METADATA.toml index fe5da0015c1e..6bd5f97bb141 100644 --- a/stubs/ruamel.yaml/METADATA.toml +++ b/stubs/ruamel.yaml/METADATA.toml @@ -2,4 +2,5 @@ version = "0.18.*" upstream_repository = "https://sourceforge.net/p/ruamel-yaml/code/" [tool.stubtest] +skip = true # mypy parse errors in upstream package stubtest_requirements = ["configobj"] From b24c3c50922dd6fc186b99c345c5d31be4e81784 Mon Sep 17 00:00:00 2001 From: stevenlele <15964380+stevenlele@users.noreply.github.com> Date: Tue, 17 Sep 2024 06:55:09 +0800 Subject: [PATCH 15/15] Remove unused type ignore comments --- stubs/ruamel.yaml/ruamel/yaml/representer.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi index cb0fcaf589df..8ccdeaead9b1 100644 --- a/stubs/ruamel.yaml/ruamel/yaml/representer.pyi +++ b/stubs/ruamel.yaml/ruamel/yaml/representer.pyi @@ -140,8 +140,8 @@ class RoundTripRepresenter(SafeRepresenter): self, tag: Tag | str | None, omap: OrderedDict[Any, Any], flow_style: bool | None = None ) -> SequenceNode: ... def represent_set(self, setting: CommentedSet[Any]) -> MappingNode: ... # type: ignore[override] - def represent_dict(self, data: Mapping[Any, Any]) -> MappingNode: ... # type: ignore[override] - def represent_list(self, data: Collection[Any]) -> SequenceNode: ... # type: ignore[override] + def represent_dict(self, data: Mapping[Any, Any]) -> MappingNode: ... + def represent_list(self, data: Collection[Any]) -> SequenceNode: ... def represent_datetime(self, data: TimeStamp) -> ScalarNode: ... # type: ignore[override] def represent_tagged_scalar(self, data: TaggedScalar) -> ScalarNode: ... def represent_scalar_bool(self, data: ScalarBoolean) -> ScalarNode: ...