Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e6fb59c

Browse files
authored
[PyYAML] type the whole Emitter class (#10750)
1 parent e1b6006 commit e6fb59c

1 file changed

Lines changed: 98 additions & 89 deletions

File tree

stubs/PyYAML/yaml/emitter.pyi

Lines changed: 98 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
from typing import Any, Protocol, TypeVar
1+
from collections.abc import Callable
2+
from typing import Any, NoReturn, Protocol, TypeVar
23

34
from yaml.error import YAMLError
45

6+
from .events import Event
7+
58
_T_contra = TypeVar("_T_contra", str, bytes, contravariant=True)
69

710
class _WriteStream(Protocol[_T_contra]):
@@ -26,94 +29,100 @@ class ScalarAnalysis:
2629
) -> None: ...
2730

2831
class Emitter:
29-
DEFAULT_TAG_PREFIXES: Any
32+
DEFAULT_TAG_PREFIXES: dict[str, str]
3033
stream: _WriteStream[Any]
31-
encoding: Any
32-
states: Any
33-
state: Any
34-
events: Any
35-
event: Any
36-
indents: Any
37-
indent: Any
38-
flow_level: Any
39-
root_context: Any
40-
sequence_context: Any
41-
mapping_context: Any
42-
simple_key_context: Any
43-
line: Any
44-
column: Any
45-
whitespace: Any
46-
indention: Any
47-
open_ended: Any
48-
canonical: Any
49-
allow_unicode: Any
50-
best_indent: Any
51-
best_width: Any
52-
best_line_break: Any
53-
tag_prefixes: Any
54-
prepared_anchor: Any
55-
prepared_tag: Any
56-
analysis: Any
57-
style: Any
34+
encoding: str | None
35+
states: list[Callable[[], None]]
36+
state: Callable[[], None] | None
37+
events: list[Event]
38+
event: Event | None
39+
indents: list[int | None]
40+
indent: int | None
41+
flow_level: int
42+
root_context: bool
43+
sequence_context: bool
44+
mapping_context: bool
45+
simple_key_context: bool
46+
line: int
47+
column: int
48+
whitespace: bool
49+
indention: bool
50+
open_ended: bool
51+
canonical: bool | None
52+
allow_unicode: bool | None
53+
best_indent: int
54+
best_width: int
55+
best_line_break: str
56+
tag_prefixes: dict[str, str] | None
57+
prepared_anchor: str | None
58+
prepared_tag: str | None
59+
analysis: ScalarAnalysis | None
60+
style: str | None
5861
def __init__(
59-
self, stream: _WriteStream[Any], canonical=None, indent=None, width=None, allow_unicode=None, line_break=None
62+
self,
63+
stream: _WriteStream[Any],
64+
canonical: bool | None = ...,
65+
indent: int | None = ...,
66+
width: int | None = ...,
67+
allow_unicode: bool | None = ...,
68+
line_break: str | None = ...,
6069
) -> None: ...
61-
def dispose(self): ...
62-
def emit(self, event): ...
63-
def need_more_events(self): ...
64-
def need_events(self, count): ...
65-
def increase_indent(self, flow=False, indentless=False): ...
66-
def expect_stream_start(self): ...
67-
def expect_nothing(self): ...
68-
def expect_first_document_start(self): ...
69-
def expect_document_start(self, first=False): ...
70-
def expect_document_end(self): ...
71-
def expect_document_root(self): ...
72-
def expect_node(self, root=False, sequence=False, mapping=False, simple_key=False): ...
73-
def expect_alias(self): ...
74-
def expect_scalar(self): ...
75-
def expect_flow_sequence(self): ...
76-
def expect_first_flow_sequence_item(self): ...
77-
def expect_flow_sequence_item(self): ...
78-
def expect_flow_mapping(self): ...
79-
def expect_first_flow_mapping_key(self): ...
80-
def expect_flow_mapping_key(self): ...
81-
def expect_flow_mapping_simple_value(self): ...
82-
def expect_flow_mapping_value(self): ...
83-
def expect_block_sequence(self): ...
84-
def expect_first_block_sequence_item(self): ...
85-
def expect_block_sequence_item(self, first=False): ...
86-
def expect_block_mapping(self): ...
87-
def expect_first_block_mapping_key(self): ...
88-
def expect_block_mapping_key(self, first=False): ...
89-
def expect_block_mapping_simple_value(self): ...
90-
def expect_block_mapping_value(self): ...
91-
def check_empty_sequence(self): ...
92-
def check_empty_mapping(self): ...
93-
def check_empty_document(self): ...
94-
def check_simple_key(self): ...
95-
def process_anchor(self, indicator): ...
96-
def process_tag(self): ...
97-
def choose_scalar_style(self): ...
98-
def process_scalar(self): ...
99-
def prepare_version(self, version): ...
100-
def prepare_tag_handle(self, handle): ...
101-
def prepare_tag_prefix(self, prefix): ...
102-
def prepare_tag(self, tag): ...
103-
def prepare_anchor(self, anchor): ...
104-
def analyze_scalar(self, scalar): ...
105-
def flush_stream(self): ...
106-
def write_stream_start(self): ...
107-
def write_stream_end(self): ...
108-
def write_indicator(self, indicator, need_whitespace, whitespace=False, indention=False): ...
109-
def write_indent(self): ...
110-
def write_line_break(self, data=None): ...
111-
def write_version_directive(self, version_text): ...
112-
def write_tag_directive(self, handle_text, prefix_text): ...
113-
def write_single_quoted(self, text, split=True): ...
114-
ESCAPE_REPLACEMENTS: Any
115-
def write_double_quoted(self, text, split=True): ...
116-
def determine_block_hints(self, text): ...
117-
def write_folded(self, text): ...
118-
def write_literal(self, text): ...
119-
def write_plain(self, text, split=True): ...
70+
def dispose(self) -> None: ...
71+
def emit(self, event: Event) -> None: ...
72+
def need_more_events(self) -> bool: ...
73+
def need_events(self, count: int) -> bool: ...
74+
def increase_indent(self, flow: bool = ..., indentless: bool = ...) -> None: ...
75+
def expect_stream_start(self) -> None: ...
76+
def expect_nothing(self) -> NoReturn: ...
77+
def expect_first_document_start(self) -> None: ...
78+
def expect_document_start(self, first: bool = False) -> None: ...
79+
def expect_document_end(self) -> None: ...
80+
def expect_document_root(self) -> None: ...
81+
def expect_node(self, root: bool = ..., sequence: bool = ..., mapping: bool = ..., simple_key: bool = ...) -> None: ...
82+
def expect_alias(self) -> None: ...
83+
def expect_scalar(self) -> None: ...
84+
def expect_flow_sequence(self) -> None: ...
85+
def expect_first_flow_sequence_item(self) -> None: ...
86+
def expect_flow_sequence_item(self) -> None: ...
87+
def expect_flow_mapping(self) -> None: ...
88+
def expect_first_flow_mapping_key(self) -> None: ...
89+
def expect_flow_mapping_key(self) -> None: ...
90+
def expect_flow_mapping_simple_value(self) -> None: ...
91+
def expect_flow_mapping_value(self) -> None: ...
92+
def expect_block_sequence(self) -> None: ...
93+
def expect_first_block_sequence_item(self) -> None: ...
94+
def expect_block_sequence_item(self, first: bool = ...) -> None: ...
95+
def expect_block_mapping(self) -> None: ...
96+
def expect_first_block_mapping_key(self) -> None: ...
97+
def expect_block_mapping_key(self, first: bool = ...) -> None: ...
98+
def expect_block_mapping_simple_value(self) -> None: ...
99+
def expect_block_mapping_value(self) -> None: ...
100+
def check_empty_sequence(self) -> bool: ...
101+
def check_empty_mapping(self) -> bool: ...
102+
def check_empty_document(self) -> bool: ...
103+
def check_simple_key(self) -> bool: ...
104+
def process_anchor(self, indicator: str) -> None: ...
105+
def process_tag(self) -> None: ...
106+
def choose_scalar_style(self) -> str: ...
107+
def process_scalar(self) -> None: ...
108+
def prepare_version(self, version) -> str: ...
109+
def prepare_tag_handle(self, handle: str) -> str: ...
110+
def prepare_tag_prefix(self, prefix: str) -> str: ...
111+
def prepare_tag(self, tag: str) -> str: ...
112+
def prepare_anchor(self, anchor: str) -> str: ...
113+
def analyze_scalar(self, scalar: str) -> ScalarAnalysis: ...
114+
def flush_stream(self) -> None: ...
115+
def write_stream_start(self) -> None: ...
116+
def write_stream_end(self) -> None: ...
117+
def write_indicator(self, indicator: str, need_whitespace: bool, whitespace: bool = ..., indention: bool = ...) -> None: ...
118+
def write_indent(self) -> None: ...
119+
def write_line_break(self, data: str | None = ...) -> None: ...
120+
def write_version_directive(self, version_text: str) -> None: ...
121+
def write_tag_directive(self, handle_text: str, prefix_text: str) -> None: ...
122+
def write_single_quoted(self, text: str, split: bool = ...) -> None: ...
123+
ESCAPE_REPLACEMENTS: dict[str, str]
124+
def write_double_quoted(self, text: str, split: bool = ...) -> None: ...
125+
def determine_block_hints(self, text: str) -> str: ...
126+
def write_folded(self, text: str) -> None: ...
127+
def write_literal(self, text: str) -> None: ...
128+
def write_plain(self, text: str, split: bool = ...) -> None: ...

0 commit comments

Comments
 (0)