Skip to content

Commit 435a6c3

Browse files
committed
Fix MyPy errors
1 parent 171769e commit 435a6c3

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

stubs/docutils/docutils/parsers/rst/states.pyi

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
from _typeshed import Incomplete
21
from collections.abc import Callable, Iterable, Mapping, Sequence
32
from re import Match, Pattern
43
from types import ModuleType
54
from typing import Any, ClassVar, Final, Literal, TypeVar, overload
6-
from typing_extensions import Never, TypeAlias
75

6+
from _typeshed import Incomplete
87
from docutils import ApplicationError, DataError, nodes
98
from docutils.parsers.rst import Directive
109
from docutils.parsers.rst.languages import _RstLanguageModule
1110
from docutils.parsers.rst.tableparser import TableParser
1211
from docutils.statemachine import StateMachine, StateMachineWS, StateWS, StringList
1312
from docutils.utils import Reporter
13+
from typing_extensions import Never, TypeAlias
1414

1515
__docformat__: Final = "reStructuredText"
1616

@@ -35,7 +35,7 @@ class RSTStateMachine(StateMachineWS[Incomplete]):
3535
document: nodes.document
3636
reporter: Reporter
3737
node: nodes.document | None
38-
def run(
38+
def run( # type: ignore[override]
3939
self,
4040
input_lines: Sequence[str] | StringList,
4141
document: nodes.document,
@@ -51,12 +51,12 @@ class NestedStateMachine(StateMachineWS[Incomplete]):
5151
reporter: Reporter
5252
language: Incomplete
5353
node: Incomplete
54-
def run(
54+
def run( # type: ignore[override]
5555
self, input_lines: Sequence[str] | StringList, input_offset: int, memo, node: nodes.Node, match_titles: bool = True
5656
) -> list[str]: ...
5757

5858
class RSTState(StateWS[list[str]]):
59-
nested_sm: ClassVar[type[NestedStateMachine]]
59+
nested_sm: ClassVar[type[NestedStateMachine]] # type: ignore[misc]
6060
nested_sm_cache: ClassVar[list[StateMachine[Incomplete]]]
6161
nested_sm_kwargs: dict[str, Any]
6262
def __init__(self, state_machine, debug: bool = False) -> None: ...
@@ -270,7 +270,7 @@ class Body(RSTState):
270270

271271
class RFC2822Body(Body):
272272
patterns: ClassVar[dict[str, str | Pattern[str]]]
273-
initial_transitions: ClassVar[list[tuple[str | tuple[str, str], str]]]
273+
initial_transitions: ClassVar[list[tuple[str | tuple[str, str], str]]] # type: ignore[assignment]
274274

275275
def rfc2822(self, match: Match[str], context: Any, next_state: _NextState) -> tuple[list[Any], _NextState, list[str]]: ...
276276
def rfc2822_field(self, match: Match[str]): ...
@@ -295,29 +295,29 @@ class SpecializedBody(Body):
295295
text = invalid_input
296296

297297
class BulletList(SpecializedBody):
298-
def bullet(self, match: Match[str], context: Any, next_state: _NextState) -> tuple[list[Any], _NextState, list[Any]]: ...
298+
def bullet(self, match: Match[str], context: Any, next_state: _NextState) -> tuple[list[Any], _NextState, list[Any]]: ... # type: ignore[override]
299299

300300
class DefinitionList(SpecializedBody):
301-
def text(self, match: Match[str], context: Any, next_state: Any) -> tuple[list[str], Literal["Definition"], list[Any]]: ...
301+
def text(self, match: Match[str], context: Any, next_state: Any) -> tuple[list[str], Literal["Definition"], list[Any]]: ... # type: ignore[override]
302302

303303
class EnumeratedList(SpecializedBody):
304304
auto: int
305305
blank_finish: Incomplete
306306
lastordinal: Incomplete
307307

308-
def enumerator(self, match: Match[str], context: Any, next_state: _NextState) -> tuple[list[Any], _NextState, list[Any]]: ...
308+
def enumerator(self, match: Match[str], context: Any, next_state: _NextState) -> tuple[list[Any], _NextState, list[Any]]: ... # type: ignore[override]
309309

310310
class FieldList(SpecializedBody):
311311
blank_finish: Incomplete
312312

313-
def field_marker(
313+
def field_marker( # type: ignore[override]
314314
self, match: Match[str], context: Any, next_state: _NextState
315315
) -> tuple[list[Any], _NextState, list[Any]]: ...
316316

317317
class OptionList(SpecializedBody):
318318
blank_finish: Incomplete
319319

320-
def option_marker(
320+
def option_marker( # type: ignore[override]
321321
self, match: Match[str], context: Any, next_state: _NextState
322322
) -> tuple[list[Any], _NextState, list[Any]]: ...
323323

@@ -326,7 +326,7 @@ class RFC2822List(SpecializedBody, RFC2822Body):
326326
initial_transitions: ClassVar[list[tuple[str | tuple[str, str], str]]]
327327
blank_finish: Incomplete
328328

329-
def rfc2822(
329+
def rfc2822( # type: ignore[override]
330330
self, match: Match[str], context: Any, next_state: Any
331331
) -> tuple[list[Any], Literal["RFC2822List"], list[Any]]: ...
332332
def blank(self, match: Any = None, context: Any = None, next_state: Any = None) -> Never: ...
@@ -335,25 +335,23 @@ class ExtensionOptions(FieldList):
335335
def parse_field_body(self, indented: StringList, offset: Any, node: nodes.Node) -> None: ...
336336

337337
class LineBlock(SpecializedBody):
338-
blank: Incomplete
339338
blank_finish: Incomplete
340339

341340
def blank(self, match: Any = None, context: Any = None, next_state: Any = None) -> Never: ...
342-
def line_block(self, match: Match[Any], context: Any, next_state: _NextState) -> tuple[list[Any], _NextState, list[Any]]: ...
341+
def line_block(self, match: Match[Any], context: Any, next_state: _NextState) -> tuple[list[Any], _NextState, list[Any]]: ... # type: ignore[override]
343342

344343
class Explicit(SpecializedBody):
345344
blank_finish: Incomplete
346-
blank: Incomplete
347345

348-
def explicit_markup(
346+
def explicit_markup( # type: ignore[override]
349347
self, match: Match[str], context: Any, next_state: _NextState
350348
) -> tuple[list[Any], _NextState, list[Any]]: ...
351-
def anonymous(self, match: Match[str], context: Any, next_state: _NextState) -> tuple[list[Any], _NextState, list[Any]]: ...
349+
def anonymous(self, match: Match[str], context: Any, next_state: _NextState) -> tuple[list[Any], _NextState, list[Any]]: ... # type: ignore[override]
352350
def blank(self, match: Any = None, context: Any = None, next_state: Any = None) -> Never: ...
353351

354352
class SubstitutionDef(Body):
355353
patterns: ClassVar[dict[str, str | Pattern[str]]]
356-
initial_transitions: ClassVar[list[str]]
354+
initial_transitions: ClassVar[list[str]] # type: ignore[assignment]
357355
blank_finish: Incomplete
358356

359357
def embedded_directive(self, match: Match[str], context: Any, next_state: Any) -> Never: ...
@@ -387,18 +385,18 @@ class SpecializedText(Text):
387385

388386
class Definition(SpecializedText):
389387
def eof(self, context: Any) -> list[Any]: ...
390-
def indent(
391-
self, match: Any, context: StringList, next_state: Any
388+
def indent( # type: ignore[override]
389+
self, match: Any, context: list[str], next_state: Any
392390
) -> tuple[list[Any], Literal["DefinitionList"], list[Any]]: ...
393391

394392
class Line(SpecializedText):
395393
eofcheck: Literal[1]
396394

397395
def eof(self, context: Any) -> list[Any]: ...
398-
def blank(self, match: Any, context: Any, next_state: Any) -> tuple[list[Any], Literal["Body"], list[Any]]: ...
399-
def text(self, match: Match[str], context: StringList, next_state: Any) -> tuple[list[Any], Literal["Body"], list[Any]]: ...
400-
def indent(self, match: Match[str], context: StringList, next_state: Any) -> tuple[list[Any], Literal["Body"], list[Any]]: ...
401-
def underline(self, match: Any, context: StringList, next_state: Any) -> tuple[list[Any], Literal["Body"], list[Any]]: ...
396+
def blank(self, match: Any, context: Any, next_state: Any) -> tuple[list[Any], Literal["Body"], list[Any]]: ... # type: ignore[override]
397+
def text(self, match: Match[str], context: list[str], next_state: Any) -> tuple[list[Any], Literal["Body"], list[Any]]: ... # type: ignore[override]
398+
def indent(self, match: Match[str], context: list[str], next_state: Any) -> tuple[list[Any], Literal["Body"], list[Any]]: ... # type: ignore[override]
399+
def underline(self, match: Any, context: list[str], next_state: Any) -> tuple[list[Any], Literal["Body"], list[Any]]: ... # type: ignore[override]
402400
def short_overline(self, context: list[Any], blocktext: Any, lineno: int | None, lines: int = 1) -> None: ...
403401
def state_correction(self, context: list[Any], lines: int = 1) -> Never: ...
404402

@@ -414,8 +412,8 @@ class QuotedLiteralBlock(RSTState):
414412
) -> tuple[_EmptyContext, _NextState, list[Any]]: ...
415413
@overload
416414
def blank(self, match: Any, context: Any, next_state: _NextState) -> Never: ...
417-
def eof(self, context: StringList) -> list[Any]: ...
418-
def indent(self, match: Any, context: StringList, next_state: Any) -> Never: ...
415+
def eof(self, context: list[str]) -> list[Any]: ...
416+
def indent(self, match: Any, context: list[str], next_state: Any) -> Never: ...
419417
def initial_quoted(
420418
self, match: Match[str], context: Any, next_state: _NextState
421419
) -> tuple[list[str], _NextState, list[Any]]: ...

0 commit comments

Comments
 (0)