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

View File

@@ -1,14 +1,10 @@
import io
import sys
from os.path import _PathType
from typing import IO, Any, Optional, TextIO, Union, overload, TypeVar
from _typeshed import AnyPath
from typing_extensions import Literal
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
_PathOrFile = Union[_PathType, IO[bytes]]
_PathOrFile = Union[AnyPath, IO[bytes]]
_T = TypeVar("_T")
def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
@@ -28,7 +24,7 @@ if sys.version_info >= (3, 3):
) -> BZ2File: ...
@overload
def open(
filename: _PathType,
filename: AnyPath,
mode: _OpenTextMode,
compresslevel: int = ...,
encoding: Optional[str] = ...,

View File

@@ -1,23 +1,19 @@
import os
import sys
from typing import Any, Callable, Dict, Optional, Text, TypeVar, Union
from _typeshed import AnyPath
from typing import Any, Callable, Dict, Optional, TypeVar, Union
def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ...
def runctx(statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ...
_SelfT = TypeVar('_SelfT', bound=Profile)
_T = TypeVar('_T')
if sys.version_info >= (3, 6):
_Path = Union[bytes, Text, os.PathLike[Any]]
else:
_Path = Union[bytes, Text]
class Profile:
def __init__(self, timer: Callable[[], float] = ..., timeunit: float = ..., subcalls: bool = ..., builtins: bool = ...) -> None: ...
def enable(self) -> None: ...
def disable(self) -> None: ...
def print_stats(self, sort: Union[str, int] = ...) -> None: ...
def dump_stats(self, file: _Path) -> None: ...
def dump_stats(self, file: AnyPath) -> None: ...
def create_stats(self) -> None: ...
def snapshot_stats(self) -> None: ...
def run(self: _SelfT, cmd: str) -> _SelfT: ...

View File

@@ -1,17 +1,8 @@
from typing import Dict, Any, List, Tuple, Optional, Callable, Type, Union, IO, AnyStr, TypeVar
from typing import Dict, Any, List, Tuple, Optional, Callable, Type, IO
from types import FrameType, TracebackType
import sys
from _typeshed import AnyPath
_T = TypeVar("_T")
_ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]]
if sys.version_info >= (3, 6):
from os import PathLike
_Path = Union[_T, PathLike[_T]]
else:
_Path = Union[_T]
def reset() -> str: ... # undocumented
def small(text: str) -> str: ... # undocumented
@@ -23,11 +14,10 @@ def html(einfo: _ExcInfo, context: int = ...) -> str: ...
def text(einfo: _ExcInfo, context: int = ...) -> str: ...
class Hook: # undocumented
def __init__(self, display: int = ..., logdir: Optional[_Path[AnyStr]] = ..., context: int = ..., file: Optional[IO[str]] = ..., format: str = ...) -> None: ...
def __init__(self, display: int = ..., logdir: Optional[AnyPath] = ..., context: int = ..., file: Optional[IO[str]] = ..., format: str = ...) -> None: ...
def __call__(self, etype: Optional[Type[BaseException]], evalue: Optional[BaseException], etb: Optional[TracebackType]) -> None: ...
def handle(self, info: Optional[_ExcInfo] = ...) -> None: ...
def handler(info: Optional[_ExcInfo] = ...) -> None: ...
def enable(display: int = ..., logdir: Optional[_Path[AnyStr]] = ..., context: int = ..., format: str = ...) -> None: ...
def enable(display: int = ..., logdir: Optional[AnyPath] = ..., context: int = ..., format: str = ...) -> None: ...

View File

@@ -1,30 +1,24 @@
from typing import Iterable, Callable, IO, AnyStr, Generic, Any, Text, Union, Iterator, Optional
import os
from typing import Iterable, Callable, IO, AnyStr, Generic, Any, Union, Iterator, Optional
from _typeshed import AnyPath
import sys
if sys.version_info >= (3, 6):
_Path = Union[Text, bytes, os.PathLike[Any]]
else:
_Path = Union[Text, bytes]
if sys.version_info >= (3, 8):
def input(
files: Union[_Path, Iterable[_Path], None] = ...,
files: Union[AnyPath, Iterable[AnyPath], None] = ...,
inplace: bool = ...,
backup: str = ...,
*,
mode: str = ...,
openhook: Callable[[_Path, str], IO[AnyStr]] = ...,
openhook: Callable[[AnyPath, str], IO[AnyStr]] = ...,
) -> FileInput[AnyStr]: ...
else:
def input(
files: Union[_Path, Iterable[_Path], None] = ...,
files: Union[AnyPath, Iterable[AnyPath], None] = ...,
inplace: bool = ...,
backup: str = ...,
bufsize: int = ...,
mode: str = ...,
openhook: Callable[[_Path, str], IO[AnyStr]] = ...,
openhook: Callable[[AnyPath, str], IO[AnyStr]] = ...,
) -> FileInput[AnyStr]: ...
def close() -> None: ...
@@ -40,22 +34,22 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]):
if sys.version_info >= (3, 8):
def __init__(
self,
files: Union[None, _Path, Iterable[_Path]] = ...,
files: Union[None, AnyPath, Iterable[AnyPath]] = ...,
inplace: bool = ...,
backup: str = ...,
*,
mode: str = ...,
openhook: Callable[[_Path, str], IO[AnyStr]] = ...
openhook: Callable[[AnyPath, str], IO[AnyStr]] = ...
) -> None: ...
else:
def __init__(
self,
files: Union[None, _Path, Iterable[_Path]] = ...,
files: Union[None, AnyPath, Iterable[AnyPath]] = ...,
inplace: bool = ...,
backup: str = ...,
bufsize: int = ...,
mode: str = ...,
openhook: Callable[[_Path, str], IO[AnyStr]] = ...
openhook: Callable[[AnyPath, str], IO[AnyStr]] = ...
) -> None: ...
def __del__(self) -> None: ...
@@ -75,8 +69,8 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]):
def isfirstline(self) -> bool: ...
def isstdin(self) -> bool: ...
def hook_compressed(filename: _Path, mode: str) -> IO[Any]: ...
def hook_compressed(filename: AnyPath, mode: str) -> IO[Any]: ...
if sys.version_info >= (3, 6):
def hook_encoded(encoding: str, errors: Optional[str] = ...) -> Callable[[_Path, str], IO[Any]]: ...
def hook_encoded(encoding: str, errors: Optional[str] = ...) -> Callable[[AnyPath, str], IO[Any]]: ...
else:
def hook_encoded(encoding: str) -> Callable[[_Path, str], IO[Any]]: ...
def hook_encoded(encoding: str) -> Callable[[AnyPath, str], IO[Any]]: ...

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

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: ...

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: ...

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: ...

View File

@@ -1,5 +1,4 @@
# Stubs for logging (Python 3.7)
from _typeshed import StrPath
from typing import (
Any, Callable, Dict, Iterable, List, Mapping, MutableMapping, Optional, IO,
Sequence, Tuple, Text, Union, overload,
@@ -19,11 +18,6 @@ else:
_ArgsType = Union[Tuple[Any, ...], Mapping[str, Any]]
_FilterType = Union[Filter, Callable[[LogRecord], int]]
_Level = Union[int, Text]
if sys.version_info >= (3, 6):
from os import PathLike
_Path = Union[str, PathLike[str]]
else:
_Path = str
raiseExceptions: bool
logThreads: bool
@@ -474,12 +468,12 @@ def getLevelName(level: Union[int, str]) -> Any: ...
def makeLogRecord(dict: Mapping[str, Any]) -> LogRecord: ...
if sys.version_info >= (3, 8):
def basicConfig(*, filename: Optional[_Path] = ..., filemode: str = ...,
def basicConfig(*, filename: Optional[StrPath] = ..., filemode: str = ...,
format: str = ..., datefmt: Optional[str] = ..., style: str = ...,
level: Optional[_Level] = ..., stream: Optional[IO[str]] = ...,
handlers: Optional[Iterable[Handler]] = ..., force: bool = ...) -> None: ...
elif sys.version_info >= (3,):
def basicConfig(*, filename: Optional[_Path] = ..., filemode: str = ...,
def basicConfig(*, filename: Optional[StrPath] = ..., filemode: str = ...,
format: str = ..., datefmt: Optional[str] = ..., style: str = ...,
level: Optional[_Level] = ..., stream: Optional[IO[str]] = ...,
handlers: Optional[Iterable[Handler]] = ...) -> None: ...
@@ -518,7 +512,7 @@ class FileHandler(StreamHandler):
mode: str # undocumented
encoding: Optional[str] # undocumented
delay: bool # undocumented
def __init__(self, filename: _Path, mode: str = ...,
def __init__(self, filename: StrPath, mode: str = ...,
encoding: Optional[str] = ..., delay: bool = ...) -> None: ...
def _open(self) -> IO[Any]: ...

View File

@@ -1,5 +1,4 @@
# Stubs for logging.config (Python 3.4)
from _typeshed import AnyPath, StrPath
from typing import Any, Callable, Dict, Optional, IO, Union
from threading import Thread
import sys
@@ -7,15 +6,11 @@ if sys.version_info >= (3,):
from configparser import RawConfigParser
else:
from ConfigParser import RawConfigParser
if sys.version_info >= (3, 6):
from os import PathLike
if sys.version_info >= (3, 7):
_Path = Union[str, bytes, PathLike[str]]
elif sys.version_info >= (3, 6):
_Path = Union[str, PathLike[str]]
_Path = AnyPath
else:
_Path = str
_Path = StrPath
def dictConfig(config: Dict[str, Any]) -> None: ...

View File

@@ -1,5 +1,4 @@
# Stubs for logging.handlers (Python 2.4)
from _typeshed import StrPath
import datetime
from logging import Handler, FileHandler, LogRecord
from socket import SocketType
@@ -15,11 +14,6 @@ else:
# TODO update socket stubs to add SocketKind
_SocketKind = int
if sys.version_info >= (3, 6):
from os import PathLike
_Path = Union[str, PathLike[str]]
else:
_Path = str
DEFAULT_TCP_LOGGING_PORT: int
DEFAULT_UDP_LOGGING_PORT: int
@@ -31,7 +25,7 @@ SYSLOG_TCP_PORT: int
class WatchedFileHandler(FileHandler):
dev: int
ino: int
def __init__(self, filename: _Path, mode: str = ..., encoding: Optional[str] = ...,
def __init__(self, filename: StrPath, mode: str = ..., encoding: Optional[str] = ...,
delay: bool = ...) -> None: ...
def _statstream(self) -> None: ...
@@ -41,7 +35,7 @@ if sys.version_info >= (3,):
terminator: str
namer: Optional[Callable[[str], str]]
rotator: Optional[Callable[[str, str], None]]
def __init__(self, filename: _Path, mode: str,
def __init__(self, filename: StrPath, mode: str,
encoding: Optional[str] = ...,
delay: bool = ...) -> None: ...
def rotation_filename(self, default_name: str) -> None: ...
@@ -50,7 +44,7 @@ if sys.version_info >= (3,):
if sys.version_info >= (3,):
class RotatingFileHandler(BaseRotatingHandler):
def __init__(self, filename: _Path, mode: str = ..., maxBytes: int = ...,
def __init__(self, filename: StrPath, mode: str = ..., maxBytes: int = ...,
backupCount: int = ..., encoding: Optional[str] = ...,
delay: bool = ...) -> None: ...
def doRollover(self) -> None: ...
@@ -65,7 +59,7 @@ else:
if sys.version_info >= (3,):
class TimedRotatingFileHandler(BaseRotatingHandler):
if sys.version_info >= (3, 4):
def __init__(self, filename: _Path, when: str = ...,
def __init__(self, filename: StrPath, when: str = ...,
interval: int = ...,
backupCount: int = ..., encoding: Optional[str] = ...,
delay: bool = ..., utc: bool = ...,

View File

@@ -4,19 +4,13 @@
import os
import sys
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional
from _typeshed import StrPath, BytesPath, AnyPath
if sys.version_info < (3, 8):
_T = TypeVar('_T')
if sys.version_info >= (3, 6):
from builtins import _PathLike
_PathType = Union[bytes, Text, _PathLike]
_StrPath = Union[Text, _PathLike[Text]]
_BytesPath = Union[bytes, _PathLike[bytes]]
else:
_PathType = Union[bytes, Text]
_StrPath = Text
_BytesPath = bytes
# ----- os.path variables -----
supports_unicode_filenames: bool
@@ -79,26 +73,26 @@ if sys.version_info < (3, 8):
# NOTE: Empty lists results in '' (str) regardless of contained type.
# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes
# So, fall back to Any
def commonprefix(m: Sequence[_PathType]) -> Any: ...
def commonprefix(m: Sequence[AnyPath]) -> Any: ...
if sys.version_info >= (3, 3):
def exists(path: Union[_PathType, int]) -> bool: ...
def exists(path: Union[AnyPath, int]) -> bool: ...
else:
def exists(path: _PathType) -> bool: ...
def lexists(path: _PathType) -> bool: ...
def exists(path: AnyPath) -> bool: ...
def lexists(path: AnyPath) -> bool: ...
# These return float if os.stat_float_times() == True,
# but int is a subclass of float.
def getatime(filename: _PathType) -> float: ...
def getmtime(filename: _PathType) -> float: ...
def getctime(filename: _PathType) -> float: ...
def getatime(filename: AnyPath) -> float: ...
def getmtime(filename: AnyPath) -> float: ...
def getctime(filename: AnyPath) -> float: ...
def getsize(filename: _PathType) -> int: ...
def isabs(s: _PathType) -> bool: ...
def isfile(path: _PathType) -> bool: ...
def isdir(s: _PathType) -> bool: ...
def islink(s: _PathType) -> bool: ...
def ismount(s: _PathType) -> bool: ...
def getsize(filename: AnyPath) -> int: ...
def isabs(s: AnyPath) -> bool: ...
def isfile(path: AnyPath) -> bool: ...
def isdir(s: AnyPath) -> bool: ...
def islink(s: AnyPath) -> bool: ...
def ismount(s: AnyPath) -> bool: ...
if sys.version_info < (3, 0):
# Make sure signatures are disjunct, and allow combinations of bytes and unicode.
@@ -108,23 +102,23 @@ if sys.version_info < (3, 8):
@overload
def join(__p1: bytes, *p: bytes) -> bytes: ...
@overload
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ...
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ...
@overload
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ...
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ...
@overload
def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ...
def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ...
@overload
def join(__p1: Text, *p: _PathType) -> Text: ...
def join(__p1: Text, *p: AnyPath) -> Text: ...
elif sys.version_info >= (3, 6):
# Mypy complains that the signatures overlap, but things seem to behave correctly anyway.
@overload
def join(s: _StrPath, *paths: _StrPath) -> Text: ...
def join(s: StrPath, *paths: StrPath) -> Text: ...
@overload
def join(s: _BytesPath, *paths: _BytesPath) -> bytes: ...
def join(s: BytesPath, *paths: BytesPath) -> bytes: ...
else:
def join(s: AnyStr, *paths: AnyStr) -> AnyStr: ...
def samefile(f1: _PathType, f2: _PathType) -> bool: ...
def samefile(f1: AnyPath, f2: AnyPath) -> bool: ...
def sameopenfile(fp1: int, fp2: int) -> bool: ...
def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ...

View File

@@ -1,19 +1,8 @@
from typing import Optional, Union, Text, AnyStr, Callable, IO, Any, Iterator, List, Tuple, TypeVar, Protocol, Dict, Sequence, Iterable, Generic, Type, Mapping, overload
from types import TracebackType
import sys
import email
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if sys.version_info >= (3, 6):
from builtins import _PathLike
_PathType = Union[bytes, Text, _PathLike]
else:
_PathType = Union[bytes, Text]
from _typeshed import AnyPath
from typing_extensions import Literal
_T = TypeVar("_T")
_MessageType = TypeVar("_MessageType", bound=Message)
@@ -32,7 +21,7 @@ class Mailbox(Generic[_MessageType]):
_path: Union[bytes, str] # undocumented
_factory: Optional[Callable[[IO[Any]], _MessageType]] # undocumented
def __init__(self, path: _PathType, factory: Optional[Callable[[IO[Any]], _MessageType]] = ..., create: bool = ...) -> None: ...
def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], _MessageType]] = ..., create: bool = ...) -> None: ...
def add(self, message: _MessageData) -> str: ...
def remove(self, key: str) -> None: ...
def __delitem__(self, key: str) -> None: ...
@@ -73,7 +62,7 @@ class Maildir(Mailbox[MaildirMessage]):
colon: str
def __init__(self, dirname: _PathType, factory: Optional[Callable[[IO[Any]], MaildirMessage]] = ..., create: bool = ...) -> None: ...
def __init__(self, dirname: AnyPath, factory: Optional[Callable[[IO[Any]], MaildirMessage]] = ..., create: bool = ...) -> None: ...
def get_file(self, key: str) -> _ProxyFile[bytes]: ...
def list_folders(self) -> List[str]: ...
@@ -91,28 +80,28 @@ class _mboxMMDF(_singlefileMailbox[_MessageType]):
class mbox(_mboxMMDF[mboxMessage]):
def __init__(self, dirname: _PathType, factory: Optional[Callable[[IO[Any]], mboxMessage]] = ..., create: bool = ...) -> None: ...
def __init__(self, dirname: AnyPath, factory: Optional[Callable[[IO[Any]], mboxMessage]] = ..., create: bool = ...) -> None: ...
class MMDF(_mboxMMDF[MMDFMessage]):
def __init__(self, dirname: _PathType, factory: Optional[Callable[[IO[Any]], MMDFMessage]] = ..., create: bool = ...) -> None: ...
def __init__(self, dirname: AnyPath, factory: Optional[Callable[[IO[Any]], MMDFMessage]] = ..., create: bool = ...) -> None: ...
class MH(Mailbox[MHMessage]):
def __init__(self, dirname: _PathType, factory: Optional[Callable[[IO[Any]], MHMessage]] = ..., create: bool = ...) -> None: ...
def __init__(self, dirname: AnyPath, factory: Optional[Callable[[IO[Any]], MHMessage]] = ..., create: bool = ...) -> None: ...
def get_file(self, key: str) -> _ProxyFile[bytes]: ...
def list_folders(self) -> List[str]: ...
def get_folder(self, folder: _PathType) -> MH: ...
def add_folder(self, folder: _PathType) -> MH: ...
def remove_folder(self, folder: _PathType) -> None: ...
def get_folder(self, folder: AnyPath) -> MH: ...
def add_folder(self, folder: AnyPath) -> MH: ...
def remove_folder(self, folder: AnyPath) -> None: ...
def get_sequences(self) -> Dict[str, List[int]]: ...
def set_sequences(self, sequences: Mapping[str, Sequence[int]]) -> None: ...
def pack(self) -> None: ...
class Babyl(_singlefileMailbox[BabylMessage]):
def __init__(self, dirname: _PathType, factory: Optional[Callable[[IO[Any]], BabylMessage]] = ..., create: bool = ...) -> None: ...
def __init__(self, dirname: AnyPath, factory: Optional[Callable[[IO[Any]], BabylMessage]] = ..., create: bool = ...) -> None: ...
def get_file(self, key: str) -> IO[bytes]: ...
def get_labels(self) -> List[str]: ...

View File

@@ -1,23 +1,14 @@
# NB: path.pyi and stdlib/2 and stdlib/3 must remain consistent!
# Stubs for os.path
# Ron Murawski <ron@horizonchess.com>
import os
import sys
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Text, Callable, Optional
from genericpath import exists as exists
from _typeshed import StrPath, BytesPath, AnyPath
_T = TypeVar('_T')
if sys.version_info >= (3, 6):
from builtins import _PathLike
_PathType = Union[bytes, Text, _PathLike]
_StrPath = Union[Text, _PathLike[Text]]
_BytesPath = Union[bytes, _PathLike[bytes]]
else:
_PathType = Union[bytes, Text]
_StrPath = Text
_BytesPath = bytes
# ----- os.path variables -----
supports_unicode_filenames: bool
@@ -90,31 +81,31 @@ else:
def realpath(filename: AnyStr) -> AnyStr: ...
if sys.version_info >= (3, 6):
# In reality it returns str for sequences of _StrPath and bytes for sequences
# of _BytesPath, but mypy does not accept such a signature.
def commonpath(paths: Sequence[_PathType]) -> Any: ...
# In reality it returns str for sequences of StrPath and bytes for sequences
# of BytesPath, but mypy does not accept such a signature.
def commonpath(paths: Sequence[AnyPath]) -> Any: ...
elif sys.version_info >= (3, 5):
def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ...
# NOTE: Empty lists results in '' (str) regardless of contained type.
# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes
# So, fall back to Any
def commonprefix(m: Sequence[_PathType]) -> Any: ...
def commonprefix(m: Sequence[AnyPath]) -> Any: ...
def lexists(path: _PathType) -> bool: ...
def lexists(path: AnyPath) -> bool: ...
# These return float if os.stat_float_times() == True,
# but int is a subclass of float.
def getatime(filename: _PathType) -> float: ...
def getmtime(filename: _PathType) -> float: ...
def getctime(filename: _PathType) -> float: ...
def getatime(filename: AnyPath) -> float: ...
def getmtime(filename: AnyPath) -> float: ...
def getctime(filename: AnyPath) -> float: ...
def getsize(filename: _PathType) -> int: ...
def isabs(s: _PathType) -> bool: ...
def isfile(path: _PathType) -> bool: ...
def isdir(s: _PathType) -> bool: ...
def islink(path: _PathType) -> bool: ...
def ismount(path: _PathType) -> bool: ...
def getsize(filename: AnyPath) -> int: ...
def isabs(s: AnyPath) -> bool: ...
def isfile(path: AnyPath) -> bool: ...
def isdir(s: AnyPath) -> bool: ...
def islink(path: AnyPath) -> bool: ...
def ismount(path: AnyPath) -> bool: ...
if sys.version_info < (3, 0):
# Make sure signatures are disjunct, and allow combinations of bytes and unicode.
@@ -124,28 +115,27 @@ if sys.version_info < (3, 0):
@overload
def join(__p1: bytes, *p: bytes) -> bytes: ...
@overload
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ...
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ...
@overload
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ...
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ...
@overload
def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ...
def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ...
@overload
def join(__p1: Text, *p: _PathType) -> Text: ...
def join(__p1: Text, *p: AnyPath) -> Text: ...
elif sys.version_info >= (3, 6):
# Mypy complains that the signatures overlap (same for relpath below), but things seem to behave correctly anyway.
@overload
def join(a: _StrPath, *paths: _StrPath) -> Text: ...
def join(a: StrPath, *paths: StrPath) -> Text: ...
@overload
def join(a: _BytesPath, *paths: _BytesPath) -> bytes: ...
def join(a: BytesPath, *paths: BytesPath) -> bytes: ...
else:
def join(a: AnyStr, *paths: AnyStr) -> AnyStr: ...
@overload
def relpath(path: _BytesPath, start: Optional[_BytesPath] = ...) -> bytes: ...
def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ...
@overload
def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ...
def relpath(path: StrPath, start: Optional[StrPath] = ...) -> Text: ...
def samefile(f1: _PathType, f2: _PathType) -> bool: ...
def samefile(f1: AnyPath, f2: AnyPath) -> bool: ...
def sameopenfile(fp1: int, fp2: int) -> bool: ...
def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ...

View File

@@ -1,13 +1,6 @@
from typing import Any, List, Sequence, Text, Tuple, Union
from typing import Any, List, Sequence, Text, Tuple
from types import CodeType
import sys
if sys.version_info >= (3, 6):
from builtins import _PathLike
_Path = Union[str, bytes, _PathLike]
else:
_Path = Union[str, bytes]
from _typeshed import AnyPath
def expr(source: Text) -> STType: ...
def suite(source: Text) -> STType: ...
@@ -15,14 +8,14 @@ def sequence2st(sequence: Sequence[Any]) -> STType: ...
def tuple2st(sequence: Sequence[Any]) -> STType: ...
def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> List[Any]: ...
def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any]: ...
def compilest(st: STType, filename: _Path = ...) -> CodeType: ...
def compilest(st: STType, filename: AnyPath = ...) -> CodeType: ...
def isexpr(st: STType) -> bool: ...
def issuite(st: STType) -> bool: ...
class ParserError(Exception): ...
class STType:
def compile(self, filename: _Path = ...) -> CodeType: ...
def compile(self, filename: AnyPath = ...) -> CodeType: ...
def isexpr(self) -> bool: ...
def issuite(self) -> bool: ...
def tolist(self, line_info: bool = ..., col_info: bool = ...) -> List[Any]: ...

View File

@@ -1,8 +1,6 @@
# Stubs for plistlib
from typing import (
Any, IO, Mapping, MutableMapping, Optional, overload, Union,
Type, TypeVar,
Type, TypeVar, Text
)
from typing import Dict as DictT
import sys
@@ -17,10 +15,7 @@ if sys.version_info >= (3,):
mm = MutableMapping[str, Any]
_D = TypeVar('_D', bound=mm)
if sys.version_info >= (3,):
_Path = str
else:
_Path = Union[str, unicode]
_Path = Union[str, Text]
if sys.version_info >= (3, 9):
@overload

View File

@@ -1,23 +1,14 @@
# NB: path.pyi and stdlib/2 and stdlib/3 must remain consistent!
# Stubs for os.path
# Ron Murawski <ron@horizonchess.com>
import os
import sys
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Text, Callable, Optional
from genericpath import exists as exists
from _typeshed import StrPath, BytesPath, AnyPath
_T = TypeVar('_T')
if sys.version_info >= (3, 6):
from builtins import _PathLike
_PathType = Union[bytes, Text, _PathLike]
_StrPath = Union[Text, _PathLike[Text]]
_BytesPath = Union[bytes, _PathLike[bytes]]
else:
_PathType = Union[bytes, Text]
_StrPath = Text
_BytesPath = bytes
# ----- os.path variables -----
supports_unicode_filenames: bool
@@ -90,31 +81,31 @@ else:
def realpath(filename: AnyStr) -> AnyStr: ...
if sys.version_info >= (3, 6):
# In reality it returns str for sequences of _StrPath and bytes for sequences
# of _BytesPath, but mypy does not accept such a signature.
def commonpath(paths: Sequence[_PathType]) -> Any: ...
# In reality it returns str for sequences of StrPath and bytes for sequences
# of BytesPath, but mypy does not accept such a signature.
def commonpath(paths: Sequence[AnyPath]) -> Any: ...
elif sys.version_info >= (3, 5):
def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ...
# NOTE: Empty lists results in '' (str) regardless of contained type.
# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes
# So, fall back to Any
def commonprefix(m: Sequence[_PathType]) -> Any: ...
def commonprefix(m: Sequence[AnyPath]) -> Any: ...
def lexists(path: _PathType) -> bool: ...
def lexists(path: AnyPath) -> bool: ...
# These return float if os.stat_float_times() == True,
# but int is a subclass of float.
def getatime(filename: _PathType) -> float: ...
def getmtime(filename: _PathType) -> float: ...
def getctime(filename: _PathType) -> float: ...
def getatime(filename: AnyPath) -> float: ...
def getmtime(filename: AnyPath) -> float: ...
def getctime(filename: AnyPath) -> float: ...
def getsize(filename: _PathType) -> int: ...
def isabs(s: _PathType) -> bool: ...
def isfile(path: _PathType) -> bool: ...
def isdir(s: _PathType) -> bool: ...
def islink(path: _PathType) -> bool: ...
def ismount(path: _PathType) -> bool: ...
def getsize(filename: AnyPath) -> int: ...
def isabs(s: AnyPath) -> bool: ...
def isfile(path: AnyPath) -> bool: ...
def isdir(s: AnyPath) -> bool: ...
def islink(path: AnyPath) -> bool: ...
def ismount(path: AnyPath) -> bool: ...
if sys.version_info < (3, 0):
# Make sure signatures are disjunct, and allow combinations of bytes and unicode.
@@ -124,28 +115,27 @@ if sys.version_info < (3, 0):
@overload
def join(__p1: bytes, *p: bytes) -> bytes: ...
@overload
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ...
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ...
@overload
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ...
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ...
@overload
def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ...
def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ...
@overload
def join(__p1: Text, *p: _PathType) -> Text: ...
def join(__p1: Text, *p: AnyPath) -> Text: ...
elif sys.version_info >= (3, 6):
# Mypy complains that the signatures overlap (same for relpath below), but things seem to behave correctly anyway.
@overload
def join(a: _StrPath, *paths: _StrPath) -> Text: ...
def join(a: StrPath, *paths: StrPath) -> Text: ...
@overload
def join(a: _BytesPath, *paths: _BytesPath) -> bytes: ...
def join(a: BytesPath, *paths: BytesPath) -> bytes: ...
else:
def join(a: AnyStr, *paths: AnyStr) -> AnyStr: ...
@overload
def relpath(path: _BytesPath, start: Optional[_BytesPath] = ...) -> bytes: ...
def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ...
@overload
def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ...
def relpath(path: StrPath, start: Optional[StrPath] = ...) -> Text: ...
def samefile(f1: _PathType, f2: _PathType) -> bool: ...
def samefile(f1: AnyPath, f2: AnyPath) -> bool: ...
def sameopenfile(fp1: int, fp2: int) -> bool: ...
def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ...

View File

@@ -1,16 +1,11 @@
import os
import sys
from typing import Any, Callable, Dict, Optional, Text, TypeVar, Union
from _typeshed import AnyPath
from typing import Any, Callable, Dict, Optional, TypeVar, Union
def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ...
def runctx(statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ...
_SelfT = TypeVar('_SelfT', bound=Profile)
_T = TypeVar('_T')
if sys.version_info >= (3, 6):
_Path = Union[bytes, Text, os.PathLike[Any]]
else:
_Path = Union[bytes, Text]
class Profile:
bias: int
@@ -20,7 +15,7 @@ class Profile:
def simulate_call(self, name: str) -> None: ...
def simulate_cmd_complete(self) -> None: ...
def print_stats(self, sort: Union[str, int] = ...) -> None: ...
def dump_stats(self, file: _Path) -> None: ...
def dump_stats(self, file: AnyPath) -> None: ...
def create_stats(self) -> None: ...
def snapshot_stats(self) -> None: ...
def run(self: _SelfT, cmd: str) -> _SelfT: ...

View File

@@ -1,15 +1,10 @@
from profile import Profile
from cProfile import Profile as _cProfile
import os
import sys
from _typeshed import AnyPath
from typing import Any, Dict, IO, Iterable, List, Optional, Text, Tuple, TypeVar, Union, overload
_Selector = Union[str, float, int]
_T = TypeVar('_T', bound=Stats)
if sys.version_info >= (3, 6):
_Path = Union[bytes, Text, os.PathLike[Any]]
else:
_Path = Union[bytes, Text]
class Stats:
sort_arg_dict_default: Dict[str, Tuple[Any, str]]
@@ -20,7 +15,7 @@ class Stats:
def load_stats(self, arg: Union[None, str, Text, Profile, _cProfile]) -> None: ...
def get_top_level_stats(self) -> None: ...
def add(self: _T, *arg_list: Union[None, str, Text, Profile, _cProfile, _T]) -> _T: ...
def dump_stats(self, filename: _Path) -> None: ...
def dump_stats(self, filename: AnyPath) -> None: ...
def get_sort_arg_defs(self) -> Dict[str, Tuple[Tuple[Tuple[int, int], ...], str]]: ...
@overload
def sort_stats(self: _T, field: int) -> _T: ...

View File

@@ -6,24 +6,22 @@ import sys
# cases don't use them.
from typing import (
List, Iterable, Callable, Any, Tuple, Sequence, NamedTuple, IO,
List, Iterable, Callable, Any, Tuple, Sequence, NamedTuple,
AnyStr, Optional, Union, Set, TypeVar, overload, Type, Protocol, Text
)
from _typeshed import StrPath
if sys.version_info >= (3, 6):
_Path = Union[str, os.PathLike[str]]
_AnyStr = str
_AnyPath = TypeVar("_AnyPath", str, os.PathLike[str])
# Return value of some functions that may either return a path-like object that was passed in or
# a string
_PathReturn = Any
elif sys.version_info >= (3,):
_Path = str
_AnyStr = str
_AnyPath = str
_PathReturn = str
else:
_Path = Text
_AnyStr = TypeVar("_AnyStr", str, unicode)
_AnyPath = TypeVar("_AnyPath", str, unicode)
_PathReturn = Type[None]
@@ -53,40 +51,40 @@ def copyfileobj(fsrc: _Reader[AnyStr], fdst: _Writer[AnyStr],
length: int = ...) -> None: ...
if sys.version_info >= (3,):
def copyfile(src: _Path, dst: _AnyPath, *,
def copyfile(src: StrPath, dst: _AnyPath, *,
follow_symlinks: bool = ...) -> _AnyPath: ...
def copymode(src: _Path, dst: _Path, *,
def copymode(src: StrPath, dst: StrPath, *,
follow_symlinks: bool = ...) -> None: ...
def copystat(src: _Path, dst: _Path, *,
def copystat(src: StrPath, dst: StrPath, *,
follow_symlinks: bool = ...) -> None: ...
def copy(src: _Path, dst: _Path, *,
def copy(src: StrPath, dst: StrPath, *,
follow_symlinks: bool = ...) -> _PathReturn: ...
def copy2(src: _Path, dst: _Path, *,
def copy2(src: StrPath, dst: StrPath, *,
follow_symlinks: bool = ...) -> _PathReturn: ...
else:
def copyfile(src: _Path, dst: _Path) -> None: ...
def copymode(src: _Path, dst: _Path) -> None: ...
def copystat(src: _Path, dst: _Path) -> None: ...
def copy(src: _Path, dst: _Path) -> _PathReturn: ...
def copy2(src: _Path, dst: _Path) -> _PathReturn: ...
def copyfile(src: StrPath, dst: StrPath) -> None: ...
def copymode(src: StrPath, dst: StrPath) -> None: ...
def copystat(src: StrPath, dst: StrPath) -> None: ...
def copy(src: StrPath, dst: StrPath) -> _PathReturn: ...
def copy2(src: StrPath, dst: StrPath) -> _PathReturn: ...
def ignore_patterns(*patterns: _Path) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ...
def ignore_patterns(*patterns: StrPath) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ...
if sys.version_info >= (3, 8):
def copytree(
src: _Path,
dst: _Path,
src: StrPath,
dst: StrPath,
symlinks: bool = ...,
ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[_Path, List[str]], Iterable[str]]] = ...,
ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[StrPath, List[str]], Iterable[str]]] = ...,
copy_function: Callable[[str, str], None] = ...,
ignore_dangling_symlinks: bool = ...,
dirs_exist_ok: bool = ...,
) -> _PathReturn: ...
elif sys.version_info >= (3,):
def copytree(src: _Path, dst: _Path, symlinks: bool = ...,
def copytree(src: StrPath, dst: StrPath, symlinks: bool = ...,
ignore: Union[None,
Callable[[str, List[str]], Iterable[str]],
Callable[[_Path, List[str]], Iterable[str]]] = ...,
Callable[[StrPath, List[str]], Iterable[str]]] = ...,
copy_function: Callable[[str, str], None] = ...,
ignore_dangling_symlinks: bool = ...) -> _PathReturn: ...
else:
@@ -96,42 +94,42 @@ else:
Iterable[AnyStr]]] = ...) -> _PathReturn: ...
if sys.version_info >= (3,):
def rmtree(path: Union[bytes, _Path], ignore_errors: bool = ...,
def rmtree(path: Union[bytes, StrPath], ignore_errors: bool = ...,
onerror: Optional[Callable[[Any, Any, Any], Any]] = ...) -> None: ...
else:
def rmtree(path: _AnyPath, ignore_errors: bool = ...,
onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ...) -> None: ...
_CopyFn = Union[Callable[[str, str], None], Callable[[_Path, _Path], None]]
_CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]]
if sys.version_info >= (3, 9):
def move(src: _Path, dst: _Path,
def move(src: StrPath, dst: StrPath,
copy_function: _CopyFn = ...) -> _PathReturn: ...
elif sys.version_info >= (3, 5):
# See https://bugs.python.org/issue32689
def move(src: str, dst: _Path,
def move(src: str, dst: StrPath,
copy_function: _CopyFn = ...) -> _PathReturn: ...
else:
def move(src: _Path, dst: _Path) -> _PathReturn: ...
def move(src: StrPath, dst: StrPath) -> _PathReturn: ...
if sys.version_info >= (3,):
class _ntuple_diskusage(NamedTuple):
total: int
used: int
free: int
def disk_usage(path: _Path) -> _ntuple_diskusage: ...
def chown(path: _Path, user: Optional[str] = ...,
def disk_usage(path: StrPath) -> _ntuple_diskusage: ...
def chown(path: StrPath, user: Optional[str] = ...,
group: Optional[str] = ...) -> None: ...
if sys.version_info >= (3, 8):
@overload
def which(cmd: _Path, mode: int = ..., path: Optional[_Path] = ...) -> Optional[str]: ...
def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ...
@overload
def which(cmd: bytes, mode: int = ..., path: Optional[_Path] = ...) -> Optional[bytes]: ...
def which(cmd: bytes, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[bytes]: ...
elif sys.version_info >= (3,):
def which(cmd: _Path, mode: int = ..., path: Optional[_Path] = ...) -> Optional[str]: ...
def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ...
def make_archive(base_name: _AnyStr, format: str, root_dir: Optional[_Path] = ...,
base_dir: Optional[_Path] = ..., verbose: bool = ...,
def make_archive(base_name: _AnyStr, format: str, root_dir: Optional[StrPath] = ...,
base_dir: Optional[StrPath] = ..., verbose: bool = ...,
dry_run: bool = ..., owner: Optional[str] = ..., group: Optional[str] = ...,
logger: Optional[Any] = ...) -> _AnyStr: ...
def get_archive_formats() -> List[Tuple[str, str]]: ...
@@ -143,11 +141,11 @@ def unregister_archive_format(name: str) -> None: ...
if sys.version_info >= (3,):
if sys.version_info >= (3, 7):
def unpack_archive(filename: _Path, extract_dir: Optional[_Path] = ...,
def unpack_archive(filename: StrPath, extract_dir: Optional[StrPath] = ...,
format: Optional[str] = ...) -> None: ...
else:
# See http://bugs.python.org/issue30218
def unpack_archive(filename: str, extract_dir: Optional[_Path] = ...,
def unpack_archive(filename: str, extract_dir: Optional[StrPath] = ...,
format: Optional[str] = ...) -> None: ...
def register_unpack_format(name: str, extensions: List[str], function: Any,
extra_args: Sequence[Tuple[str, Any]] = ...,

View File

@@ -1,8 +1,6 @@
# Stubs for sndhdr (Python 2 and 3)
import os
import sys
from typing import Any, NamedTuple, Optional, Tuple, Union
from _typeshed import AnyPath
from typing import NamedTuple, Optional, Tuple, Union
if sys.version_info >= (3, 5):
class SndHeaders(NamedTuple):
@@ -15,10 +13,5 @@ if sys.version_info >= (3, 5):
else:
_SndHeaders = Tuple[str, int, int, int, Union[int, str]]
if sys.version_info >= (3, 6):
_Path = Union[str, bytes, os.PathLike[Any]]
else:
_Path = Union[str, bytes]
def what(filename: _Path) -> Optional[_SndHeaders]: ...
def whathdr(filename: _Path) -> Optional[_SndHeaders]: ...
def what(filename: AnyPath) -> Optional[_SndHeaders]: ...
def whathdr(filename: AnyPath) -> Optional[_SndHeaders]: ...

View File

@@ -1,18 +1,12 @@
# Stubs for ssl
from _typeshed import StrPath
from typing import (
Any, Callable, ClassVar, Dict, Iterable, List, NamedTuple, Optional, Set, Text, Type, Tuple, Union,
overload
)
from typing_extensions import Literal
import enum
import socket
import sys
import os
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
_PCTRTT = Tuple[Tuple[str, str], ...]
_PCTRTTT = Tuple[_PCTRTT, ...]
@@ -21,11 +15,6 @@ _PeerCertRetType = Union[_PeerCertRetDictType, bytes, None]
_EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]]
_PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes]
if sys.version_info < (3, 6):
_Path = Text
else:
_Path = Union[str, os.PathLike[Any]]
if sys.version_info >= (3, 5):
_SC1ArgT = Union[SSLSocket, SSLObject]
else:
@@ -278,13 +267,13 @@ class SSLContext:
else:
def __init__(self, protocol: int) -> None: ...
def cert_store_stats(self) -> Dict[str, int]: ...
def load_cert_chain(self, certfile: _Path, keyfile: Optional[_Path] = ...,
def load_cert_chain(self, certfile: StrPath, keyfile: Optional[StrPath] = ...,
password: Optional[_PasswordType] = ...) -> None: ...
def load_default_certs(self, purpose: Purpose = ...) -> None: ...
def load_verify_locations(
self,
cafile: Optional[_Path] = ...,
capath: Optional[_Path] = ...,
cafile: Optional[StrPath] = ...,
capath: Optional[StrPath] = ...,
cadata: Union[Text, bytes, None] = ...,
) -> None: ...
def get_ca_certs(self, binary_form: bool = ...) -> Union[List[_PeerCertRetDictType], List[bytes]]: ...

View File

@@ -1,13 +1,5 @@
# Stubs for tabnanny (Python 2 and 3)
import os
import sys
from typing import Iterable, Tuple, Union
if sys.version_info >= (3, 6):
_Path = Union[str, bytes, os.PathLike]
else:
_Path = Union[str, bytes]
from _typeshed import AnyPath
from typing import Iterable, Tuple
verbose: int
filename_only: int
@@ -18,5 +10,5 @@ class NannyNag(Exception):
def get_msg(self) -> str: ...
def get_line(self) -> str: ...
def check(file: _Path) -> None: ...
def check(file: AnyPath) -> None: ...
def process_tokens(tokens: Iterable[Tuple[int, str, Tuple[int, int], Tuple[int, int], str]]) -> None: ...

View File

@@ -1,20 +1,11 @@
# Stubs for tarfile
from typing import (
Callable, IO, Iterable, Iterator, List, Mapping, Optional, Type,
Union, Tuple, Dict, Set
)
import os
import sys
from _typeshed import AnyPath
from types import TracebackType
if sys.version_info >= (3, 6):
_Path = Union[bytes, str, os.PathLike]
elif sys.version_info >= (3,):
_Path = Union[bytes, str]
else:
_Path = Union[str, unicode]
# tar constants
NUL: bytes
BLOCKSIZE: int
@@ -67,7 +58,7 @@ if sys.version_info < (3,):
TAR_PLAIN: int
TAR_GZIPPED: int
def open(name: Optional[_Path] = ..., mode: str = ...,
def open(name: Optional[AnyPath] = ..., mode: str = ...,
fileobj: Optional[IO[bytes]] = ..., bufsize: int = ...,
*, format: Optional[int] = ..., tarinfo: Optional[TarInfo] = ...,
dereference: Optional[bool] = ...,
@@ -79,7 +70,7 @@ def open(name: Optional[_Path] = ..., mode: str = ...,
compresslevel: Optional[int] = ...) -> TarFile: ...
class TarFile(Iterable[TarInfo]):
name: Optional[_Path]
name: Optional[AnyPath]
mode: str
fileobj: Optional[IO[bytes]]
format: Optional[int]
@@ -93,7 +84,7 @@ class TarFile(Iterable[TarInfo]):
errorlevel: Optional[int]
if sys.version_info < (3,):
posix: bool
def __init__(self, name: Optional[_Path] = ..., mode: str = ...,
def __init__(self, name: Optional[AnyPath] = ..., mode: str = ...,
fileobj: Optional[IO[bytes]] = ...,
format: Optional[int] = ..., tarinfo: Optional[TarInfo] = ...,
dereference: Optional[bool] = ...,
@@ -110,7 +101,7 @@ class TarFile(Iterable[TarInfo]):
exc_tb: Optional[TracebackType]) -> None: ...
def __iter__(self) -> Iterator[TarInfo]: ...
@classmethod
def open(cls, name: Optional[_Path] = ..., mode: str = ...,
def open(cls, name: Optional[AnyPath] = ..., mode: str = ...,
fileobj: Optional[IO[bytes]] = ..., bufsize: int = ...,
*, format: Optional[int] = ..., tarinfo: Optional[TarInfo] = ...,
dereference: Optional[bool] = ...,
@@ -129,33 +120,33 @@ class TarFile(Iterable[TarInfo]):
def list(self, verbose: bool = ...) -> None: ...
def next(self) -> Optional[TarInfo]: ...
if sys.version_info >= (3, 5):
def extractall(self, path: _Path = ...,
def extractall(self, path: AnyPath = ...,
members: Optional[List[TarInfo]] = ...,
*, numeric_owner: bool = ...) -> None: ...
else:
def extractall(self, path: _Path = ...,
def extractall(self, path: AnyPath = ...,
members: Optional[List[TarInfo]] = ...) -> None: ...
if sys.version_info >= (3, 5):
def extract(self, member: Union[str, TarInfo], path: _Path = ...,
def extract(self, member: Union[str, TarInfo], path: AnyPath = ...,
set_attrs: bool = ...,
*, numeric_owner: bool = ...) -> None: ...
else:
def extract(self, member: Union[str, TarInfo],
path: _Path = ...) -> None: ...
path: AnyPath = ...) -> None: ...
def extractfile(self,
member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ...
def makedir(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented
def makefile(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented
def makeunknown(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented
def makefifo(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented
def makedev(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented
def makelink(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented
def makedir(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented
def makefile(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented
def makeunknown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented
def makefifo(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented
def makedev(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented
def makelink(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented
if sys.version_info >= (3, 5):
def chown(self, tarinfo: TarInfo, targetpath: _Path, numeric_owner: bool) -> None: ... # undocumented
def chown(self, tarinfo: TarInfo, targetpath: AnyPath, numeric_owner: bool) -> None: ... # undocumented
else:
def chown(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented
def chmod(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented
def utime(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented
def chown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented
def chmod(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented
def utime(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented
if sys.version_info >= (3, 7):
def add(self, name: str, arcname: Optional[str] = ...,
recursive: bool = ..., *,
@@ -178,9 +169,9 @@ class TarFile(Iterable[TarInfo]):
def close(self) -> None: ...
if sys.version_info >= (3, 9):
def is_tarfile(name: Union[_Path, IO[bytes]]) -> bool: ...
def is_tarfile(name: Union[AnyPath, IO[bytes]]) -> bool: ...
else:
def is_tarfile(name: _Path) -> bool: ...
def is_tarfile(name: AnyPath) -> bool: ...
if sys.version_info < (3, 8):
def filemode(mode: int) -> str: ... # undocumented

View File

@@ -1,27 +1,19 @@
# Stubs for trace (Python 2 and 3)
import os
import sys
from _typeshed import StrPath
import types
from typing import Any, Callable, Mapping, Optional, Sequence, Text, Tuple, TypeVar, Union
from typing import Any, Callable, Mapping, Optional, Sequence, Tuple, TypeVar, Union
_T = TypeVar('_T')
_localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]]
if sys.version_info >= (3, 6):
_Path = Union[Text, os.PathLike]
else:
_Path = Text
class CoverageResults:
def update(self, other: CoverageResults) -> None: ...
def write_results(self, show_missing: bool = ..., summary: bool = ..., coverdir: Optional[_Path] = ...) -> None: ...
def write_results_file(self, path: _Path, lines: Sequence[str], lnotab: Any, lines_hit: Mapping[int, int], encoding: Optional[str] = ...) -> Tuple[int, int]: ...
def write_results(self, show_missing: bool = ..., summary: bool = ..., coverdir: Optional[StrPath] = ...) -> None: ...
def write_results_file(self, path: StrPath, lines: Sequence[str], lnotab: Any, lines_hit: Mapping[int, int], encoding: Optional[str] = ...) -> Tuple[int, int]: ...
class Trace:
def __init__(self, count: int = ..., trace: int = ..., countfuncs: int = ..., countcallers: int = ...,
ignoremods: Sequence[str] = ..., ignoredirs: Sequence[str] = ..., infile: Optional[_Path] = ...,
outfile: Optional[_Path] = ..., timing: bool = ...) -> None: ...
ignoremods: Sequence[str] = ..., ignoredirs: Sequence[str] = ..., infile: Optional[StrPath] = ...,
outfile: Optional[StrPath] = ..., timing: bool = ...) -> None: ...
def run(self, cmd: Union[str, types.CodeType]) -> None: ...
def runctx(self, cmd: Union[str, types.CodeType], globals: Optional[Mapping[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> None: ...
def runfunc(self, func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ...

View File

@@ -1,15 +1,9 @@
# Stubs for zipfile
from _typeshed import StrPath
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, Protocol, Text, Tuple, Type, Union, Sequence, Pattern
from types import TracebackType
import io
import os
import sys
if sys.version_info >= (3, 6):
_Path = Union[os.PathLike[str], str]
else:
_Path = Text
_SZI = Union[Text, ZipInfo]
_DT = Tuple[int, int, int, int, int, int]
@@ -72,7 +66,7 @@ class ZipFile:
if sys.version_info >= (3, 8):
def __init__(
self,
file: Union[_Path, IO[bytes]],
file: Union[StrPath, IO[bytes]],
mode: str = ...,
compression: int = ...,
allowZip64: bool = ...,
@@ -83,7 +77,7 @@ class ZipFile:
elif sys.version_info >= (3, 7):
def __init__(
self,
file: Union[_Path, IO[bytes]],
file: Union[StrPath, IO[bytes]],
mode: str = ...,
compression: int = ...,
allowZip64: bool = ...,
@@ -91,7 +85,7 @@ class ZipFile:
) -> None: ...
else:
def __init__(
self, file: Union[_Path, IO[bytes]], mode: Text = ..., compression: int = ..., allowZip64: bool = ...
self, file: Union[StrPath, IO[bytes]], mode: Text = ..., compression: int = ..., allowZip64: bool = ...
) -> None: ...
def __enter__(self) -> ZipFile: ...
def __exit__(
@@ -104,7 +98,7 @@ class ZipFile:
def open(self, name: _SZI, mode: Text = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ...
def extract(self, member: _SZI, path: Optional[_SZI] = ..., pwd: Optional[bytes] = ...) -> str: ...
def extractall(
self, path: Optional[_Path] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ...
self, path: Optional[StrPath] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ...
) -> None: ...
if sys.version_info >= (3,):
def printdir(self, file: Optional[_Writer] = ...) -> None: ...
@@ -114,9 +108,9 @@ class ZipFile:
def read(self, name: _SZI, pwd: Optional[bytes] = ...) -> bytes: ...
def testzip(self) -> Optional[str]: ...
if sys.version_info >= (3, 7):
def write(self, filename: _Path, arcname: Optional[_Path] = ..., compress_type: Optional[int] = ..., compresslevel: Optional[int] = ...) -> None: ...
def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ..., compresslevel: Optional[int] = ...) -> None: ...
else:
def write(self, filename: _Path, arcname: Optional[_Path] = ..., compress_type: Optional[int] = ...) -> None: ...
def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ...) -> None: ...
if sys.version_info >= (3, 7):
def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str], compress_type: Optional[int] = ..., compresslevel: Optional[int] = ...) -> None: ...
elif sys.version_info >= (3,):
@@ -154,10 +148,10 @@ class ZipInfo:
def __init__(self, filename: Optional[Text] = ..., date_time: Optional[_DT] = ...) -> None: ...
if sys.version_info >= (3, 8):
@classmethod
def from_file(cls, filename: _Path, arcname: Optional[_Path] = ..., *, strict_timestamps: bool = ...) -> ZipInfo: ...
def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ..., *, strict_timestamps: bool = ...) -> ZipInfo: ...
elif sys.version_info >= (3, 6):
@classmethod
def from_file(cls, filename: _Path, arcname: Optional[_Path] = ...) -> ZipInfo: ...
def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ...) -> ZipInfo: ...
if sys.version_info >= (3, 6):
def is_dir(self) -> bool: ...
def FileHeader(self, zip64: Optional[bool] = ...) -> bytes: ...
@@ -168,7 +162,7 @@ if sys.version_info >= (3, 8):
def name(self) -> str: ...
@property
def parent(self) -> Path: ... # undocumented
def __init__(self, root: Union[ZipFile, _Path, IO[bytes]], at: str = ...) -> None: ...
def __init__(self, root: Union[ZipFile, StrPath, IO[bytes]], at: str = ...) -> None: ...
def open(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ...
def iterdir(self) -> Iterator[Path]: ...
def is_dir(self) -> bool: ...
@@ -183,10 +177,10 @@ if sys.version_info >= (3, 8):
write_through: bool = ...,
) -> str: ...
def read_bytes(self) -> bytes: ...
def joinpath(self, add: _Path) -> Path: ... # undocumented
def __truediv__(self, add: _Path) -> Path: ...
def joinpath(self, add: StrPath) -> Path: ... # undocumented
def __truediv__(self, add: StrPath) -> Path: ...
def is_zipfile(filename: Union[_Path, IO[bytes]]) -> bool: ...
def is_zipfile(filename: Union[StrPath, IO[bytes]]) -> bool: ...
ZIP_STORED: int
ZIP_DEFLATED: int