mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Clean up files with former forced consistency (#4717)
Replace Text with str in Python 3 code
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import sys
|
||||
|
||||
from ._base import (
|
||||
ALL_COMPLETED as ALL_COMPLETED,
|
||||
FIRST_COMPLETED as FIRST_COMPLETED,
|
||||
@@ -13,8 +11,3 @@ from ._base import (
|
||||
)
|
||||
from .process import ProcessPoolExecutor as ProcessPoolExecutor
|
||||
from .thread import ThreadPoolExecutor as ThreadPoolExecutor
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from ._base import InvalidStateError as InvalidStateError
|
||||
if sys.version_info >= (3, 7):
|
||||
from ._base import BrokenExecutor as BrokenExecutor
|
||||
|
||||
41
third_party/2/concurrent/futures/_base.pyi
vendored
41
third_party/2/concurrent/futures/_base.pyi
vendored
@@ -1,13 +1,9 @@
|
||||
import sys
|
||||
import threading
|
||||
from abc import abstractmethod
|
||||
from logging import Logger
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Container, Generic, Iterable, Iterator, List, Optional, Protocol, Set, Tuple, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
FIRST_COMPLETED: str
|
||||
FIRST_EXCEPTION: str
|
||||
ALL_COMPLETED: str
|
||||
@@ -22,12 +18,6 @@ class Error(Exception): ...
|
||||
class CancelledError(Error): ...
|
||||
class TimeoutError(Error): ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class InvalidStateError(Error): ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
class BrokenExecutor(RuntimeError): ...
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
@@ -49,32 +39,15 @@ class Future(Generic[_T]):
|
||||
def result(self, timeout: Optional[float] = ...) -> _T: ...
|
||||
def set_running_or_notify_cancel(self) -> bool: ...
|
||||
def set_result(self, result: _T) -> None: ...
|
||||
if sys.version_info >= (3,):
|
||||
def exception(self, timeout: Optional[float] = ...) -> Optional[BaseException]: ...
|
||||
def set_exception(self, exception: Optional[BaseException]) -> None: ...
|
||||
else:
|
||||
def exception(self, timeout: Optional[float] = ...) -> Any: ...
|
||||
def exception_info(self, timeout: Optional[float] = ...) -> Tuple[Any, Optional[TracebackType]]: ...
|
||||
def set_exception(self, exception: Any) -> None: ...
|
||||
def set_exception_info(self, exception: Any, traceback: Optional[TracebackType]) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
def exception(self, timeout: Optional[float] = ...) -> Any: ...
|
||||
def exception_info(self, timeout: Optional[float] = ...) -> Tuple[Any, Optional[TracebackType]]: ...
|
||||
def set_exception(self, exception: Any) -> None: ...
|
||||
def set_exception_info(self, exception: Any, traceback: Optional[TracebackType]) -> None: ...
|
||||
|
||||
class Executor:
|
||||
if sys.version_info >= (3, 9):
|
||||
def submit(self, __fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
|
||||
else:
|
||||
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
def map(
|
||||
self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ..., chunksize: int = ...
|
||||
) -> Iterator[_T]: ...
|
||||
else:
|
||||
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...) -> Iterator[_T]: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def shutdown(self, wait: bool = ..., *, cancel_futures: bool = ...) -> None: ...
|
||||
else:
|
||||
def shutdown(self, wait: bool = ...) -> None: ...
|
||||
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
|
||||
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...) -> Iterator[_T]: ...
|
||||
def shutdown(self, wait: bool = ...) -> None: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Optional[bool]: ...
|
||||
|
||||
|
||||
26
third_party/2/concurrent/futures/process.pyi
vendored
26
third_party/2/concurrent/futures/process.pyi
vendored
@@ -1,28 +1,8 @@
|
||||
import sys
|
||||
from typing import Any, Callable, Optional, Tuple
|
||||
from typing import Any, Optional
|
||||
|
||||
from ._base import Executor
|
||||
|
||||
EXTRA_QUEUED_CALLS: Any
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from ._base import BrokenExecutor
|
||||
class BrokenProcessPool(BrokenExecutor): ...
|
||||
|
||||
elif sys.version_info >= (3,):
|
||||
class BrokenProcessPool(RuntimeError): ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from multiprocessing.context import BaseContext
|
||||
class ProcessPoolExecutor(Executor):
|
||||
def __init__(
|
||||
self,
|
||||
max_workers: Optional[int] = ...,
|
||||
mp_context: Optional[BaseContext] = ...,
|
||||
initializer: Optional[Callable[..., None]] = ...,
|
||||
initargs: Tuple[Any, ...] = ...,
|
||||
) -> None: ...
|
||||
|
||||
else:
|
||||
class ProcessPoolExecutor(Executor):
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
class ProcessPoolExecutor(Executor):
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
|
||||
23
third_party/2/concurrent/futures/thread.pyi
vendored
23
third_party/2/concurrent/futures/thread.pyi
vendored
@@ -1,30 +1,11 @@
|
||||
import sys
|
||||
from typing import Any, Callable, Generic, Iterable, Mapping, Optional, Tuple, TypeVar
|
||||
|
||||
from ._base import Executor, Future
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from ._base import BrokenExecutor
|
||||
class BrokenThreadPool(BrokenExecutor): ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_S = TypeVar("_S")
|
||||
|
||||
class ThreadPoolExecutor(Executor):
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(
|
||||
self,
|
||||
max_workers: Optional[int] = ...,
|
||||
thread_name_prefix: str = ...,
|
||||
initializer: Optional[Callable[..., None]] = ...,
|
||||
initargs: Tuple[Any, ...] = ...,
|
||||
) -> None: ...
|
||||
elif sys.version_info >= (3, 6) or sys.version_info < (3,):
|
||||
def __init__(self, max_workers: Optional[int] = ..., thread_name_prefix: str = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
def __init__(self, max_workers: Optional[int] = ..., thread_name_prefix: str = ...) -> None: ...
|
||||
|
||||
class _WorkItem(Generic[_S]):
|
||||
future: Future[_S]
|
||||
@@ -33,5 +14,3 @@ class _WorkItem(Generic[_S]):
|
||||
kwargs: Mapping[str, Any]
|
||||
def __init__(self, future: Future[_S], fn: Callable[..., _S], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ...
|
||||
def run(self) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
4
third_party/2/ipaddress.pyi
vendored
4
third_party/2/ipaddress.pyi
vendored
@@ -1,4 +1,3 @@
|
||||
import sys
|
||||
from typing import Any, Container, Generic, Iterable, Iterator, Optional, SupportsInt, Text, Tuple, TypeVar, overload
|
||||
|
||||
# Undocumented length constants
|
||||
@@ -87,9 +86,6 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
|
||||
def overlaps(self, other: _BaseNetwork[_A]) -> bool: ...
|
||||
@property
|
||||
def prefixlen(self) -> int: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def subnet_of(self: _T, other: _T) -> bool: ...
|
||||
def supernet_of(self: _T, other: _T) -> bool: ...
|
||||
def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Iterator[_T]: ...
|
||||
def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> _T: ...
|
||||
@property
|
||||
|
||||
128
third_party/2/pathlib2.pyi
vendored
128
third_party/2/pathlib2.pyi
vendored
@@ -6,17 +6,10 @@ from types import TracebackType
|
||||
from typing import IO, Any, BinaryIO, Generator, List, Optional, Sequence, Text, TextIO, Tuple, Type, TypeVar, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_P = TypeVar("_P", bound=PurePath)
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
_PurePathBase = os.PathLike[str]
|
||||
_PathLike = os.PathLike[str]
|
||||
else:
|
||||
_PurePathBase = object
|
||||
_PathLike = PurePath
|
||||
_PurePathBase = object
|
||||
_PathLike = PurePath
|
||||
|
||||
class PurePath(_PurePathBase):
|
||||
parts: Tuple[str, ...]
|
||||
@@ -35,28 +28,21 @@ class PurePath(_PurePathBase):
|
||||
def __ge__(self, other: PurePath) -> bool: ...
|
||||
def __truediv__(self: _P, key: Union[str, _PathLike]) -> _P: ...
|
||||
def __rtruediv__(self: _P, key: Union[str, _PathLike]) -> _P: ...
|
||||
if sys.version_info < (3,):
|
||||
def __div__(self: _P, key: Union[str, PurePath]) -> _P: ...
|
||||
def __div__(self: _P, key: Union[str, PurePath]) -> _P: ...
|
||||
def __bytes__(self) -> bytes: ...
|
||||
def as_posix(self) -> str: ...
|
||||
def as_uri(self) -> str: ...
|
||||
def is_absolute(self) -> bool: ...
|
||||
def is_reserved(self) -> bool: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def is_relative_to(self, *other: Union[str, os.PathLike[str]]) -> bool: ...
|
||||
def match(self, path_pattern: str) -> bool: ...
|
||||
def relative_to(self: _P, *other: Union[str, _PathLike]) -> _P: ...
|
||||
def with_name(self: _P, name: str) -> _P: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def with_stem(self: _P, stem: str) -> _P: ...
|
||||
def with_suffix(self: _P, suffix: str) -> _P: ...
|
||||
def joinpath(self: _P, *other: Union[str, _PathLike]) -> _P: ...
|
||||
@property
|
||||
def parents(self: _P) -> Sequence[_P]: ...
|
||||
@property
|
||||
def parent(self: _P) -> _P: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, type: Any) -> GenericAlias: ...
|
||||
|
||||
class PurePosixPath(PurePath): ...
|
||||
class PureWindowsPath(PurePath): ...
|
||||
@@ -76,8 +62,6 @@ class Path(PurePath):
|
||||
def group(self) -> str: ...
|
||||
def is_dir(self) -> bool: ...
|
||||
def is_file(self) -> bool: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def is_mount(self) -> bool: ...
|
||||
def is_symlink(self) -> bool: ...
|
||||
def is_socket(self) -> bool: ...
|
||||
def is_fifo(self) -> bool: ...
|
||||
@@ -86,101 +70,25 @@ class Path(PurePath):
|
||||
def iterdir(self) -> Generator[Path, None, None]: ...
|
||||
def lchmod(self, mode: int) -> None: ...
|
||||
def lstat(self) -> os.stat_result: ...
|
||||
if sys.version_info < (3, 5):
|
||||
def mkdir(self, mode: int = ..., parents: bool = ...) -> None: ...
|
||||
else:
|
||||
def mkdir(self, mode: int = ..., parents: bool = ..., exist_ok: bool = ...) -> None: ...
|
||||
if sys.version_info >= (3,):
|
||||
# Adapted from builtins.open
|
||||
# Text mode: always returns a TextIOWrapper
|
||||
@overload
|
||||
def open(
|
||||
self,
|
||||
mode: OpenTextMode = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
) -> TextIOWrapper: ...
|
||||
# Unbuffered binary mode: returns a FileIO
|
||||
@overload
|
||||
def open(
|
||||
self, mode: OpenBinaryMode, buffering: Literal[0], encoding: None = ..., errors: None = ..., newline: None = ...
|
||||
) -> FileIO: ...
|
||||
# Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter
|
||||
@overload
|
||||
def open(
|
||||
self,
|
||||
mode: OpenBinaryModeUpdating,
|
||||
buffering: Literal[-1, 1] = ...,
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
newline: None = ...,
|
||||
) -> BufferedRandom: ...
|
||||
@overload
|
||||
def open(
|
||||
self,
|
||||
mode: OpenBinaryModeWriting,
|
||||
buffering: Literal[-1, 1] = ...,
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
newline: None = ...,
|
||||
) -> BufferedWriter: ...
|
||||
@overload
|
||||
def open(
|
||||
self,
|
||||
mode: OpenBinaryModeReading,
|
||||
buffering: Literal[-1, 1] = ...,
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
newline: None = ...,
|
||||
) -> BufferedReader: ...
|
||||
# Buffering cannot be determined: fall back to BinaryIO
|
||||
@overload
|
||||
def open(
|
||||
self, mode: OpenBinaryMode, buffering: int, encoding: None = ..., errors: None = ..., newline: None = ...
|
||||
) -> BinaryIO: ...
|
||||
# Fallback if mode is not specified
|
||||
@overload
|
||||
def open(
|
||||
self,
|
||||
mode: str,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
) -> IO[Any]: ...
|
||||
else:
|
||||
# Adapted from _io.open
|
||||
def open(
|
||||
self,
|
||||
mode: Text = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[Text] = ...,
|
||||
errors: Optional[Text] = ...,
|
||||
newline: Optional[Text] = ...,
|
||||
) -> IO[Any]: ...
|
||||
def mkdir(self, mode: int = ..., parents: bool = ...) -> None: ...
|
||||
# Adapted from _io.open
|
||||
def open(
|
||||
self,
|
||||
mode: Text = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[Text] = ...,
|
||||
errors: Optional[Text] = ...,
|
||||
newline: Optional[Text] = ...,
|
||||
) -> IO[Any]: ...
|
||||
def owner(self) -> str: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def readlink(self: _P) -> _P: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def rename(self: _P, target: Union[str, PurePath]) -> _P: ...
|
||||
def replace(self: _P, target: Union[str, PurePath]) -> _P: ...
|
||||
else:
|
||||
def rename(self, target: Union[str, PurePath]) -> None: ...
|
||||
def replace(self, target: Union[str, PurePath]) -> None: ...
|
||||
if sys.version_info < (3, 6):
|
||||
def resolve(self: _P) -> _P: ...
|
||||
else:
|
||||
def resolve(self: _P, strict: bool = ...) -> _P: ...
|
||||
def rename(self, target: Union[str, PurePath]) -> None: ...
|
||||
def replace(self, target: Union[str, PurePath]) -> None: ...
|
||||
def resolve(self: _P) -> _P: ...
|
||||
def rglob(self, pattern: str) -> Generator[Path, None, None]: ...
|
||||
def rmdir(self) -> None: ...
|
||||
def symlink_to(self, target: Union[str, Path], target_is_directory: bool = ...) -> None: ...
|
||||
def touch(self, mode: int = ..., exist_ok: bool = ...) -> None: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def unlink(self, missing_ok: bool = ...) -> None: ...
|
||||
else:
|
||||
def unlink(self) -> None: ...
|
||||
def unlink(self) -> None: ...
|
||||
@classmethod
|
||||
def home(cls: Type[_P]) -> _P: ...
|
||||
def absolute(self: _P) -> _P: ...
|
||||
@@ -190,8 +98,6 @@ class Path(PurePath):
|
||||
def samefile(self, other_path: Union[str, bytes, int, Path]) -> bool: ...
|
||||
def write_bytes(self, data: bytes) -> int: ...
|
||||
def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def link_to(self, target: Union[str, bytes, os.PathLike[str]]) -> None: ...
|
||||
|
||||
class PosixPath(Path, PurePosixPath): ...
|
||||
class WindowsPath(Path, PureWindowsPath): ...
|
||||
|
||||
Reference in New Issue
Block a user