From f385a0ef7dc629f710584840a2851e2b4704b844 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 09:36:29 +0000 Subject: [PATCH 01/20] improve type annotations in 'docutils.parsers.rst.states' --- .../docutils/docutils/parsers/rst/states.pyi | 434 +++++++++++++++++- 1 file changed, 432 insertions(+), 2 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index 1ef7be91074e..d37c1ee8c847 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -1,6 +1,436 @@ -from _typeshed import Incomplete +from collections.abc import Callable, MutableSequence, Sequence +from re import Match, Pattern +from types import ModuleType +from typing import Any +from typing_extensions import TypeAlias + +from docutils import ApplicationError, DataError, nodes +from docutils.parsers.rst import Directive, tableparser +from docutils.statemachine import StateMachine, StateMachineWS, StateWS, Stringlist +from docutils.utils import Reporter + +BasicDefinition: TypeAlias = tuple[str, str, str, list[Pattern[str]]] +DefinitionParts: TypeAlias = tuple[str, str, str, list[Pattern[str] | BasicDefinition]] +Definitiontype: TypeAlias = tuple[str, str, str, list[Pattern[str] | DefinitionParts]] + +__docformat__: str + +class MarkupError(DataError): ... +class UnknownInterpretedRoleError(DataError): ... +class InterpretedRoleNotImplementedError(DataError): ... +class ParserError(ApplicationError): ... +class MarkupMismatch(Exception): ... + +class Struct: + def __init__(self, **keywordargs) -> None: ... + +class RSTStateMachine(StateMachineWS): + language: ModuleType + match_titles: bool + memo: Struct + document: nodes.document + reporter: Reporter + node: nodes.Node + def run( + self, + input_lines: list[str] | Stringlist, + document: nodes.document, + input_offset: int = ..., + match_titles: bool = ..., + inliner: Inliner | None = ..., + ) -> None: ... + +class NestedStateMachine(StateMachineWS): + match_titles: bool + memo: Struct + document: nodes.document + reporter: Reporter + language: ModuleType + node: nodes.Node + def run( + self, input_lines: list[str] | Stringlist, input_offset: int, memo: Struct, node: nodes.Node, match_titles: bool = ... + ) -> list[Any]: ... + +class RSTState(StateWS): + nested_sm: type[StateMachine] + nested_sm_cache: list[StateMachine] + nested_sm_kwargs: dict[str, Any] + def __init__(self, state_machine: StateMachine, debug: bool = ...) -> None: ... + memo: Struct + reporter: Reporter + inliner: Inliner + document: nodes.document + parent: nodes.Node + def runtime_init(self) -> None: ... + def goto_line(self, abs_line_offset: int) -> None: ... + def no_match( + self, context, transitions: tuple[list[str], dict[str, tuple[Pattern[str], Callable, str]]] + ) -> tuple[Any, str, list]: ... + def bof(self, context) -> tuple[list, list]: ... + def nested_parse( + self, + block: Stringlist, + input_offset: int, + node: nodes.Node, + match_titles: bool = ..., + state_machine_class: type[StateMachine] | None = ..., + state_machine_kwargs: dict[str, Any] | None = ..., + ) -> int: ... + def nested_list_parse( + self, + block, + input_offset, + node, + initial_state, + blank_finish, + blank_finish_state: Any | None = ..., + extra_settings: Any = ..., + match_titles: bool = ..., + state_machine_class: Any | None = ..., + state_machine_kwargs: Any | None = ..., + ) -> tuple[int, bool]: ... + def section(self, title: str, source: str, style: str, lineno: int, messages: list[str]) -> None: ... + def check_subsection(self, source: str, style: str, lineno: int) -> int: ... + def title_inconsistent(self, sourcetext: str, lineno: int) -> nodes.system_message: ... + def new_subsection(self, title: str, lineno: int, messages: list[nodes.system_message]) -> None: ... + def paragraph(self, lines: list[str], lineno: int) -> tuple[list[nodes.Node], int]: ... + def inline_text(self, text: str, lineno: int) -> tuple[list[nodes.Node], list[nodes.system_message]]: ... + def unindent_warning(self, node_name: str) -> nodes.system_message: ... + +def build_regexp(definition: Definitiontype, compile: bool = ...) -> Pattern[str]: ... class Inliner: + implicit_dispatch: list[tuple[Pattern[str], Callable]] = ... def __init__(self) -> None: ... + start_string_prefix: str + end_string_suffix: str + parts: Definitiontype + patterns: Any + def init_customizations(self, settings: Any) -> None: ... + reporter: Reporter + document: nodes.document + language: ModuleType + parent: nodes.Element + def parse( + self, text: str, lineno: int, memo: Any, parent: nodes.Element + ) -> tuple[list[nodes.Node], list[nodes.system_message]]: ... + non_whitespace_before: str + non_whitespace_escape_before: str + non_unescaped_whitespace_escape_before: str + non_whitespace_after: str + simplename: str + uric: str + uri_end_delim: str + urilast: str + uri_end: str + emailc: str + email_pattern: str + def quoted_start(self, match: Match[str]) -> bool: ... + def inline_obj( + self, + match: Match[str], + lineno: int, + end_pattern: Pattern[str], + nodeclass: nodes.TextElement, + restore_backslashes: bool = ..., + ) -> tuple[str, list[nodes.problematic], str, list[nodes.system_message], str]: ... + def problematic(self, text: str, rawsource: str, message: nodes.system_message) -> nodes.problematic: ... + def emphasis( + self, match: Match[str], lineno: int + ) -> tuple[str, list[nodes.problematic], str, list[nodes.system_message]]: ... + def strong(self, match: Match[str], lineno: int) -> tuple[str, list[nodes.problematic], str, list[nodes.system_message]]: ... + def interpreted_or_phrase_ref( + self, match: Match[str], lineno: int + ) -> tuple[str, list[nodes.problematic], str, list[nodes.system_message]]: ... + def phrase_ref( + self, before: str, after: str, rawsource: str, escaped: str, text: str | None = None + ) -> tuple[str, list[nodes.Node], str, list[nodes.Node]]: ... + def adjust_uri(self, uri: str) -> str: ... + def interpreted( + self, rawsource: str, text: str, role: str, lineno: int + ) -> tuple[list[nodes.Node], list[nodes.system_message]]: ... + def literal(self, match: Match[str], lineno: int) -> tuple[str, list[nodes.problematic], str, list[nodes.system_message]]: ... + def inline_internal_target( + self, match: Match[str], lineno: int + ) -> tuple[str, list[nodes.problematic], str, list[nodes.system_message]]: ... + def substitution_reference( + self, match: Match[str], lineno: int + ) -> tuple[str, list[nodes.problematic], str, list[nodes.system_message]]: ... + def footnote_reference( + self, match: Match[str], lineno: int + ) -> tuple[str, list[nodes.problematic], str, list[nodes.system_message]]: ... + def reference( + self, match: Match[str], lineno: int, anonymous: bool = ... + ) -> tuple[str, list[nodes.problematic], str, list[nodes.system_message]]: ... + def anonymous_reference( + self, match: Match[str], lineno: int + ) -> tuple[str, list[nodes.problematic], str, list[nodes.system_message]]: ... + def standalone_uri( + self, match: Match[str], lineno: int + ) -> list[tuple[str, list[nodes.problematic], str, list[nodes.system_message]]]: ... + def pep_reference( + self, match: Match[str], lineno: int + ) -> list[tuple[str, list[nodes.problematic], str, list[nodes.system_message]]]: ... + rfc_url: str + def rfc_reference( + self, match: Match[str], lineno: int + ) -> list[tuple[str, list[nodes.problematic], str, list[nodes.system_message]]]: ... + def implicit_inline(self, text: str, lineno: int) -> list[nodes.Text]: ... + dispatch: dict[str, Callable[[Match[str], int], tuple[str, list[nodes.problematic], str, list[nodes.system_message]]]] + +class Body(RSTState): + double_width_pad_char: str + enum: Any + grid_table_top_pat: Pattern[str] + simple_table_top_pat: Pattern[str] + simple_table_border_pat: Pattern[str] + pats: dict[str, str] + patterns: dict[str, str | Pattern[str]] + initial_transitions: Sequence[str] | Sequence[tuple[str, str]] + def indent(self, match: Match[str], context: Any, next_state: str) -> tuple[Any, str, list[Any]]: ... + def block_quote(self, indented: Stringlist, line_offset: int) -> list[nodes.Element]: ... + attribution_pattern: Pattern[str] + def split_attribution( + self, indented: Stringlist, line_offset: int + ) -> tuple[Stringlist, Stringlist | None, int | None, Stringlist | None, int | None]: ... + def check_attribution(self, indented: Stringlist, attribution_start: int) -> tuple[int | None, int | None]: ... + def parse_attribution( + self, indented: Stringlist, line_offset: int + ) -> tuple[nodes.attribution, list[nodes.system_message]]: ... + def bullet(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]] | None: ... + def list_item(self, indent: int) -> tuple[nodes.list_item, bool]: ... + def enumerator(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def parse_enumerator(self, match: Match[str], expected_sequence: Any | None = ...) -> tuple[str, str, str, str | None]: ... + def is_enumerated_list_item(self, ordinal: int | None, sequence: str, format: str) -> int | None: ... + def make_enumerator(self, ordinal: int, sequence: str, format: str) -> tuple[str, str] | None: ... + def field_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def field(self, match: Match[str]) -> tuple[nodes.field, bool]: ... + def parse_field_marker(self, match: Match[str]) -> str: ... + def parse_field_body(self, indented: Stringlist, offset, node) -> None: ... + def option_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def option_list_item(self, match: Match[str]) -> tuple[nodes.option_list_item, bool]: ... + def parse_option_marker(self, match: Match[str]) -> list[nodes.option | nodes.option_argument]: ... + def doctest(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def line_block(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def line_block_line(self, match: Match[str], lineno: int) -> tuple[nodes.line, list[nodes.system_message], bool]: ... + def nest_line_block_lines(self, block: nodes.line_block) -> None: ... + def nest_line_block_segment(self, block: nodes.line_block) -> None: ... + def grid_table_top(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def simple_table_top(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def table_top( + self, + match: Match[str], + context: Any, + next_state: str, + isolate_function: Callable[ + [], tuple[list[Any], list[nodes.system_message], bool] | tuple[Stringlist, list[nodes.system_message], bool] + ], + parser_class: type[tableparser.GridTableParser | tableparser.SimpleTableParser], + ) -> tuple[list[Any], str, list[Any]]: ... + def table( + self, + isolate_function: Callable[[], tuple[list[Any] | Stringlist, list[nodes.system_message], bool]], + parser_class: type[tableparser.GridTableParser | tableparser.SimpleTableParser], + ) -> tuple[list[nodes.Node], bool]: ... + def isolate_grid_table( + self, + ) -> tuple[list[Any], list[nodes.system_message], bool] | tuple[Stringlist, list[nodes.system_message], bool]: ... + def isolate_simple_table( + self, + ) -> tuple[list[Any], list[nodes.system_message], bool] | tuple[Stringlist, list[nodes.system_message], bool]: ... + def malformed_table(self, block: Stringlist, detail: str = ..., offset: int = ...) -> list[nodes.system_message]: ... + def build_table( + self, + tabledata: tuple[list[int], list[list[tuple[int, int, int, Stringlist]]], list[list[tuple[int, int, int, Stringlist]]]], + tableline: int, + stub_columns: int = ..., + widths: None | str | list[int] = ..., + ) -> nodes.table: ... + def build_table_row(self, rowdata: list[tuple[int, int, int, Stringlist]], tableline: int) -> nodes.row: ... + explicit: Struct = ... + def footnote(self, match: Match[str]) -> tuple[list[nodes.footnote], bool]: ... + def citation(self, match: Match[str]) -> tuple[list[nodes.citation], bool]: ... + def hyperlink_target(self, match: Match[str]) -> tuple[list[nodes.target], bool] | tuple[list[str], bool]: ... + def make_target(self, block: list[str], block_text: str, lineno: int, target_name: str) -> nodes.target | str: ... + def parse_target(self, block: list[str], block_text: str, lineno: int) -> tuple[str, str]: ... + def is_reference(self, reference: str) -> str | None: ... + def add_target(self, targetname: str, refuri: str | None, target: nodes.target, lineno: int) -> None: ... + def substitution_def( + self, match: Match[str] + ) -> tuple[list[nodes.system_message], bool] | tuple[list[nodes.substitution_definition], bool]: ... + def disallowed_inside_substitution_definitions(self, node: nodes.Node) -> int: ... + def directive( + self, match: Match[str], **option_presets: Any + ) -> tuple[list[nodes.system_message], bool] | tuple[list[nodes.literal_block], bool]: ... + def run_directive( + self, directive: type[Directive], match: Match[str], type_name: str, option_presets: dict[str, Any] + ) -> tuple[list[nodes.system_message], bool] | tuple[list[nodes.literal_block], bool]: ... + def parse_directive_block( + self, indented: Stringlist, line_offset: int, directive: Directive, option_presets: dict[str, Any] + ) -> tuple[list[str], dict[str, Any], Stringlist, int]: ... + def parse_directive_options( + self, option_presets: dict[str, Any], option_spec: dict[str, Callable[[str], str]], arg_block: Stringlist | list[Any] + ) -> tuple[dict[str, Any], Stringlist]: ... + def parse_directive_arguments(self, directive: Directive, arg_block: Stringlist | list[Any]) -> list[str]: ... + def parse_extension_options( + self, option_spec: dict[str, Callable[[str], str]], datalines: Stringlist | list[Any] + ) -> tuple[int, str | dict[str, Any]]: ... + def unknown_directive(self, type_name: str) -> tuple[list[nodes.system_message], bool]: ... + def comment(self, match: Match[str]) -> tuple[list[nodes.comment], bool]: ... + def explicit_markup(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def explicit_construct( + self, match: Match[str] + ) -> ( + tuple[list[nodes.footnote], bool] + | tuple[list[nodes.citation], bool] + | tuple[list[nodes.target], bool] + | tuple[list[str], bool] + | tuple[list[nodes.system_message], bool] + | tuple[list[nodes.substitution_definition], bool] + | tuple[list[nodes.literal_block], bool] + | tuple[list[nodes.comment | nodes.system_message], bool] + ): ... + def explicit_list(self, blank_finish: bool) -> None: ... + def anonymous(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def anonymous_target(self, match: Match[str]) -> tuple[list[nodes.target | str], bool]: ... + def line(self, match: Match[str], context: Any, next_state: str) -> tuple[list[str], str, list[Any]]: ... + def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[str], str, list[Any]] | None: ... + +class RFC2822Body(Body): + patterns: dict[str, str | Pattern[str]] = ... + initial_transitions: Sequence[tuple[str, str]] = ... + def rfc2822(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def rfc2822_field(self, match: Match[str]) -> tuple[nodes.field, bool]: ... + +class SpecializedBody(Body): + def invalid_input(self, match: Match[str] | None = ..., context: Any | None = ..., next_state: str | None = ...) -> None: ... + # Description quoted below is taken from the docstring of SpecializedBody:: + # + # All transition methods are disabled (redefined as `invalid_input`). + # Override individual methods in subclasses to re-enable. + # + # Considering this purpose, we do not type following methods. + # + # indent + # bullet + # enumerator + # field_marker + # option_marker + # doctest + # line_block + # grid_table_top + # simple_table_top + # explicit_markup + # anonymous + # line + # text + +class Bulletlist(SpecializedBody): + blank_finish: bool = ... + def bullet(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + +class Definitionlist(SpecializedBody): + def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[str], str, list[Any]]: ... + +class Enumeratedlist(SpecializedBody): + auto: int = ... + blank_finish: bool = ... + lastordinal: int = ... + def enumerator(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + +class Fieldlist(SpecializedBody): + blank_finish: bool = ... + def field_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + +class Optionlist(SpecializedBody): + blank_finish: bool = ... + def option_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + +class RFC2822list(SpecializedBody, RFC2822Body): + patterns: dict[str, str | Pattern[str]] = ... + initial_transitions: list[tuple[str, str]] = ... + blank_finish: bool = ... + def rfc2822(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + # blank + +class ExtensionOptions(Fieldlist): + def parse_field_body(self, indented: Stringlist, offset: int, node: nodes.Node) -> None: ... + +class LineBlock(SpecializedBody): + # blank + blank_finish: bool = ... + def line_block(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + +class Explicit(SpecializedBody): + blank_finish: bool = ... + def explicit_markup(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def anonymous(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + # blank + +class SubstitutionDef(Body): + patterns: dict[str, str | Pattern[str]] = ... + initial_transitions: list[str] = ... + blank_finish: bool = ... + def embedded_directive(self, match: Match[str], context: Any, next_state: str) -> None: ... + def text(self, match: Match[str], context: Any, next_state: str) -> None: ... + +class Text(RSTState): + patterns: dict[str, str | Pattern[str]] = ... + initial_transitions: list[tuple[str, str]] = ... + def blank(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def eof(self, context: Any) -> list[Any]: ... + def indent(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def underline(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def literal_block(self) -> list[nodes.Node] | list[nodes.literal_block | nodes.system_message]: ... + def quoted_literal_block(self) -> list[nodes.Node]: ... + def definition_list_item(self, termline: MutableSequence[str]) -> tuple[nodes.definition_list_item, bool]: ... + classifier_delimiter: Pattern[str] = ... + def term( + self, lines: MutableSequence[str], lineno: int + ) -> tuple[list[nodes.term | nodes.classifier], list[nodes.system_message]]: ... + +class SpecializedText(Text): + def eof(self, context: Any) -> list[Any]: ... + def invalid_input(self, match: Match[str] | None = ..., context: Any | None = ..., next_state: str | None = ...) -> None: ... + # Description quoted below is taken from the docstring of SpecializedBody:: + # + # All transition methods are disabled. Override individual methods in + # subclasses to re-enable. + # + # Considering this purpose, we do not type following methods. + # + # blank + # indent + # underline + # text + +class Definition(SpecializedText): + def eof(self, context: Any) -> list[Any]: ... + blank_finish: bool = ... + def indent(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + +class Line(SpecializedText): + eofcheck: int = ... + def eof(self, context: Any) -> list[Any]: ... + def blank(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + # indent + def underline(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def short_overline(self, context: Any, blocktext: str, lineno: int, lines: int = ...) -> None: ... + def state_correction(self, context: Any, lines: int = ...) -> None: ... + +class QuotedLiteralBlock(RSTState): + patterns: dict[str, str | Pattern[str]] = ... + initial_transitions: tuple[str, str] = ... + messages: list[nodes.system_message] = ... + initial_lineno: int | None = ... + def __init__(self, state_machine: StateMachine, debug: bool = ...) -> None: ... + def blank(self, match: Match[str], context: Any, next_state: str) -> tuple[Any, str, list[Any]]: ... + def eof(self, context: Any) -> list[Any]: ... + def indent(self, match: Match[str], context: Any, next_state: str) -> None: ... + def initial_quoted(self, match: Match[str], context: Any, next_state: str) -> tuple[list[str], str, list[Any]]: ... + def quoted(self, match: Match[str], context: Any, next_state: str) -> tuple[Any, str, list[Any]]: ... + def text(self, match: Match[str], context: Any, next_state: str) -> None: ... -def __getattr__(name: str) -> Incomplete: ... +state_classes: Sequence[type[RSTState]] From 432bc11a06c3fa37803e0c6e02f855781dd31c0c Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 09:51:34 +0000 Subject: [PATCH 02/20] fixup --- .../docutils/parsers/rst/tableparser.pyi | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 stubs/docutils/docutils/parsers/rst/tableparser.pyi diff --git a/stubs/docutils/docutils/parsers/rst/tableparser.pyi b/stubs/docutils/docutils/parsers/rst/tableparser.pyi new file mode 100644 index 000000000000..20866eec54d0 --- /dev/null +++ b/stubs/docutils/docutils/parsers/rst/tableparser.pyi @@ -0,0 +1,63 @@ +from re import Pattern + +from docutils import DataError +from docutils.statemachine import Stringlist + +Cell = tuple[int, int, int, list[str]] +Row = list[Cell | None] +Colspecs = list[int] + +__docformat__: str + +class TableMarkupError(DataError): + offset: int + def __init__(self, *args, **kwargs) -> None: ... + +class TableParser: + head_body_separator_pat: Pattern[str] + double_width_pad_char: str + def parse(self, block: Stringlist) -> tuple[Colspecs, list[Row], list[Row]]: ... + head_body_sep: int + def find_head_body_sep(self) -> None: ... + +class GridTableParser(TableParser): + head_body_separator_pat: Pattern[str] + block: Stringlist + bottom: int + right: int + head_body_sep: int + done: list[int] + cells: list[Cell] + rowseps: dict[int, list[int]] + colseps: dict[int, list[int]] + def setup(self, block: Stringlist) -> None: ... + def parse_table(self) -> None: ... + def mark_done(self, top: int, left: int, bottom: int, right: int) -> None: ... + def check_parse_complete(self) -> bool: ... + def scan_cell(self, top: int, left: int) -> tuple[int, int, dict[int, list[int]], dict[int, list[int]]]: ... + def scan_right(self, top: int, left: int) -> tuple[int, int, dict[int, list[int]], dict[int, list[int]]]: ... + def scan_down(self, top: int, left: int, right: int) -> tuple[int, dict[int, list[int]], dict[int, list[int]]]: ... + def scan_left(self, top: int, left: int, bottom: int, right: int) -> tuple[dict[int, list[int]], dict[int, list[int]]]: ... + def scan_up(self, top: int, left: int, bottom: int, right: int) -> dict[int, list[int]]: ... + def structure_from_cells(self) -> tuple[Colspecs, list[Row], list[Row]]: ... + +class SimpleTableParser(TableParser): + head_body_separator_pat: Pattern[str] + span_pat: Pattern[str] + block: Stringlist + head_body_sep: int + columns: list[tuple[int, int]] + border_end: int + table: tuple[list[int], list[Row], list[Row]] + done: list[int] + rowseps: dict[int, tuple[int]] + colseps: dict[int, tuple[int]] + def setup(self, block: Stringlist) -> None: ... + def parse_table(self) -> None: ... + def parse_columns(self, line: str, offset: int) -> list[tuple[int, int]]: ... + def init_row(self, colspec: list[tuple[int, int]], offset: int) -> list[Cell]: ... + def parse_row(self, lines: list[str], start: int, spanline: tuple[str, int] | None = ...) -> None: ... + def check_columns(self, lines: list[str], first_line: int, columns: list[tuple[int, int]]) -> None: ... + def structure_from_cells(self) -> tuple[Colspecs, list[Row], list[Row]]: ... + +def update_dict_of_lists(master: dict[int, list[int]], newdata: dict[int, list[int]]) -> None: ... From 3ffba7f2f36c2ef1dad778a255b0744fa28ed3b8 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 09:56:46 +0000 Subject: [PATCH 03/20] fixup --- stubs/docutils/docutils/parsers/rst/tableparser.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/tableparser.pyi b/stubs/docutils/docutils/parsers/rst/tableparser.pyi index 20866eec54d0..7075d3398d15 100644 --- a/stubs/docutils/docutils/parsers/rst/tableparser.pyi +++ b/stubs/docutils/docutils/parsers/rst/tableparser.pyi @@ -1,4 +1,5 @@ from re import Pattern +from typing import ClassVar from docutils import DataError from docutils.statemachine import Stringlist @@ -14,14 +15,13 @@ class TableMarkupError(DataError): def __init__(self, *args, **kwargs) -> None: ... class TableParser: - head_body_separator_pat: Pattern[str] - double_width_pad_char: str + head_body_separator_pat: ClassVar[Pattern[str] | None] + double_width_pad_char: ClassVar[str] def parse(self, block: Stringlist) -> tuple[Colspecs, list[Row], list[Row]]: ... - head_body_sep: int def find_head_body_sep(self) -> None: ... class GridTableParser(TableParser): - head_body_separator_pat: Pattern[str] + head_body_separator_pat: ClassVar[Pattern[str]] block: Stringlist bottom: int right: int From 2bef051ea47193cba184bb788cfb472221f41c59 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 09:56:55 +0000 Subject: [PATCH 04/20] fixup --- stubs/docutils/docutils/parsers/rst/tableparser.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/tableparser.pyi b/stubs/docutils/docutils/parsers/rst/tableparser.pyi index 7075d3398d15..66f3ff7d5a7a 100644 --- a/stubs/docutils/docutils/parsers/rst/tableparser.pyi +++ b/stubs/docutils/docutils/parsers/rst/tableparser.pyi @@ -42,8 +42,8 @@ class GridTableParser(TableParser): def structure_from_cells(self) -> tuple[Colspecs, list[Row], list[Row]]: ... class SimpleTableParser(TableParser): - head_body_separator_pat: Pattern[str] - span_pat: Pattern[str] + head_body_separator_pat: ClassVar[Pattern[str]] + span_pat: ClassVar[Pattern[str]] block: Stringlist head_body_sep: int columns: list[tuple[int, int]] From 3d0c062b0b59713f02b51bcfdbc194352394faec Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 09:59:03 +0000 Subject: [PATCH 05/20] fixup --- .../docutils/parsers/rst/tableparser.pyi | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/tableparser.pyi b/stubs/docutils/docutils/parsers/rst/tableparser.pyi index 66f3ff7d5a7a..b836eda66230 100644 --- a/stubs/docutils/docutils/parsers/rst/tableparser.pyi +++ b/stubs/docutils/docutils/parsers/rst/tableparser.pyi @@ -4,9 +4,9 @@ from typing import ClassVar from docutils import DataError from docutils.statemachine import Stringlist -Cell = tuple[int, int, int, list[str]] -Row = list[Cell | None] -Colspecs = list[int] +_Cell = tuple[int, int, int, list[str]] +_Row = list[_Cell | None] +_Colspecs = list[int] __docformat__: str @@ -17,7 +17,7 @@ class TableMarkupError(DataError): class TableParser: head_body_separator_pat: ClassVar[Pattern[str] | None] double_width_pad_char: ClassVar[str] - def parse(self, block: Stringlist) -> tuple[Colspecs, list[Row], list[Row]]: ... + def parse(self, block: Stringlist) -> tuple[_Colspecs, list[_Row], list[_Row]]: ... def find_head_body_sep(self) -> None: ... class GridTableParser(TableParser): @@ -27,7 +27,7 @@ class GridTableParser(TableParser): right: int head_body_sep: int done: list[int] - cells: list[Cell] + cells: list[_Cell] rowseps: dict[int, list[int]] colseps: dict[int, list[int]] def setup(self, block: Stringlist) -> None: ... @@ -39,7 +39,7 @@ class GridTableParser(TableParser): def scan_down(self, top: int, left: int, right: int) -> tuple[int, dict[int, list[int]], dict[int, list[int]]]: ... def scan_left(self, top: int, left: int, bottom: int, right: int) -> tuple[dict[int, list[int]], dict[int, list[int]]]: ... def scan_up(self, top: int, left: int, bottom: int, right: int) -> dict[int, list[int]]: ... - def structure_from_cells(self) -> tuple[Colspecs, list[Row], list[Row]]: ... + def structure_from_cells(self) -> tuple[_Colspecs, list[_Row], list[_Row]]: ... class SimpleTableParser(TableParser): head_body_separator_pat: ClassVar[Pattern[str]] @@ -48,16 +48,16 @@ class SimpleTableParser(TableParser): head_body_sep: int columns: list[tuple[int, int]] border_end: int - table: tuple[list[int], list[Row], list[Row]] + table: tuple[list[int], list[_Row], list[_Row]] done: list[int] rowseps: dict[int, tuple[int]] colseps: dict[int, tuple[int]] def setup(self, block: Stringlist) -> None: ... def parse_table(self) -> None: ... def parse_columns(self, line: str, offset: int) -> list[tuple[int, int]]: ... - def init_row(self, colspec: list[tuple[int, int]], offset: int) -> list[Cell]: ... + def init_row(self, colspec: list[tuple[int, int]], offset: int) -> list[_Cell]: ... def parse_row(self, lines: list[str], start: int, spanline: tuple[str, int] | None = ...) -> None: ... def check_columns(self, lines: list[str], first_line: int, columns: list[tuple[int, int]]) -> None: ... - def structure_from_cells(self) -> tuple[Colspecs, list[Row], list[Row]]: ... + def structure_from_cells(self) -> tuple[_Colspecs, list[_Row], list[_Row]]: ... def update_dict_of_lists(master: dict[int, list[int]], newdata: dict[int, list[int]]) -> None: ... From a734606a135c0a12d04bce88c69959982ae488f4 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 10:03:36 +0000 Subject: [PATCH 06/20] fixup --- stubs/docutils/docutils/parsers/rst/states.pyi | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index d37c1ee8c847..1bbfa78fd017 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -392,18 +392,11 @@ class Text(RSTState): class SpecializedText(Text): def eof(self, context: Any) -> list[Any]: ... - def invalid_input(self, match: Match[str] | None = ..., context: Any | None = ..., next_state: str | None = ...) -> None: ... - # Description quoted below is taken from the docstring of SpecializedBody:: - # - # All transition methods are disabled. Override individual methods in - # subclasses to re-enable. - # - # Considering this purpose, we do not type following methods. - # - # blank - # indent - # underline - # text + def invalid_input(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def blank(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def indent(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def underline(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def text(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... class Definition(SpecializedText): def eof(self, context: Any) -> list[Any]: ... From 698e1eb72d96dd725d4c2755164abdce3b9944e6 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 10:04:27 +0000 Subject: [PATCH 07/20] fixup --- .../docutils/docutils/parsers/rst/states.pyi | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index 1bbfa78fd017..0e98797d1e5c 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -303,27 +303,20 @@ class RFC2822Body(Body): def rfc2822_field(self, match: Match[str]) -> tuple[nodes.field, bool]: ... class SpecializedBody(Body): - def invalid_input(self, match: Match[str] | None = ..., context: Any | None = ..., next_state: str | None = ...) -> None: ... - # Description quoted below is taken from the docstring of SpecializedBody:: - # - # All transition methods are disabled (redefined as `invalid_input`). - # Override individual methods in subclasses to re-enable. - # - # Considering this purpose, we do not type following methods. - # - # indent - # bullet - # enumerator - # field_marker - # option_marker - # doctest - # line_block - # grid_table_top - # simple_table_top - # explicit_markup - # anonymous - # line - # text + def invalid_input(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def indent(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def bullet(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def enumerator(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def field_marker(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def option_marker(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def doctest(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def line_block(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def grid_table_top(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def simple_table_top(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def explicit_markup(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def anonymous(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def line(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def text(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... class Bulletlist(SpecializedBody): blank_finish: bool = ... From 139c5221ca81667923ac29d6138911de486fdf81 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:23:09 +0000 Subject: [PATCH 08/20] fixup --- .../docutils/docutils/parsers/rst/states.pyi | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index 0e98797d1e5c..f0216c705441 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -304,19 +304,20 @@ class RFC2822Body(Body): class SpecializedBody(Body): def invalid_input(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def indent(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def bullet(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def enumerator(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def field_marker(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def option_marker(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def doctest(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def line_block(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def grid_table_top(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def simple_table_top(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def explicit_markup(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def anonymous(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def line(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def text(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + # The following base class methods are overridden by setting equal to `invalid_input`, and then overriden once again in subclasses + def indent(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def bullet(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def enumerator(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def field_marker(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def option_marker(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def doctest(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def line_block(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def grid_table_top(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def simple_table_top(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def explicit_markup(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def anonymous(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def line(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def text(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] class Bulletlist(SpecializedBody): blank_finish: bool = ... From be286e00785c04a6b54b0046d0401b97653bdf1f Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:25:10 +0000 Subject: [PATCH 09/20] fixup --- stubs/docutils/docutils/parsers/rst/states.pyi | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index f0216c705441..9be446c7eaa0 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -387,10 +387,11 @@ class Text(RSTState): class SpecializedText(Text): def eof(self, context: Any) -> list[Any]: ... def invalid_input(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def blank(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def indent(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def underline(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... - def text(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + # The following base class methods are overridden by setting equal to `invalid_input`, and then overriden once again in subclasses + def blank(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def indent(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def underline(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] + def text(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] class Definition(SpecializedText): def eof(self, context: Any) -> list[Any]: ... @@ -408,10 +409,10 @@ class Line(SpecializedText): def state_correction(self, context: Any, lines: int = ...) -> None: ... class QuotedLiteralBlock(RSTState): - patterns: dict[str, str | Pattern[str]] = ... - initial_transitions: tuple[str, str] = ... - messages: list[nodes.system_message] = ... - initial_lineno: int | None = ... + patterns: dict[str, str | Pattern[str]] + initial_transitions: tuple[str, str] + messages: list[nodes.system_message] + initial_lineno: int | None def __init__(self, state_machine: StateMachine, debug: bool = ...) -> None: ... def blank(self, match: Match[str], context: Any, next_state: str) -> tuple[Any, str, list[Any]]: ... def eof(self, context: Any) -> list[Any]: ... From 2c26ae8a87c5cbb3f88693eb70e8d2f3cdee18fa Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:31:07 +0000 Subject: [PATCH 10/20] fixup --- .../docutils/docutils/parsers/rst/states.pyi | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index 9be446c7eaa0..a32a5f35f853 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -303,7 +303,9 @@ class RFC2822Body(Body): def rfc2822_field(self, match: Match[str]) -> tuple[nodes.field, bool]: ... class SpecializedBody(Body): - def invalid_input(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def invalid_input( + self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None + ) -> None: ... # The following base class methods are overridden by setting equal to `invalid_input`, and then overriden once again in subclasses def indent(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] def bullet(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] @@ -321,10 +323,10 @@ class SpecializedBody(Body): class Bulletlist(SpecializedBody): blank_finish: bool = ... - def bullet(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def bullet(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] class Definitionlist(SpecializedBody): - def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[str], str, list[Any]]: ... + def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[str], str, list[Any]]: ... # type: ignore[override] class Enumeratedlist(SpecializedBody): auto: int = ... @@ -338,20 +340,18 @@ class Fieldlist(SpecializedBody): class Optionlist(SpecializedBody): blank_finish: bool = ... - def option_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def option_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] class RFC2822list(SpecializedBody, RFC2822Body): patterns: dict[str, str | Pattern[str]] = ... initial_transitions: list[tuple[str, str]] = ... blank_finish: bool = ... def rfc2822(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... - # blank class ExtensionOptions(Fieldlist): def parse_field_body(self, indented: Stringlist, offset: int, node: nodes.Node) -> None: ... class LineBlock(SpecializedBody): - # blank blank_finish: bool = ... def line_block(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... @@ -359,7 +359,6 @@ class Explicit(SpecializedBody): blank_finish: bool = ... def explicit_markup(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... def anonymous(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... - # blank class SubstitutionDef(Body): patterns: dict[str, str | Pattern[str]] = ... @@ -386,7 +385,9 @@ class Text(RSTState): class SpecializedText(Text): def eof(self, context: Any) -> list[Any]: ... - def invalid_input(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... + def invalid_input( + self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None + ) -> None: ... # The following base class methods are overridden by setting equal to `invalid_input`, and then overriden once again in subclasses def blank(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] def indent(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] @@ -405,7 +406,7 @@ class Line(SpecializedText): def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # indent def underline(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... - def short_overline(self, context: Any, blocktext: str, lineno: int, lines: int = ...) -> None: ... + def short_overline(self, context: Any, blocktext: str, lineno: int, lines: int = ...) -> None: ... # type: ignore[override] def state_correction(self, context: Any, lines: int = ...) -> None: ... class QuotedLiteralBlock(RSTState): From 9698850e6a39fabe70ce88e548c520621bb4616d Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:32:51 +0000 Subject: [PATCH 11/20] fixup --- stubs/docutils/docutils/parsers/rst/states.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index a32a5f35f853..d72001c9265e 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -332,11 +332,11 @@ class Enumeratedlist(SpecializedBody): auto: int = ... blank_finish: bool = ... lastordinal: int = ... - def enumerator(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def enumerator(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] class Fieldlist(SpecializedBody): blank_finish: bool = ... - def field_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def field_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] class Optionlist(SpecializedBody): blank_finish: bool = ... @@ -357,8 +357,8 @@ class LineBlock(SpecializedBody): class Explicit(SpecializedBody): blank_finish: bool = ... - def explicit_markup(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... - def anonymous(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def explicit_markup(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] + def anonymous(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] class SubstitutionDef(Body): patterns: dict[str, str | Pattern[str]] = ... From a733190602b7dea21eb832e78a008ef4dd68c2af Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:35:47 +0000 Subject: [PATCH 12/20] fixup --- stubs/docutils/docutils/parsers/rst/states.pyi | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index d72001c9265e..2727b5c7a1cd 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -353,7 +353,7 @@ class ExtensionOptions(Fieldlist): class LineBlock(SpecializedBody): blank_finish: bool = ... - def line_block(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def line_block(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] class Explicit(SpecializedBody): blank_finish: bool = ... @@ -397,15 +397,14 @@ class SpecializedText(Text): class Definition(SpecializedText): def eof(self, context: Any) -> list[Any]: ... blank_finish: bool = ... - def indent(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def indent(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] class Line(SpecializedText): eofcheck: int = ... def eof(self, context: Any) -> list[Any]: ... def blank(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... - def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... - # indent - def underline(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] + def underline(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] def short_overline(self, context: Any, blocktext: str, lineno: int, lines: int = ...) -> None: ... # type: ignore[override] def state_correction(self, context: Any, lines: int = ...) -> None: ... From b0893f78551955f53e96cfcd9b1e338450125f39 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:37:55 +0000 Subject: [PATCH 13/20] fixup --- stubs/docutils/docutils/parsers/rst/states.pyi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index 2727b5c7a1cd..54d678ed1555 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -361,15 +361,15 @@ class Explicit(SpecializedBody): def anonymous(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] class SubstitutionDef(Body): - patterns: dict[str, str | Pattern[str]] = ... - initial_transitions: list[str] = ... - blank_finish: bool = ... + patterns: dict[str, str | Pattern[str]] + initial_transitions: list[str] + blank_finish: bool def embedded_directive(self, match: Match[str], context: Any, next_state: str) -> None: ... def text(self, match: Match[str], context: Any, next_state: str) -> None: ... class Text(RSTState): - patterns: dict[str, str | Pattern[str]] = ... - initial_transitions: list[tuple[str, str]] = ... + patterns: dict[str, str | Pattern[str]] + initial_transitions: list[tuple[str, str]] def blank(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... def eof(self, context: Any) -> list[Any]: ... def indent(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... @@ -400,9 +400,9 @@ class Definition(SpecializedText): def indent(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] class Line(SpecializedText): - eofcheck: int = ... + eofcheck: int def eof(self, context: Any) -> list[Any]: ... - def blank(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... + def blank(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] def underline(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] def short_overline(self, context: Any, blocktext: str, lineno: int, lines: int = ...) -> None: ... # type: ignore[override] From 696b8de4ae3b090e671419cd1bac03e60c723843 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:41:31 +0000 Subject: [PATCH 14/20] fixup --- stubs/docutils/docutils/parsers/rst/states.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index 54d678ed1555..98fe389b4bb2 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -9,9 +9,9 @@ from docutils.parsers.rst import Directive, tableparser from docutils.statemachine import StateMachine, StateMachineWS, StateWS, Stringlist from docutils.utils import Reporter -BasicDefinition: TypeAlias = tuple[str, str, str, list[Pattern[str]]] -DefinitionParts: TypeAlias = tuple[str, str, str, list[Pattern[str] | BasicDefinition]] -Definitiontype: TypeAlias = tuple[str, str, str, list[Pattern[str] | DefinitionParts]] +_BasicDefinition: TypeAlias = tuple[str, str, str, list[Pattern[str]]] +_DefinitionParts: TypeAlias = tuple[str, str, str, list[Pattern[str] | _BasicDefinition]] +_Definitiontype: TypeAlias = tuple[str, str, str, list[Pattern[str] | _DefinitionParts]] __docformat__: str From eedb3ef492cbff6606b5617f07c099e8fd77ee4e Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:43:40 +0000 Subject: [PATCH 15/20] fixup --- stubs/docutils/docutils/parsers/rst/states.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index 98fe389b4bb2..5cacebc4d832 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -11,7 +11,7 @@ from docutils.utils import Reporter _BasicDefinition: TypeAlias = tuple[str, str, str, list[Pattern[str]]] _DefinitionParts: TypeAlias = tuple[str, str, str, list[Pattern[str] | _BasicDefinition]] -_Definitiontype: TypeAlias = tuple[str, str, str, list[Pattern[str] | _DefinitionParts]] +_DefinitionType: TypeAlias = tuple[str, str, str, list[Pattern[str] | _DefinitionParts]] __docformat__: str @@ -97,14 +97,14 @@ class RSTState(StateWS): def inline_text(self, text: str, lineno: int) -> tuple[list[nodes.Node], list[nodes.system_message]]: ... def unindent_warning(self, node_name: str) -> nodes.system_message: ... -def build_regexp(definition: Definitiontype, compile: bool = ...) -> Pattern[str]: ... +def build_regexp(definition: _DefinitionType, compile: bool = ...) -> Pattern[str]: ... class Inliner: implicit_dispatch: list[tuple[Pattern[str], Callable]] = ... def __init__(self) -> None: ... start_string_prefix: str end_string_suffix: str - parts: Definitiontype + parts: _DefinitionType patterns: Any def init_customizations(self, settings: Any) -> None: ... reporter: Reporter From 93ce796a8b001221099a5ad5c3e3b9784527d4b4 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:47:00 +0000 Subject: [PATCH 16/20] fixup --- stubs/docutils/docutils/parsers/rst/states.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index 5cacebc4d832..a0a9f4bb4695 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -321,24 +321,24 @@ class SpecializedBody(Body): def line(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] def text(self, match: Match[str] | None = None, context: Any | None = None, next_state: str | None = None) -> None: ... # type: ignore[override] -class Bulletlist(SpecializedBody): +class BulletList(SpecializedBody): blank_finish: bool = ... def bullet(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] -class Definitionlist(SpecializedBody): +class DefinitionList(SpecializedBody): def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[str], str, list[Any]]: ... # type: ignore[override] -class Enumeratedlist(SpecializedBody): +class EnumeratedList(SpecializedBody): auto: int = ... blank_finish: bool = ... lastordinal: int = ... def enumerator(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] -class Fieldlist(SpecializedBody): +class FieldList(SpecializedBody): blank_finish: bool = ... def field_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] -class Optionlist(SpecializedBody): +class OptionList(SpecializedBody): blank_finish: bool = ... def option_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] @@ -348,7 +348,7 @@ class RFC2822list(SpecializedBody, RFC2822Body): blank_finish: bool = ... def rfc2822(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... -class ExtensionOptions(Fieldlist): +class ExtensionOptions(FieldList): def parse_field_body(self, indented: Stringlist, offset: int, node: nodes.Node) -> None: ... class LineBlock(SpecializedBody): From 40a8e1c91e21208bcbab5893813c5d42c4317d5b Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:49:09 +0000 Subject: [PATCH 17/20] fixup --- stubs/docutils/docutils/parsers/rst/states.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index a0a9f4bb4695..e5fd0b2da1e6 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -54,7 +54,7 @@ class NestedStateMachine(StateMachineWS): class RSTState(StateWS): nested_sm: type[StateMachine] nested_sm_cache: list[StateMachine] - nested_sm_kwargs: dict[str, Any] + nested_sm_kwargs: dict[str, Any] | None def __init__(self, state_machine: StateMachine, debug: bool = ...) -> None: ... memo: Struct reporter: Reporter From c410089e4331d3b2740269d3bfed2c53722df4c8 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 11:54:44 +0000 Subject: [PATCH 18/20] fixup --- stubs/docutils/docutils/parsers/rst/states.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index e5fd0b2da1e6..a92db4a6244e 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -342,7 +342,7 @@ class OptionList(SpecializedBody): blank_finish: bool = ... def option_marker(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] -class RFC2822list(SpecializedBody, RFC2822Body): +class RFC2822List(SpecializedBody, RFC2822Body): patterns: dict[str, str | Pattern[str]] = ... initial_transitions: list[tuple[str, str]] = ... blank_finish: bool = ... @@ -405,6 +405,7 @@ class Line(SpecializedText): def blank(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] def text(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] def underline(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] + def indent(self, match: Match[str], context: Any, next_state: str) -> tuple[list[Any], str, list[Any]]: ... # type: ignore[override] def short_overline(self, context: Any, blocktext: str, lineno: int, lines: int = ...) -> None: ... # type: ignore[override] def state_correction(self, context: Any, lines: int = ...) -> None: ... From 077febbaec99a191e941bd6f067698dad3ebee3b Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sun, 3 Mar 2024 12:51:10 +0000 Subject: [PATCH 19/20] fixup --- .../docutils/docutils/parsers/rst/states.pyi | 32 +++++++++---------- .../docutils/parsers/rst/tableparser.pyi | 7 ++-- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index a92db4a6244e..d82f2ca9b1f0 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -35,9 +35,9 @@ class RSTStateMachine(StateMachineWS): self, input_lines: list[str] | Stringlist, document: nodes.document, - input_offset: int = ..., - match_titles: bool = ..., - inliner: Inliner | None = ..., + input_offset: int = 0, + match_titles: bool = True, + inliner: Inliner | None = None, ) -> None: ... class NestedStateMachine(StateMachineWS): @@ -48,14 +48,14 @@ class NestedStateMachine(StateMachineWS): language: ModuleType node: nodes.Node def run( - self, input_lines: list[str] | Stringlist, input_offset: int, memo: Struct, node: nodes.Node, match_titles: bool = ... + self, input_lines: list[str] | Stringlist, input_offset: int, memo: Struct, node: nodes.Node, match_titles: bool = True ) -> list[Any]: ... class RSTState(StateWS): nested_sm: type[StateMachine] nested_sm_cache: list[StateMachine] nested_sm_kwargs: dict[str, Any] | None - def __init__(self, state_machine: StateMachine, debug: bool = ...) -> None: ... + def __init__(self, state_machine: StateMachine, debug: bool = False) -> None: ... memo: Struct reporter: Reporter inliner: Inliner @@ -72,9 +72,9 @@ class RSTState(StateWS): block: Stringlist, input_offset: int, node: nodes.Node, - match_titles: bool = ..., - state_machine_class: type[StateMachine] | None = ..., - state_machine_kwargs: dict[str, Any] | None = ..., + match_titles: bool = False, + state_machine_class: type[StateMachine] | None = None, + state_machine_kwargs: dict[str, Any] | None = None, ) -> int: ... def nested_list_parse( self, @@ -83,11 +83,11 @@ class RSTState(StateWS): node, initial_state, blank_finish, - blank_finish_state: Any | None = ..., - extra_settings: Any = ..., - match_titles: bool = ..., - state_machine_class: Any | None = ..., - state_machine_kwargs: Any | None = ..., + blank_finish_state: Any | None = None, + extra_settings: dict[str, Any] = {}, + match_titles: bool = False, + state_machine_class: Any | None = None, + state_machine_kwargs: Any | None = None, ) -> tuple[int, bool]: ... def section(self, title: str, source: str, style: str, lineno: int, messages: list[str]) -> None: ... def check_subsection(self, source: str, style: str, lineno: int) -> int: ... @@ -238,13 +238,13 @@ class Body(RSTState): def isolate_simple_table( self, ) -> tuple[list[Any], list[nodes.system_message], bool] | tuple[Stringlist, list[nodes.system_message], bool]: ... - def malformed_table(self, block: Stringlist, detail: str = ..., offset: int = ...) -> list[nodes.system_message]: ... + def malformed_table(self, block: Stringlist, detail: str = '', offset: int = 0) -> list[nodes.system_message]: ... def build_table( self, tabledata: tuple[list[int], list[list[tuple[int, int, int, Stringlist]]], list[list[tuple[int, int, int, Stringlist]]]], tableline: int, - stub_columns: int = ..., - widths: None | str | list[int] = ..., + stub_columns: int = 0, + widths: None | str | list[int] = None, ) -> nodes.table: ... def build_table_row(self, rowdata: list[tuple[int, int, int, Stringlist]], tableline: int) -> nodes.row: ... explicit: Struct = ... diff --git a/stubs/docutils/docutils/parsers/rst/tableparser.pyi b/stubs/docutils/docutils/parsers/rst/tableparser.pyi index b836eda66230..76b06eb90532 100644 --- a/stubs/docutils/docutils/parsers/rst/tableparser.pyi +++ b/stubs/docutils/docutils/parsers/rst/tableparser.pyi @@ -1,12 +1,13 @@ from re import Pattern from typing import ClassVar +from typing_extensions import TypeAlias from docutils import DataError from docutils.statemachine import Stringlist -_Cell = tuple[int, int, int, list[str]] -_Row = list[_Cell | None] -_Colspecs = list[int] +_Cell: TypeAlias = tuple[int, int, int, list[str]] +_Row: TypeAlias = list[_Cell | None] +_Colspecs: TypeAlias = list[int] __docformat__: str From 5c0f1d18b81a7054c27ec259d3b144a1aff65f21 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 3 Mar 2024 12:52:14 +0000 Subject: [PATCH 20/20] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/docutils/docutils/parsers/rst/states.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index d82f2ca9b1f0..a5fd6dd96954 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -238,7 +238,7 @@ class Body(RSTState): def isolate_simple_table( self, ) -> tuple[list[Any], list[nodes.system_message], bool] | tuple[Stringlist, list[nodes.system_message], bool]: ... - def malformed_table(self, block: Stringlist, detail: str = '', offset: int = 0) -> list[nodes.system_message]: ... + def malformed_table(self, block: Stringlist, detail: str = "", offset: int = 0) -> list[nodes.system_message]: ... def build_table( self, tabledata: tuple[list[int], list[list[tuple[int, int, int, Stringlist]]], list[list[tuple[int, int, int, Stringlist]]]],