Big diff: use lower-case list and dict (#5888)

This commit is contained in:
Akuli
2021-08-08 19:26:35 +03:00
committed by GitHub
parent 11f54c3407
commit ce11072dbe
325 changed files with 2196 additions and 2334 deletions

View File

@@ -7,14 +7,14 @@ _DFA = List[List[Tuple[int, int]]]
_DFAS = Tuple[_DFA, Dict[int, int]]
class Grammar:
symbol2number: Dict[str, int]
number2symbol: Dict[int, str]
states: List[_DFA]
dfas: Dict[int, _DFAS]
labels: List[_Label]
keywords: Dict[str, int]
tokens: Dict[int, int]
symbol2label: Dict[str, int]
symbol2number: dict[str, int]
number2symbol: dict[int, str]
states: list[_DFA]
dfas: dict[int, _DFAS]
labels: list[_Label]
keywords: dict[str, int]
tokens: dict[int, int]
symbol2label: dict[str, int]
start: int
def __init__(self) -> None: ...
def dump(self, filename: StrPath) -> None: ...
@@ -23,4 +23,4 @@ class Grammar:
def report(self) -> None: ...
opmap_raw: str
opmap: Dict[str, str]
opmap: dict[str, str]

View File

@@ -1,6 +1,6 @@
from typing import Dict, Match
from typing import Match
simple_escapes: Dict[str, str]
simple_escapes: dict[str, str]
def escape(m: Match[str]) -> str: ...
def evalString(s: str) -> str: ...

View File

@@ -1,6 +1,6 @@
from lib2to3.pgen2.grammar import _DFAS, Grammar
from lib2to3.pytree import _NL, _Convert, _RawNode
from typing import Any, List, Sequence, Set, Tuple
from typing import Any, Sequence, Set, Tuple
_Context = Sequence[Any]
@@ -14,7 +14,7 @@ class ParseError(Exception):
class Parser:
grammar: Grammar
convert: _Convert
stack: List[Tuple[_DFAS, int, _RawNode]]
stack: list[Tuple[_DFAS, int, _RawNode]]
rootnode: _NL | None
used_names: Set[str]
def __init__(self, grammar: Grammar, convert: _Convert | None = ...) -> None: ...

View File

@@ -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, Tuple
from typing import IO, Any, Iterable, Iterator, NoReturn, Tuple
class PgenGrammar(grammar.Grammar): ...
@@ -9,18 +9,18 @@ class ParserGenerator:
filename: StrPath
stream: IO[str]
generator: Iterator[_TokenInfo]
first: Dict[str, Dict[str, int]]
first: dict[str, dict[str, int]]
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_first(self, c: PgenGrammar, name: str) -> dict[int, int]: ...
def make_label(self, c: PgenGrammar, label: str) -> int: ...
def addfirstsets(self) -> None: ...
def calcfirst(self, name: str) -> None: ...
def parse(self) -> Tuple[Dict[str, List[DFAState]], str]: ...
def make_dfa(self, start: NFAState, finish: NFAState) -> List[DFAState]: ...
def dump_nfa(self, name: str, start: NFAState, finish: NFAState) -> List[DFAState]: ...
def parse(self) -> Tuple[dict[str, list[DFAState]], str]: ...
def make_dfa(self, start: NFAState, finish: NFAState) -> list[DFAState]: ...
def dump_nfa(self, name: str, start: NFAState, finish: NFAState) -> list[DFAState]: ...
def dump_dfa(self, name: str, dfa: Iterable[DFAState]) -> None: ...
def simplify_dfa(self, dfa: List[DFAState]) -> None: ...
def simplify_dfa(self, dfa: list[DFAState]) -> None: ...
def parse_rhs(self) -> Tuple[NFAState, NFAState]: ...
def parse_alt(self) -> Tuple[NFAState, NFAState]: ...
def parse_item(self) -> Tuple[NFAState, NFAState]: ...
@@ -30,15 +30,15 @@ class ParserGenerator:
def raise_error(self, msg: str, *args: Any) -> NoReturn: ...
class NFAState:
arcs: List[Tuple[str | None, NFAState]]
arcs: list[Tuple[str | None, NFAState]]
def __init__(self) -> None: ...
def addarc(self, next: NFAState, label: str | None = ...) -> None: ...
class DFAState:
nfaset: Dict[NFAState, Any]
nfaset: dict[NFAState, Any]
isfinal: bool
arcs: Dict[str, DFAState]
def __init__(self, nfaset: Dict[NFAState, Any], final: NFAState) -> None: ...
arcs: dict[str, DFAState]
def __init__(self, nfaset: dict[NFAState, Any], final: NFAState) -> None: ...
def addarc(self, next: DFAState, label: str) -> None: ...
def unifystate(self, old: DFAState, new: DFAState) -> None: ...
def __eq__(self, other: Any) -> bool: ...

View File

@@ -1,5 +1,3 @@
from typing import Dict
ENDMARKER: int
NAME: int
NUMBER: int
@@ -61,7 +59,7 @@ ASYNC: int
ERRORTOKEN: int
N_TOKENS: int
NT_OFFSET: int
tok_name: Dict[int, str]
tok_name: dict[int, str]
def ISTERMINAL(x: int) -> bool: ...
def ISNONTERMINAL(x: int) -> bool: ...

View File

@@ -1,5 +1,5 @@
from lib2to3.pgen2.token import * # noqa
from typing import Callable, Iterable, Iterator, List, Tuple
from typing import Callable, Iterable, Iterator, Tuple
_Coord = Tuple[int, int]
_TokenEater = Callable[[int, str, _Coord, _Coord, str], None]
@@ -11,7 +11,7 @@ class StopTokenizing(Exception): ...
def tokenize(readline: Callable[[], str], tokeneater: _TokenEater = ...) -> None: ...
class Untokenizer:
tokens: List[str]
tokens: list[str]
prev_row: int
prev_col: int
def __init__(self) -> None: ...

View File

@@ -16,7 +16,7 @@ class Base:
type: int
parent: Node | None
prefix: str
children: List[_NL]
children: list[_NL]
was_changed: bool
was_checked: bool
def __eq__(self, other: Any) -> bool: ...
@@ -24,7 +24,7 @@ class Base:
def clone(self: _P) -> _P: ...
def post_order(self) -> Iterator[_NL]: ...
def pre_order(self) -> Iterator[_NL]: ...
def replace(self, new: _NL | List[_NL]) -> None: ...
def replace(self, new: _NL | list[_NL]) -> None: ...
def get_lineno(self) -> int: ...
def changed(self) -> None: ...
def remove(self) -> int | None: ...
@@ -37,14 +37,14 @@ class Base:
def get_suffix(self) -> str: ...
class Node(Base):
fixers_applied: List[Any]
fixers_applied: list[Any]
def __init__(
self,
type: int,
children: List[_NL],
children: list[_NL],
context: Any | None = ...,
prefix: str | None = ...,
fixers_applied: List[Any] | None = ...,
fixers_applied: list[Any] | None = ...,
) -> None: ...
def set_child(self, i: int, child: _NL) -> None: ...
def insert_child(self, i: int, child: _NL) -> None: ...
@@ -54,9 +54,9 @@ class Leaf(Base):
lineno: int
column: int
value: str
fixers_applied: List[Any]
fixers_applied: list[Any]
def __init__(
self, type: int, value: str, context: _Context | None = ..., prefix: str | None = ..., fixers_applied: List[Any] = ...
self, type: int, value: str, context: _Context | None = ..., prefix: str | None = ..., fixers_applied: list[Any] = ...
) -> None: ...
def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ...
@@ -67,8 +67,8 @@ class BasePattern:
name: str | None
def optimize(self) -> BasePattern: ... # sic, subclasses are free to optimize themselves into different patterns
def match(self, node: _NL, results: _Results | None = ...) -> bool: ...
def match_seq(self, nodes: List[_NL], results: _Results | None = ...) -> bool: ...
def generate_matches(self, nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ...
def match_seq(self, nodes: list[_NL], results: _Results | None = ...) -> bool: ...
def generate_matches(self, nodes: list[_NL]) -> Iterator[Tuple[int, _Results]]: ...
class LeafPattern(BasePattern):
def __init__(self, type: int | None = ..., content: str | None = ..., name: str | None = ...) -> None: ...
@@ -85,4 +85,4 @@ class WildcardPattern(BasePattern):
class NegatedPattern(BasePattern):
def __init__(self, content: str | None = ...) -> None: ...
def generate_matches(patterns: List[BasePattern], nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ...
def generate_matches(patterns: list[BasePattern], nodes: list[_NL]) -> Iterator[Tuple[int, _Results]]: ...