Enable --disallow-any-generics for stubs (#3288)

This commit is contained in:
Sebastian Rittau
2019-10-01 14:31:34 +02:00
committed by Jelle Zijlstra
parent 23b353303b
commit c32e1e2280
77 changed files with 386 additions and 329 deletions

View File

@@ -7,7 +7,7 @@ localdict = Dict[Any, Any]
class _localimpl:
key: str
dicts: Dict[int, Tuple[ReferenceType, localdict]]
dicts: Dict[int, Tuple[ReferenceType[Any], localdict]]
def __init__(self) -> None: ...
def get_dict(self) -> localdict: ...
def create_dict(self) -> localdict: ...

View File

@@ -3,7 +3,7 @@
# for a more precise manual annotation of this module.
# Feel free to edit the source below, but remove this header when you do.
from typing import Any
from typing import Any, Tuple
def _get_object_traceback(*args, **kwargs) -> Any: ...
@@ -14,7 +14,7 @@ def clear_traces() -> None: ...
def get_traceback_limit() -> int: ...
def get_traced_memory() -> tuple: ...
def get_traced_memory() -> Tuple[Any, ...]: ...
def get_tracemalloc_memory() -> Any: ...

View File

@@ -1,11 +1,11 @@
from typing import Any, List, Optional, Type
from typing import Any, Dict, List, Optional, Tuple, Type
_defaultaction: str
_onceregistry: dict
filters: List[tuple]
_onceregistry: Dict[Any, Any]
filters: List[Tuple[Any, ...]]
def warn(message: Warning, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ...
def warn_explicit(message: Warning, category: Optional[Type[Warning]],
filename: str, lineno: int,
module: Any = ..., registry: dict = ...,
module_globals: dict = ...) -> None: ...
module: Any = ..., registry: Dict[Any, Any] = ...,
module_globals: Dict[Any, Any] = ...) -> None: ...

View File

@@ -61,7 +61,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
family: int = ..., type: int = ..., proto: int = ...,
flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any, ...]]]]: ...
@coroutine
def getnameinfo(self, sockaddr: tuple, flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...
def getnameinfo(self, sockaddr: Tuple[Any, ...], flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...
if sys.version_info >= (3, 7):
async def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
fallback: bool = ...) -> int: ...

View File

@@ -107,7 +107,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any, ...]]]]: ...
@abstractmethod
@coroutine
def getnameinfo(self, sockaddr: tuple, flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...
def getnameinfo(self, sockaddr: Tuple[Any, ...], flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...
if sys.version_info >= (3, 7):
@abstractmethod
async def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,

View File

@@ -14,7 +14,7 @@ if sys.version_info >= (3, 7):
__all__: List[str]
_T = TypeVar('_T')
_S = TypeVar('_S', bound=Future)
_S = TypeVar('_S')
class InvalidStateError(Error): ...

View File

@@ -95,9 +95,9 @@ def wait_for(fut: _FutureT[_T], timeout: Optional[float],
class Task(Future[_T], Generic[_T]):
@classmethod
def current_task(cls, loop: Optional[AbstractEventLoop] = ...) -> Task: ...
def current_task(cls, loop: Optional[AbstractEventLoop] = ...) -> Task[Any]: ...
@classmethod
def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task]: ...
def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
def __init__(self, coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...) -> None: ...
def __repr__(self) -> str: ...
def get_stack(self, *, limit: int = ...) -> List[FrameType]: ...
@@ -107,6 +107,6 @@ class Task(Future[_T], Generic[_T]):
def _wakeup(self, future: Future[Any]) -> None: ...
if sys.version_info >= (3, 7):
def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task]: ...
def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task: ...
def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task]: ...
def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task[Any]: ...
def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ...

View File

@@ -47,16 +47,27 @@ _VT = TypeVar('_VT')
# namedtuple is special-cased in the type checker; the initializer is ignored.
if sys.version_info >= (3, 7):
def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *,
rename: bool = ..., module: Optional[str] = ..., defaults: Optional[Iterable[Any]] = ...) -> Type[tuple]: ...
def namedtuple(
typename: str,
field_names: Union[str, Iterable[str]],
*,
rename: bool = ...,
module: Optional[str] = ...,
defaults: Optional[Iterable[Any]] = ...,
) -> Type[Tuple[Any, ...]]: ...
elif sys.version_info >= (3, 6):
def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *,
verbose: bool = ..., rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ...
def namedtuple(
typename: str,
field_names: Union[str, Iterable[str]],
*,
verbose: bool = ...,
rename: bool = ...,
module: Optional[str] = ...,
) -> Type[Tuple[Any, ...]]: ...
else:
def namedtuple(typename: str, field_names: Union[str, Iterable[str]],
verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ...
_UserDictT = TypeVar('_UserDictT', bound=UserDict)
def namedtuple(
typename: str, field_names: Union[str, Iterable[str]], verbose: bool = ..., rename: bool = ...,
) -> Type[Tuple[Any, ...]]: ...
class UserDict(MutableMapping[_KT, _VT]):
data: Dict[_KT, _VT]
@@ -67,11 +78,9 @@ class UserDict(MutableMapping[_KT, _VT]):
def __delitem__(self, key: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
def __contains__(self, key: object) -> bool: ...
def copy(self: _UserDictT) -> _UserDictT: ...
def copy(self: _S) -> _S: ...
@classmethod
def fromkeys(cls: Type[_UserDictT], iterable: Iterable[_KT], value: Optional[_VT] = ...) -> _UserDictT: ...
_UserListT = TypeVar('_UserListT', bound=UserList)
def fromkeys(cls: Type[_S], iterable: Iterable[_KT], value: Optional[_VT] = ...) -> _S: ...
class UserList(MutableSequence[_T]):
data: List[_T]
@@ -91,16 +100,16 @@ class UserList(MutableSequence[_T]):
@overload
def __setitem__(self, i: slice, o: Iterable[_T]) -> None: ...
def __delitem__(self, i: Union[int, slice]) -> None: ...
def __add__(self: _UserListT, other: Iterable[_T]) -> _UserListT: ...
def __iadd__(self: _UserListT, other: Iterable[_T]) -> _UserListT: ...
def __mul__(self: _UserListT, n: int) -> _UserListT: ...
def __imul__(self: _UserListT, n: int) -> _UserListT: ...
def __add__(self: _S, other: Iterable[_T]) -> _S: ...
def __iadd__(self: _S, other: Iterable[_T]) -> _S: ...
def __mul__(self: _S, n: int) -> _S: ...
def __imul__(self: _S, n: int) -> _S: ...
def append(self, item: _T) -> None: ...
def insert(self, i: int, item: _T) -> None: ...
def pop(self, i: int = ...) -> _T: ...
def remove(self, item: _T) -> None: ...
def clear(self) -> None: ...
def copy(self: _UserListT) -> _UserListT: ...
def copy(self: _S) -> _S: ...
def count(self, item: _T) -> int: ...
def index(self, item: _T, *args: Any) -> int: ...
def reverse(self) -> None: ...
@@ -233,8 +242,6 @@ class deque(MutableSequence[_T], Generic[_T]):
def __mul__(self, other: int) -> deque[_T]: ...
def __imul__(self, other: int) -> None: ...
_CounterT = TypeVar('_CounterT', bound=Counter)
class Counter(Dict[_T, int], Generic[_T]):
@overload
def __init__(self, **kwargs: int) -> None: ...
@@ -242,7 +249,7 @@ class Counter(Dict[_T, int], Generic[_T]):
def __init__(self, mapping: Mapping[_T, int]) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T]) -> None: ...
def copy(self: _CounterT) -> _CounterT: ...
def copy(self: _S) -> _S: ...
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ...
@@ -275,8 +282,6 @@ class Counter(Dict[_T, int], Generic[_T]):
def __iand__(self, other: Counter[_T]) -> Counter[_T]: ...
def __ior__(self, other: Counter[_T]) -> Counter[_T]: ...
_OrderedDictT = TypeVar('_OrderedDictT', bound=OrderedDict)
class _OrderedDictKeysView(KeysView[_KT], Reversible[_KT]):
def __reversed__(self) -> Iterator[_KT]: ...
class _OrderedDictItemsView(ItemsView[_KT, _VT], Reversible[Tuple[_KT, _VT]]):
@@ -287,14 +292,12 @@ class _OrderedDictValuesView(ValuesView[_VT], Reversible[_VT]):
class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
def move_to_end(self, key: _KT, last: bool = ...) -> None: ...
def copy(self: _OrderedDictT) -> _OrderedDictT: ...
def copy(self: _S) -> _S: ...
def __reversed__(self) -> Iterator[_KT]: ...
def keys(self) -> _OrderedDictKeysView[_KT]: ...
def items(self) -> _OrderedDictItemsView[_KT, _VT]: ...
def values(self) -> _OrderedDictValuesView[_VT]: ...
_DefaultDictT = TypeVar('_DefaultDictT', bound=defaultdict)
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
default_factory: Optional[Callable[[], _VT]]
@@ -318,7 +321,7 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def __missing__(self, key: _KT) -> _VT: ...
# TODO __reversed__
def copy(self: _DefaultDictT) -> _DefaultDictT: ...
def copy(self: _S) -> _S: ...
class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...

View File

@@ -2,7 +2,7 @@
import os
import sys
from typing import Optional, Union, Pattern
from typing import Any, Optional, Union, Pattern
if sys.version_info < (3, 6):
_Path = Union[str, bytes]
@@ -12,6 +12,24 @@ else:
_SuccessType = int
# rx can be any object with a 'search' method; once we have Protocols we can change the type
def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., workers: int = ...) -> _SuccessType: ...
def compile_file(fullname: _Path, ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> _SuccessType: ...
def compile_dir(
dir: _Path,
maxlevels: int = ...,
ddir: Optional[_Path] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
legacy: bool = ...,
optimize: int = ...,
workers: int = ...,
) -> _SuccessType: ...
def compile_file(
fullname: _Path,
ddir: Optional[_Path] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
legacy: bool = ...,
optimize: int = ...,
) -> _SuccessType: ...
def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> _SuccessType: ...

View File

@@ -62,25 +62,25 @@ def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when:
class _Waiter:
event: threading.Event
finished_futures: List[Future]
finished_futures: List[Future[Any]]
def __init__(self) -> None: ...
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...
def add_result(self, future: Future[Any]) -> None: ...
def add_exception(self, future: Future[Any]) -> None: ...
def add_cancelled(self, future: Future[Any]) -> None: ...
class _AsCompletedWaiter(_Waiter):
lock: threading.Lock
def __init__(self) -> None: ...
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...
def add_result(self, future: Future[Any]) -> None: ...
def add_exception(self, future: Future[Any]) -> None: ...
def add_cancelled(self, future: Future[Any]) -> None: ...
class _FirstCompletedWaiter(_Waiter):
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...
def add_result(self, future: Future[Any]) -> None: ...
def add_exception(self, future: Future[Any]) -> None: ...
def add_cancelled(self, future: Future[Any]) -> None: ...
class _AllCompletedWaiter(_Waiter):
@@ -88,13 +88,13 @@ class _AllCompletedWaiter(_Waiter):
stop_on_exception: bool
lock: threading.Lock
def __init__(self, num_pending_calls: int, stop_on_exception: bool) -> None: ...
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...
def add_result(self, future: Future[Any]) -> None: ...
def add_exception(self, future: Future[Any]) -> None: ...
def add_cancelled(self, future: Future[Any]) -> None: ...
class _AcquireFutures:
futures: Iterable[Future]
def __init__(self, futures: Iterable[Future]) -> None: ...
futures: Iterable[Future[Any]]
def __init__(self, futures: Iterable[Future[Any]]) -> None: ...
def __enter__(self) -> None: ...
def __exit__(self, *args: Any) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Optional, Tuple, TypeVar, Generic
from typing import Any, Callable, Iterable, Mapping, Optional, Tuple, TypeVar, Generic
from ._base import Executor, Future
import sys
@@ -22,10 +22,9 @@ class ThreadPoolExecutor(Executor):
class _WorkItem(Generic[_S]):
future: Future
fn: Callable[[Future[_S]], Any]
args: Any
kwargs: Any
def __init__(self, future: Future, fn: Callable[[Future[_S]], Any], args: Any,
kwargs: Any) -> None: ...
future: Future[_S]
fn: Callable[..., _S]
args: Iterable[Any]
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: ...

View File

@@ -177,7 +177,7 @@ class SectionProxy(MutableMapping[str, str]):
def __getattr__(self, key: str) -> Callable[..., Any]: ...
class ConverterMapping(MutableMapping[str, Optional[_converter]]):
GETTERCRE: Pattern
GETTERCRE: Pattern[Any]
def __init__(self, parser: RawConfigParser) -> None: ...
def __getitem__(self, key: str) -> _converter: ...
def __setitem__(self, key: str, value: Optional[_converter]) -> None: ...

View File

@@ -2,7 +2,7 @@
from typing import Generic, Dict, List, Mapping, MutableMapping, Optional, TypeVar, Union, Any
_DataType = Union[str, Mapping[str, Union[str, Morsel]]]
_DataType = Union[str, Mapping[str, Union[str, Morsel[Any]]]]
_T = TypeVar('_T')
class CookieError(Exception): ...
@@ -18,7 +18,7 @@ class Morsel(Dict[str, Any], Generic[_T]):
def js_output(self, attrs: Optional[List[str]] = ...) -> str: ...
def OutputString(self, attrs: Optional[List[str]] = ...) -> str: ...
class BaseCookie(Dict[str, Morsel], Generic[_T]):
class BaseCookie(Dict[str, Morsel[_T]], Generic[_T]):
def __init__(self, input: Optional[_DataType] = ...) -> None: ...
def value_decode(self, val: str) -> _T: ...
def value_encode(self, val: _T) -> str: ...
@@ -26,6 +26,6 @@ class BaseCookie(Dict[str, Morsel], Generic[_T]):
sep: str = ...) -> str: ...
def js_output(self, attrs: Optional[List[str]] = ...) -> str: ...
def load(self, rawdata: _DataType) -> None: ...
def __setitem__(self, key: str, value: Union[str, Morsel]) -> None: ...
def __setitem__(self, key: str, value: Union[str, Morsel[_T]]) -> None: ...
class SimpleCookie(BaseCookie): ...
class SimpleCookie(BaseCookie[_T], Generic[_T]): ...

View File

@@ -77,8 +77,7 @@ def ismemberdescriptor(object: object) -> bool: ...
#
# Retrieving source code
#
_SourceObjectType = Union[ModuleType, Type, MethodType, FunctionType,
TracebackType, FrameType, CodeType]
_SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType]
def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ...
def getabsfile(object: _SourceObjectType) -> str: ...
@@ -174,7 +173,7 @@ def getclasstree(classes: List[type], unique: bool = ...) -> Any: ...
ArgSpec = NamedTuple('ArgSpec', [('args', List[str]),
('varargs', str),
('keywords', str),
('defaults', tuple),
('defaults', Tuple[Any, ...]),
])
Arguments = NamedTuple('Arguments', [('args', List[str]),
@@ -188,7 +187,7 @@ def getargspec(func: object) -> ArgSpec: ...
FullArgSpec = NamedTuple('FullArgSpec', [('args', List[str]),
('varargs', Optional[str]),
('varkw', Optional[str]),
('defaults', tuple),
('defaults', Tuple[Any, ...]),
('kwonlyargs', List[str]),
('kwonlydefaults', Dict[str, Any]),
('annotations', Dict[str, Any]),

View File

@@ -54,7 +54,7 @@ class _BaseAddress(_IPAddressBase, SupportsInt):
@property
def packed(self) -> bytes: ...
class _BaseNetwork(_IPAddressBase, Container, Iterable[_A], Generic[_A]):
class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
network_address: _A
netmask: _A
def __init__(self, address: object, strict: bool = ...) -> None: ...

View File

@@ -37,7 +37,7 @@ else:
def loads(s: _LoadsString,
encoding: Any = ..., # ignored and deprecated
cls: Optional[Type[JSONDecoder]] = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
@@ -49,7 +49,7 @@ class _Reader(Protocol):
def load(fp: _Reader,
cls: Optional[Type[JSONDecoder]] = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,

View File

@@ -14,7 +14,7 @@ class JSONEncoder:
def __init__(self, skipkeys: bool = ..., ensure_ascii: bool = ...,
check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ...,
indent: Optional[int] = ..., separators: Optional[Tuple[str, str]] = ...,
default: Optional[Callable] = ...) -> None: ...
default: Optional[Callable[..., Any]] = ...) -> None: ...
def default(self, o: Any) -> Any: ...
def encode(self, o: Any) -> str: ...

View File

@@ -26,7 +26,7 @@ import sys
# Sychronization primitives
_LockLike = Union[synchronize.Lock, synchronize.RLock]
def Barrier(parties: int,
action: Optional[Callable] = ...,
action: Optional[Callable[..., Any]] = ...,
timeout: Optional[float] = ...) -> synchronize.Barrier: ...
def BoundedSemaphore(value: int = ...) -> synchronize.BoundedSemaphore: ...
def Condition(lock: Optional[_LockLike] = ...) -> synchronize.Condition: ...
@@ -52,7 +52,7 @@ class Process():
# TODO: set type of group to None
def __init__(self,
group: Any = ...,
target: Optional[Callable] = ...,
target: Optional[Callable[..., Any]] = ...,
name: Optional[str] = ...,
args: Iterable[Any] = ...,
kwargs: Mapping[Any, Any] = ...,

View File

@@ -41,7 +41,7 @@ class BaseContext(object):
def Barrier(self,
parties: int,
action: Optional[Callable] = ...,
action: Optional[Callable[..., Any]] = ...,
timeout: Optional[float] = ...) -> synchronize.Barrier: ...
def BoundedSemaphore(self,
value: int = ...) -> synchronize.BoundedSemaphore: ...
@@ -52,9 +52,9 @@ class BaseContext(object):
def RLock(self) -> synchronize.RLock: ...
def Semaphore(self, value: int = ...) -> synchronize.Semaphore: ...
def Queue(self, maxsize: int = ...) -> queues.Queue: ...
def JoinableQueue(self, maxsize: int = ...) -> queues.JoinableQueue: ...
def SimpleQueue(self) -> queues.SimpleQueue: ...
def Queue(self, maxsize: int = ...) -> queues.Queue[Any]: ...
def JoinableQueue(self, maxsize: int = ...) -> queues.JoinableQueue[Any]: ...
def SimpleQueue(self) -> queues.SimpleQueue[Any]: ...
def Pool(
self,
processes: Optional[int] = ...,
@@ -65,7 +65,7 @@ class BaseContext(object):
def Process(
self,
group: Any = ...,
target: Optional[Callable] = ...,
target: Optional[Callable[..., Any]] = ...,
name: Optional[str] = ...,
args: Iterable[Any] = ...,
kwargs: Mapping[Any, Any] = ...,

View File

@@ -14,7 +14,7 @@ JoinableQueue = Queue
class DummyProcess(threading.Thread):
_children: weakref.WeakKeyDictionary
_children: weakref.WeakKeyDictionary[Any, Any]
_parent: threading.Thread
_pid: None
_start_called: int
@@ -33,10 +33,10 @@ class Value(object):
def __init__(self, typecode, value, lock=...) -> None: ...
def Array(typecode, sequence, lock=...) -> array.array: ...
def Array(typecode, sequence, lock=...) -> array.array[Any]: ...
def Manager() -> Any: ...
def Pool(processes=..., initializer=..., initargs=...) -> Any: ...
def active_children() -> List: ...
def active_children() -> List[Any]: ...
def current_process() -> threading.Thread: ...
def freeze_support() -> None: ...
def shutdown() -> None: ...

View File

@@ -21,9 +21,9 @@ class Connection(object):
def poll(self, timeout: float = ...) -> bool: ...
class Listener(object):
_backlog_queue: Optional[Queue]
_backlog_queue: Optional[Queue[Any]]
@property
def address(self) -> Optional[Queue]: ...
def address(self) -> Optional[Queue[Any]]: ...
def __enter__(self: _TListener) -> _TListener: ...
def __exit__(self, exc_type, exc_value, exc_tb) -> None: ...
def __init__(self, address=..., family=..., backlog=...) -> None: ...

View File

@@ -28,7 +28,7 @@ class BaseManager(ContextManager[BaseManager]):
address: Union[str, Tuple[str, int]]
def connect(self) -> None: ...
@classmethod
def register(cls, typeid: str, callable: Optional[Callable] = ...,
def register(cls, typeid: str, callable: Optional[Callable[..., Any]] = ...,
proxytype: Any = ...,
exposed: Optional[Sequence[str]] = ...,
method_to_typeid: Optional[Mapping[str, str]] = ...,
@@ -43,7 +43,7 @@ class SyncManager(BaseManager, ContextManager[SyncManager]):
def Event(self) -> threading.Event: ...
def Lock(self) -> threading.Lock: ...
def Namespace(self) -> _Namespace: ...
def Queue(self, maxsize: int = ...) -> queue.Queue: ...
def Queue(self, maxsize: int = ...) -> queue.Queue[Any]: ...
def RLock(self) -> threading.RLock: ...
def Semaphore(self, value: Any = ...) -> threading.Semaphore: ...
def Array(self, typecode: Any, sequence: Sequence[_T]) -> Sequence[_T]: ...

View File

@@ -19,14 +19,12 @@ AsyncResult = ApplyResult
class MapResult(ApplyResult[List[_T]]): ...
_IMIT = TypeVar('_IMIT', bound=IMapIterator)
class IMapIterator(Iterator[_T]):
def __iter__(self: _IMIT) -> _IMIT: ...
def __iter__(self: _S) -> _S: ...
def next(self, timeout: Optional[float] = ...) -> _T: ...
def __next__(self, timeout: Optional[float] = ...) -> _T: ...
class IMapUnorderedIterator(IMapIterator): ...
class IMapUnorderedIterator(IMapIterator[_T]): ...
class Pool(ContextManager[Pool]):
def __init__(self, processes: Optional[int] = ...,

View File

@@ -1,4 +1,4 @@
from typing import Callable, ContextManager, Optional, Union
from typing import Any, Callable, ContextManager, Optional, Union
from multiprocessing.context import BaseContext
import threading
@@ -9,7 +9,7 @@ _LockLike = Union[Lock, RLock]
class Barrier(threading.Barrier):
def __init__(self,
parties: int,
action: Optional[Callable] = ...,
action: Optional[Callable[..., Any]] = ...,
timeout: Optional[float] = ...,
*
ctx: BaseContext) -> None: ...

View File

@@ -282,12 +282,12 @@ if sys.platform != 'win32':
# ----- os function stubs -----
if sys.version_info >= (3, 6):
def fsencode(filename: Union[str, bytes, PathLike]) -> bytes: ...
def fsencode(filename: Union[str, bytes, PathLike[Any]]) -> bytes: ...
else:
def fsencode(filename: Union[str, bytes]) -> bytes: ...
if sys.version_info >= (3, 6):
def fsdecode(filename: Union[str, bytes, PathLike]) -> str: ...
def fsdecode(filename: Union[str, bytes, PathLike[Any]]) -> str: ...
else:
def fsdecode(filename: Union[str, bytes]) -> str: ...
@@ -297,7 +297,7 @@ if sys.version_info >= (3, 6):
@overload
def fspath(path: bytes) -> bytes: ...
@overload
def fspath(path: PathLike) -> Any: ...
def fspath(path: PathLike[Any]) -> Any: ...
def get_exec_path(env: Optional[Mapping[str, str]] = ...) -> List[str]: ...
# NOTE: get_exec_path(): returns List[bytes] when env not None
@@ -506,32 +506,34 @@ def utime(
follow_symlinks: bool = ...,
) -> None: ...
_OnError = Callable[[OSError], Any]
if sys.version_info >= (3, 6):
def walk(top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ...,
onerror: Optional[Callable[[OSError], Any]] = ...,
onerror: Optional[_OnError] = ...,
followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr],
List[AnyStr]]]: ...
else:
def walk(top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ...,
def walk(top: AnyStr, topdown: bool = ..., onerror: Optional[_OnError] = ...,
followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr],
List[AnyStr]]]: ...
if sys.platform != 'win32':
if sys.version_info >= (3, 7):
@overload
def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ...,
onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ...,
onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ...,
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
@overload
def fwalk(top: bytes, topdown: bool = ...,
onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ...,
onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ...,
dir_fd: Optional[int] = ...) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ...
elif sys.version_info >= (3, 6):
def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ...,
onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ...,
onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ...,
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
else:
def fwalk(top: str = ..., topdown: bool = ...,
onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ...,
onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ...,
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
def getxattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> bytes: ... # Linux only
def listxattr(path: _FdOrPathType, *, follow_symlinks: bool = ...) -> List[str]: ... # Linux only

View File

@@ -2,9 +2,8 @@
# NOTE: These are incomplete!
from collections import deque
from threading import Condition, Lock
from typing import Any, TypeVar, Generic, Optional
from typing import Any, Deque, TypeVar, Generic, Optional
import sys
_T = TypeVar('_T')
@@ -21,7 +20,7 @@ class Queue(Generic[_T]):
all_tasks_done: Condition # undocumented
unfinished_tasks: int # undocumented
queue: deque # undocumented
queue: Deque[Any] # undocumented
def __init__(self, maxsize: int = ...) -> None: ...
def _init(self, maxsize: int) -> None: ...
def empty(self) -> bool: ...

View File

@@ -8,17 +8,15 @@
import _random
import sys
from typing import (
Any, TypeVar, Sequence, List, Callable, AbstractSet, Union, Optional
)
from typing import Any, TypeVar, Sequence, List, Callable, AbstractSet, Union, Optional, Tuple
_T = TypeVar('_T')
class Random(_random.Random):
def __init__(self, x: Any = ...) -> None: ...
def seed(self, a: Any = ..., version: int = ...) -> None: ...
def getstate(self) -> tuple: ...
def setstate(self, state: tuple) -> None: ...
def getstate(self) -> Tuple[Any, ...]: ...
def setstate(self, state: Tuple[Any, ...]) -> None: ...
def getrandbits(self, k: int) -> int: ...
def randrange(self, start: int, stop: Union[int, None] = ..., step: int = ...) -> int: ...
def randint(self, a: int, b: int) -> int: ...

View File

@@ -24,7 +24,7 @@ class Repr:
def repr1(self, x: Any, level: int) -> str: ...
def repr_tuple(self, x: Tuple[Any, ...], level: int) -> str: ...
def repr_list(self, x: List[Any], level: int) -> str: ...
def repr_array(self, x: array, level: int) -> str: ...
def repr_array(self, x: array[Any], level: int) -> str: ...
def repr_set(self, x: Set[Any], level: int) -> str: ...
def repr_frozenset(self, x: FrozenSet[Any], level: int) -> str: ...
def repr_deque(self, x: Deque[Any], level: int) -> str: ...

View File

@@ -2,7 +2,7 @@ from typing import Any, Dict, Iterator, Optional, Tuple
import collections
class Shelf(collections.MutableMapping):
class Shelf(collections.MutableMapping[Any, Any]):
def __init__(self, dict: Dict[bytes, Any], protocol: Optional[int] = ..., writeback: bool = ..., keyencoding: str = ...) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def __len__(self) -> int: ...

View File

@@ -77,5 +77,5 @@ class Tokenizer:
def fix_flags(src: Union[str, bytes], flag: int) -> int: ...
def parse(str: str, flags: int = ..., pattern: Pattern = ...) -> SubPattern: ...
_TemplateType = Tuple[List[Tuple[int, int]], List[str]]
def parse_template(source: str, pattern: _Pattern) -> _TemplateType: ...
def expand_template(template: _TemplateType, match: Match) -> str: ...
def parse_template(source: str, pattern: _Pattern[Any]) -> _TemplateType: ...
def expand_template(template: _TemplateType, match: Match[Any]) -> str: ...

View File

@@ -40,6 +40,7 @@ else:
_CMD = Union[_TXT, Sequence[_PATH]]
_ENV = Union[Mapping[bytes, _TXT], Mapping[Text, _TXT]]
_S = TypeVar('_S')
_T = TypeVar('_T')
class CompletedProcess(Generic[_T]):
@@ -1169,7 +1170,7 @@ class Popen(Generic[AnyStr]):
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
def __enter__(self) -> Popen: ...
def __enter__(self: _S) -> _S: ...
def __exit__(self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]) -> None: ...
# The result really is always a str.

View File

@@ -18,6 +18,7 @@ TMP_MAX: int
tempdir: Optional[str]
template: str
_S = TypeVar("_S")
_T = TypeVar("_T") # for pytype, define typevar in same file as alias
if sys.version_info >= (3, 6):
_DirT = Union[_T, os.PathLike[_T]]
@@ -98,7 +99,7 @@ class SpooledTemporaryFile(IO[AnyStr]):
prefix: Optional[str] = ..., dir: Optional[str] = ...
) -> None: ...
def rollover(self) -> None: ...
def __enter__(self) -> SpooledTemporaryFile: ...
def __enter__(self: _S) -> _S: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...

View File

@@ -45,7 +45,7 @@ def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, N
if sys.version_info >= (3, 6):
from os import PathLike
def open(filename: Union[str, bytes, int, PathLike]) -> TextIO: ...
def open(filename: Union[str, bytes, int, PathLike[Any]]) -> TextIO: ...
else:
def open(filename: Union[str, bytes, int]) -> TextIO: ...

View File

@@ -147,7 +147,7 @@ class MethodType:
__self__: object
__name__: str
__qualname__: str
def __init__(self, func: Callable, obj: object) -> None: ...
def __init__(self, func: Callable[..., Any], obj: object) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
class BuiltinFunctionType:
__self__: Union[object, ModuleType]

View File

@@ -75,7 +75,7 @@ _KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers.
_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers.
_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant.
_TC = TypeVar('_TC', bound=Type[object])
_C = TypeVar("_C", bound=Callable)
_C = TypeVar("_C", bound=Callable[..., Any])
def runtime_checkable(cls: _TC) -> _TC: ...
@@ -166,7 +166,7 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
@property
def gi_running(self) -> bool: ...
@property
def gi_yieldfrom(self) -> Optional[Generator]: ...
def gi_yieldfrom(self) -> Optional[Generator[Any, Any, Any]]: ...
@runtime_checkable
class Awaitable(Protocol[_T_co]):
@@ -581,8 +581,9 @@ class Pattern(Generic[AnyStr]):
# Functions
def get_type_hints(obj: Callable, globalns: Optional[dict[str, Any]] = ...,
localns: Optional[dict[str, Any]] = ...) -> dict[str, Any]: ...
def get_type_hints(
obj: Callable[..., Any], globalns: Optional[Dict[str, Any]] = ..., localns: Optional[Dict[str, Any]] = ...,
) -> Dict[str, Any]: ...
@overload
def cast(tp: Type[_T], obj: Any) -> _T: ...
@@ -592,7 +593,7 @@ def cast(tp: str, obj: Any) -> Any: ...
# Type constructors
# NamedTuple is special-cased in the type checker
class NamedTuple(tuple):
class NamedTuple(Tuple[Any, ...]):
_field_types: collections.OrderedDict[str, Type[Any]]
_field_defaults: Dict[str, Any] = ...
_fields: Tuple[str, ...]

View File

@@ -1,7 +1,9 @@
# Stubs for mock
import sys
from typing import Any, Optional, Text, Type
from typing import Any, List, Optional, Text, Tuple, Type, TypeVar
_T = TypeVar("_T")
FILTER_DIR: Any
@@ -18,7 +20,7 @@ class _Sentinel:
sentinel: Any
DEFAULT: Any
class _CallList(list):
class _CallList(List[_T]):
def __contains__(self, value: Any) -> bool: ...
class _MockIter:
@@ -111,7 +113,7 @@ class _ANY:
ANY: Any
class _Call(tuple):
class _Call(Tuple[Any, ...]):
def __new__(cls, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ...) -> Any: ...
name: Any
parent: Any

View File

@@ -35,7 +35,7 @@ class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ...
class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes): ...
class _DefragResultBase(tuple, Generic[AnyStr]):
class _DefragResultBase(Tuple[Any, ...], Generic[AnyStr]):
url: AnyStr
fragment: AnyStr

View File

@@ -202,7 +202,7 @@ class HTTPErrorProcessor(BaseHandler):
def https_response(self, request, response) -> _UrlopenRet: ...
if sys.version_info >= (3, 6):
def urlretrieve(url: str, filename: Optional[Union[str, os.PathLike]] = ...,
def urlretrieve(url: str, filename: Optional[Union[str, os.PathLike[Any]]] = ...,
reporthook: Optional[Callable[[int, int, int], None]] = ...,
data: Optional[bytes] = ...) -> Tuple[str, HTTPMessage]: ...
else: