mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Big diff: Use new "|" union syntax (#5872)
This commit is contained in:
@@ -2,19 +2,19 @@ from _typeshed import StrPath
|
||||
from lib2to3.pgen2.grammar import Grammar
|
||||
from lib2to3.pytree import _NL, _Convert
|
||||
from logging import Logger
|
||||
from typing import IO, Any, Iterable, Optional
|
||||
from typing import IO, Any, Iterable
|
||||
|
||||
class Driver:
|
||||
grammar: Grammar
|
||||
logger: Logger
|
||||
convert: _Convert
|
||||
def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ..., logger: Optional[Logger] = ...) -> None: ...
|
||||
def __init__(self, grammar: Grammar, convert: _Convert | None = ..., logger: Logger | None = ...) -> None: ...
|
||||
def parse_tokens(self, tokens: Iterable[Any], debug: bool = ...) -> _NL: ...
|
||||
def parse_stream_raw(self, stream: IO[str], debug: bool = ...) -> _NL: ...
|
||||
def parse_stream(self, stream: IO[str], debug: bool = ...) -> _NL: ...
|
||||
def parse_file(self, filename: StrPath, encoding: Optional[str] = ..., debug: bool = ...) -> _NL: ...
|
||||
def parse_file(self, filename: StrPath, encoding: str | None = ..., debug: bool = ...) -> _NL: ...
|
||||
def parse_string(self, text: str, debug: bool = ...) -> _NL: ...
|
||||
|
||||
def load_grammar(
|
||||
gt: str = ..., gp: Optional[str] = ..., save: bool = ..., force: bool = ..., logger: Optional[Logger] = ...
|
||||
gt: str = ..., gp: str | None = ..., save: bool = ..., force: bool = ..., logger: Logger | None = ...
|
||||
) -> Grammar: ...
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
from lib2to3.pgen2.grammar import _DFAS, Grammar
|
||||
from lib2to3.pytree import _NL, _Convert, _RawNode
|
||||
from typing import Any, List, Optional, Sequence, Set, Tuple
|
||||
from typing import Any, List, Sequence, Set, Tuple
|
||||
|
||||
_Context = Sequence[Any]
|
||||
|
||||
class ParseError(Exception):
|
||||
msg: str
|
||||
type: int
|
||||
value: Optional[str]
|
||||
value: str | None
|
||||
context: _Context
|
||||
def __init__(self, msg: str, type: int, value: Optional[str], context: _Context) -> None: ...
|
||||
def __init__(self, msg: str, type: int, value: str | None, context: _Context) -> None: ...
|
||||
|
||||
class Parser:
|
||||
grammar: Grammar
|
||||
convert: _Convert
|
||||
stack: List[Tuple[_DFAS, int, _RawNode]]
|
||||
rootnode: Optional[_NL]
|
||||
rootnode: _NL | None
|
||||
used_names: Set[str]
|
||||
def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ...) -> None: ...
|
||||
def setup(self, start: Optional[int] = ...) -> None: ...
|
||||
def addtoken(self, type: int, value: Optional[str], context: _Context) -> bool: ...
|
||||
def classify(self, type: int, value: Optional[str], context: _Context) -> int: ...
|
||||
def shift(self, type: int, value: Optional[str], newstate: int, context: _Context) -> None: ...
|
||||
def __init__(self, grammar: Grammar, convert: _Convert | None = ...) -> None: ...
|
||||
def setup(self, start: int | None = ...) -> None: ...
|
||||
def addtoken(self, type: int, value: str | None, context: _Context) -> bool: ...
|
||||
def classify(self, type: int, value: str | None, context: _Context) -> int: ...
|
||||
def shift(self, type: int, value: str | None, newstate: int, context: _Context) -> None: ...
|
||||
def push(self, type: int, newdfa: _DFAS, newstate: int, context: _Context) -> None: ...
|
||||
def pop(self) -> None: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from _typeshed import StrPath
|
||||
from lib2to3.pgen2 import grammar
|
||||
from lib2to3.pgen2.tokenize import _TokenInfo
|
||||
from typing import IO, Any, Dict, Iterable, Iterator, List, NoReturn, Optional, Tuple
|
||||
from typing import IO, Any, Dict, Iterable, Iterator, List, NoReturn, Tuple
|
||||
|
||||
class PgenGrammar(grammar.Grammar): ...
|
||||
|
||||
@@ -10,7 +10,7 @@ class ParserGenerator:
|
||||
stream: IO[str]
|
||||
generator: Iterator[_TokenInfo]
|
||||
first: Dict[str, Dict[str, int]]
|
||||
def __init__(self, filename: StrPath, stream: Optional[IO[str]] = ...) -> None: ...
|
||||
def __init__(self, filename: StrPath, stream: IO[str] | None = ...) -> None: ...
|
||||
def make_grammar(self) -> PgenGrammar: ...
|
||||
def make_first(self, c: PgenGrammar, name: str) -> Dict[int, int]: ...
|
||||
def make_label(self, c: PgenGrammar, label: str) -> int: ...
|
||||
@@ -25,14 +25,14 @@ class ParserGenerator:
|
||||
def parse_alt(self) -> Tuple[NFAState, NFAState]: ...
|
||||
def parse_item(self) -> Tuple[NFAState, NFAState]: ...
|
||||
def parse_atom(self) -> Tuple[NFAState, NFAState]: ...
|
||||
def expect(self, type: int, value: Optional[Any] = ...) -> str: ...
|
||||
def expect(self, type: int, value: Any | None = ...) -> str: ...
|
||||
def gettoken(self) -> None: ...
|
||||
def raise_error(self, msg: str, *args: Any) -> NoReturn: ...
|
||||
|
||||
class NFAState:
|
||||
arcs: List[Tuple[Optional[str], NFAState]]
|
||||
arcs: List[Tuple[str | None, NFAState]]
|
||||
def __init__(self) -> None: ...
|
||||
def addarc(self, next: NFAState, label: Optional[str] = ...) -> None: ...
|
||||
def addarc(self, next: NFAState, label: str | None = ...) -> None: ...
|
||||
|
||||
class DFAState:
|
||||
nfaset: Dict[NFAState, Any]
|
||||
|
||||
Reference in New Issue
Block a user