Skip to content

Commit eff97aa

Browse files
committed
fixup
1 parent 1d0c8d5 commit eff97aa

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

stubs/docutils/docutils/statemachine.pyi

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from collections.abc import Callable, Generator, Iterator, Sequence
22
from re import Match, Pattern
3-
from typing import Any, Generic, TypeVar, overload
3+
from typing import Any, Generic, TypeAlias, TypeVar, overload
44
from typing_extensions import Self
55

66
__docformat__: str
77

88
_Context = TypeVar("_Context")
99
_Result = TypeVar("_Result")
10+
_TransitionMethod: TypeAlias = Callable[[tuple[Match[str], _Context, str | None]], tuple[_Context, str | None, list[_Result]]]
11+
_TransitionResult: TypeAlias = tuple[_Context, str, list[_Result]]
1012

1113
class StateMachine(Generic[_Context, _Result]):
1214
input_lines: StringList | None
@@ -45,7 +47,7 @@ class StateMachine(Generic[_Context, _Result]):
4547
def get_text_block(self, flush_left: bool = False) -> StringList: ...
4648
def check_line(
4749
self, context: _Context, state: State[_Context, _Result], transitions: list[str] | None = ...
48-
) -> tuple[_Context, str | None, list[_Result]]: ...
50+
) -> _TransitionResult[_Context, _Result]: ...
4951
def add_state(self, state_class: type[State[_Context, _Result]]) -> None: ...
5052
def add_states(self, state_classes: Sequence[type[State[_Context, _Result]]]) -> None: ...
5153
def runtime_init(self) -> None: ...
@@ -70,16 +72,20 @@ class State(Generic[_Context, _Result]):
7072
def add_transitions(self, names: list[str], transitions) -> None: ...
7173
def add_transition(self, name: str, transition: tuple[Pattern[str], str, str]) -> None: ...
7274
def remove_transition(self, name: str) -> None: ...
73-
def make_transition(self, name: str, next_state: str | None = None) -> tuple[Pattern[str], Callable, str]: ...
75+
def make_transition(
76+
self, name: str, next_state: str | None = None
77+
) -> tuple[Pattern[str], _TransitionMethod[_Context, _Result], str]: ...
7478
def make_transitions(
7579
self, name_list: list[str | tuple[str] | tuple[str, str]]
76-
) -> tuple[list[str], dict[str, tuple[Pattern[str], Callable, str]]]: ...
80+
) -> tuple[list[str], dict[str, tuple[Pattern[str], _TransitionMethod[_Context, _Result], str]]]: ...
7781
def no_match(
78-
self, context: Any, transitions: tuple[list[str], dict[str, tuple[Pattern[str], Callable, str]]]
79-
) -> tuple[Any, str, list[Any]]: ...
80-
def bof(self, context: _Context) -> tuple[Any, list[Any]]: ...
81-
def eof(self, context: _Context) -> list[Any]: ...
82-
def nop(self, match: Match[str], context: _Context, next_state: str) -> tuple[Any, str, list[Any]]: ...
82+
self,
83+
context: Any,
84+
transitions: tuple[list[str], dict[str, tuple[Pattern[str], _TransitionMethod[_Context, _Result], str]]],
85+
) -> _TransitionResult[_Context, _Result]: ...
86+
def bof(self, context: _Context) -> tuple[_Context, list[_Result]]: ...
87+
def eof(self, context: _Context) -> list[_Result]: ...
88+
def nop(self, match: Match[str], context: _Context, next_state: str) -> _TransitionResult[_Context, _Result]: ...
8389

8490
class StateMachineWS(StateMachine[_Context, _Result]):
8591
def get_indented(self, until_blank: bool = False, strip_indent: bool = True) -> tuple[StringList, int, int, bool]: ...
@@ -99,10 +105,12 @@ class StateWS(State[_Context, _Result]):
99105
ws_initial_transitions: Sequence[str]
100106
def __init__(self, state_machine: StateMachine[_Context, _Result], debug: bool = False) -> None: ...
101107
def add_initial_transitions(self) -> None: ...
102-
def blank(self, match: Match[str], context: _Context, next_state: str) -> tuple[Any, str, Any]: ...
103-
def indent(self, match: Match[str], context: _Context, next_state: str) -> tuple[Any, str, Any] | None: ...
104-
def known_indent(self, match: Match[str], context: _Context, next_state: str) -> tuple[Any, str, Any]: ...
105-
def first_known_indent(self, match: Match[str], context: _Context, next_state: str) -> tuple[Any, str, Any]: ...
108+
def blank(self, match: Match[str], context: _Context, next_state: str) -> _TransitionResult[_Context, _Result]: ...
109+
def indent(self, match: Match[str], context: _Context, next_state: str) -> _TransitionResult[_Context, _Result]: ...
110+
def known_indent(self, match: Match[str], context: _Context, next_state: str) -> _TransitionResult[_Context, _Result]: ...
111+
def first_known_indent(
112+
self, match: Match[str], context: _Context, next_state: str
113+
) -> _TransitionResult[_Context, _Result]: ...
106114

107115
class _SearchOverride:
108116
def match(self, pattern: Pattern[str]) -> Match[str]: ...

0 commit comments

Comments
 (0)