use _typeshed's Path aliases (#4214)

This commit is contained in:
Jelle Zijlstra
2020-06-10 20:57:09 -07:00
committed by GitHub
parent 86f03f2d7b
commit 43e93f803f
42 changed files with 483 additions and 757 deletions
-10
View File
@@ -1,10 +0,0 @@
# Stubs for lib2to3.pgen2 (Python 3.6)
import os
import sys
from typing import Text, Union
if sys.version_info >= (3, 6):
_Path = Union[Text, os.PathLike]
else:
_Path = Text
+3 -7
View File
@@ -1,12 +1,8 @@
# Stubs for lib2to3.pgen2.driver (Python 3.6)
import os
import sys
from typing import Any, Callable, IO, Iterable, List, Optional, Text, Tuple, Union
from _typeshed import StrPath
from typing import Any, IO, Iterable, Optional, Text
from logging import Logger
from lib2to3.pytree import _Convert, _NL
from lib2to3.pgen2 import _Path
from lib2to3.pgen2.grammar import Grammar
@@ -18,7 +14,7 @@ class Driver:
def parse_tokens(self, tokens: Iterable[Any], debug: bool = ...) -> _NL: ...
def parse_stream_raw(self, stream: IO[Text], debug: bool = ...) -> _NL: ...
def parse_stream(self, stream: IO[Text], debug: bool = ...) -> _NL: ...
def parse_file(self, filename: _Path, encoding: Optional[Text] = ..., debug: bool = ...) -> _NL: ...
def parse_file(self, filename: StrPath, encoding: Optional[Text] = ..., debug: bool = ...) -> _NL: ...
def parse_string(self, text: Text, debug: bool = ...) -> _NL: ...
def load_grammar(gt: Text = ..., gp: Optional[Text] = ..., save: bool = ..., force: bool = ..., logger: Optional[Logger] = ...) -> Grammar: ...
+4 -7
View File
@@ -1,8 +1,5 @@
# Stubs for lib2to3.pgen2.grammar (Python 3.6)
from lib2to3.pgen2 import _Path
from typing import Any, Dict, List, Optional, Text, Tuple, TypeVar
from _typeshed import StrPath
from typing import Dict, List, Optional, Text, Tuple, TypeVar
_P = TypeVar('_P')
_Label = Tuple[int, Optional[Text]]
@@ -20,8 +17,8 @@ class Grammar:
symbol2label: Dict[Text, int]
start: int
def __init__(self) -> None: ...
def dump(self, filename: _Path) -> None: ...
def load(self, filename: _Path) -> None: ...
def dump(self, filename: StrPath) -> None: ...
def load(self, filename: StrPath) -> None: ...
def copy(self: _P) -> _P: ...
def report(self) -> None: ...
+5 -6
View File
@@ -1,20 +1,19 @@
# Stubs for lib2to3.pgen2.pgen (Python 3.6)
from _typeshed import StrPath
from typing import (
Any, Dict, IO, Iterable, Iterator, List, NoReturn, Optional, Text, Tuple
)
from lib2to3.pgen2 import _Path, grammar
from lib2to3.pgen2 import grammar
from lib2to3.pgen2.tokenize import _TokenInfo
class PgenGrammar(grammar.Grammar): ...
class ParserGenerator:
filename: _Path
filename: StrPath
stream: IO[Text]
generator: Iterator[_TokenInfo]
first: Dict[Text, Dict[Text, int]]
def __init__(self, filename: _Path, stream: Optional[IO[Text]] = ...) -> None: ...
def __init__(self, filename: StrPath, stream: Optional[IO[Text]] = ...) -> None: ...
def make_grammar(self) -> PgenGrammar: ...
def make_first(self, c: PgenGrammar, name: Text) -> Dict[int, int]: ...
def make_label(self, c: PgenGrammar, label: Text) -> int: ...
@@ -47,4 +46,4 @@ class DFAState:
def unifystate(self, old: DFAState, new: DFAState) -> None: ...
def __eq__(self, other: Any) -> bool: ...
def generate_grammar(filename: _Path = ...) -> PgenGrammar: ...
def generate_grammar(filename: StrPath = ...) -> PgenGrammar: ...