mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-21 11:21:19 +08:00
Various stubtest exceptions (#5227)
This commit is contained in:
@@ -54,7 +54,7 @@ class Thread:
|
||||
target: Optional[Callable[..., Any]] = ...,
|
||||
name: Optional[str] = ...,
|
||||
args: Iterable[Any] = ...,
|
||||
kwargs: Mapping[str, Any] = ...,
|
||||
kwargs: Optional[Mapping[str, Any]] = ...,
|
||||
*,
|
||||
daemon: Optional[bool] = ...,
|
||||
) -> None: ...
|
||||
@@ -65,7 +65,7 @@ class Thread:
|
||||
target: Optional[Callable[..., Any]] = ...,
|
||||
name: Optional[Text] = ...,
|
||||
args: Iterable[Any] = ...,
|
||||
kwargs: Mapping[Text, Any] = ...,
|
||||
kwargs: Optional[Mapping[Text, Any]] = ...,
|
||||
) -> None: ...
|
||||
def start(self) -> None: ...
|
||||
def run(self) -> None: ...
|
||||
@@ -130,14 +130,15 @@ class Condition:
|
||||
|
||||
class Semaphore:
|
||||
def __init__(self, value: int = ...) -> None: ...
|
||||
def __enter__(self) -> bool: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> Optional[bool]: ...
|
||||
if sys.version_info >= (3,):
|
||||
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
|
||||
def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ...
|
||||
def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ...
|
||||
else:
|
||||
def acquire(self, blocking: bool = ...) -> bool: ...
|
||||
def __enter__(self, blocking: bool = ...) -> bool: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def release(self, n: int = ...) -> None: ...
|
||||
else:
|
||||
|
||||
@@ -54,7 +54,7 @@ class Thread:
|
||||
target: Optional[Callable[..., Any]] = ...,
|
||||
name: Optional[str] = ...,
|
||||
args: Iterable[Any] = ...,
|
||||
kwargs: Mapping[str, Any] = ...,
|
||||
kwargs: Optional[Mapping[str, Any]] = ...,
|
||||
*,
|
||||
daemon: Optional[bool] = ...,
|
||||
) -> None: ...
|
||||
@@ -65,7 +65,7 @@ class Thread:
|
||||
target: Optional[Callable[..., Any]] = ...,
|
||||
name: Optional[Text] = ...,
|
||||
args: Iterable[Any] = ...,
|
||||
kwargs: Mapping[Text, Any] = ...,
|
||||
kwargs: Optional[Mapping[Text, Any]] = ...,
|
||||
) -> None: ...
|
||||
def start(self) -> None: ...
|
||||
def run(self) -> None: ...
|
||||
@@ -130,14 +130,15 @@ class Condition:
|
||||
|
||||
class Semaphore:
|
||||
def __init__(self, value: int = ...) -> None: ...
|
||||
def __enter__(self) -> bool: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> Optional[bool]: ...
|
||||
if sys.version_info >= (3,):
|
||||
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
|
||||
def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ...
|
||||
def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ...
|
||||
else:
|
||||
def acquire(self, blocking: bool = ...) -> bool: ...
|
||||
def __enter__(self, blocking: bool = ...) -> bool: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def release(self, n: int = ...) -> None: ...
|
||||
else:
|
||||
|
||||
@@ -39,4 +39,6 @@ else:
|
||||
stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., repeat: int = ..., number: int = ...
|
||||
) -> List[float]: ...
|
||||
|
||||
def main(args: Optional[Sequence[str]]) -> None: ...
|
||||
_timerFunc = Callable[[], float]
|
||||
|
||||
def main(args: Optional[Sequence[str]] = ..., *, _wrap_timer: Optional[Callable[[_timerFunc], _timerFunc]] = ...) -> None: ...
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
import types
|
||||
from _typeshed import StrPath
|
||||
from typing import Any, Callable, Mapping, Optional, Sequence, Tuple, TypeVar, Union
|
||||
from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, TypeVar, Union
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]]
|
||||
_fileModuleFunction = Tuple[str, Optional[str], str]
|
||||
|
||||
class CoverageResults:
|
||||
def __init__(
|
||||
self,
|
||||
counts: Optional[Dict[Tuple[str, int], int]] = ...,
|
||||
calledfuncs: Optional[Dict[_fileModuleFunction, int]] = ...,
|
||||
infile: Optional[StrPath] = ...,
|
||||
callers: Optional[Dict[Tuple[_fileModuleFunction, _fileModuleFunction], int]] = ...,
|
||||
outfile: Optional[StrPath] = ...,
|
||||
) -> None: ... # undocumented
|
||||
def update(self, other: CoverageResults) -> None: ...
|
||||
def write_results(self, show_missing: bool = ..., summary: bool = ..., coverdir: Optional[StrPath] = ...) -> None: ...
|
||||
def write_results_file(
|
||||
@@ -33,7 +42,7 @@ class Trace:
|
||||
locals: Optional[Mapping[str, Any]] = ...,
|
||||
) -> None: ...
|
||||
def runfunc(self, func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ...
|
||||
def file_module_function_of(self, frame: types.FrameType) -> Tuple[str, Optional[str], str]: ...
|
||||
def file_module_function_of(self, frame: types.FrameType) -> _fileModuleFunction: ...
|
||||
def globaltrace_trackcallers(self, frame: types.FrameType, why: str, arg: Any) -> None: ...
|
||||
def globaltrace_countfuncs(self, frame: types.FrameType, why: str, arg: Any) -> None: ...
|
||||
def globaltrace_lt(self, frame: types.FrameType, why: str, arg: Any) -> None: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import SupportsWrite
|
||||
from types import FrameType, TracebackType
|
||||
from typing import IO, Any, Dict, Generator, Iterable, Iterator, List, Mapping, Optional, Tuple, Type
|
||||
from typing import IO, Any, Dict, Generator, Iterable, Iterator, List, Mapping, Optional, Set, Tuple, Type
|
||||
|
||||
_PT = Tuple[str, int, str, Optional[str]]
|
||||
|
||||
@@ -90,20 +90,45 @@ if sys.version_info >= (3, 5):
|
||||
text: str
|
||||
offset: int
|
||||
msg: str
|
||||
def __init__(
|
||||
self,
|
||||
exc_type: Type[BaseException],
|
||||
exc_value: BaseException,
|
||||
exc_traceback: TracebackType,
|
||||
*,
|
||||
limit: Optional[int] = ...,
|
||||
lookup_lines: bool = ...,
|
||||
capture_locals: bool = ...,
|
||||
) -> None: ...
|
||||
@classmethod
|
||||
def from_exception(
|
||||
cls, exc: BaseException, *, limit: Optional[int] = ..., lookup_lines: bool = ..., capture_locals: bool = ...
|
||||
) -> TracebackException: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
def __init__(
|
||||
self,
|
||||
exc_type: Type[BaseException],
|
||||
exc_value: BaseException,
|
||||
exc_traceback: TracebackType,
|
||||
*,
|
||||
limit: Optional[int] = ...,
|
||||
lookup_lines: bool = ...,
|
||||
capture_locals: bool = ...,
|
||||
compact: bool = ...,
|
||||
_seen: Optional[Set[int]] = ...,
|
||||
) -> None: ...
|
||||
@classmethod
|
||||
def from_exception(
|
||||
cls,
|
||||
exc: BaseException,
|
||||
*,
|
||||
limit: Optional[int] = ...,
|
||||
lookup_lines: bool = ...,
|
||||
capture_locals: bool = ...,
|
||||
compact: bool = ...,
|
||||
) -> TracebackException: ...
|
||||
else:
|
||||
def __init__(
|
||||
self,
|
||||
exc_type: Type[BaseException],
|
||||
exc_value: BaseException,
|
||||
exc_traceback: TracebackType,
|
||||
*,
|
||||
limit: Optional[int] = ...,
|
||||
lookup_lines: bool = ...,
|
||||
capture_locals: bool = ...,
|
||||
_seen: Optional[Set[int]] = ...,
|
||||
) -> None: ...
|
||||
@classmethod
|
||||
def from_exception(
|
||||
cls, exc: BaseException, *, limit: Optional[int] = ..., lookup_lines: bool = ..., capture_locals: bool = ...
|
||||
) -> TracebackException: ...
|
||||
def format(self, *, chain: bool = ...) -> Generator[str, None, None]: ...
|
||||
def format_exception_only(self) -> Generator[str, None, None]: ...
|
||||
class FrameSummary(Iterable[Any]):
|
||||
@@ -117,6 +142,7 @@ if sys.version_info >= (3, 5):
|
||||
filename: str,
|
||||
lineno: int,
|
||||
name: str,
|
||||
*,
|
||||
lookup_line: bool = ...,
|
||||
locals: Optional[Mapping[str, str]] = ...,
|
||||
line: Optional[str] = ...,
|
||||
|
||||
@@ -273,36 +273,42 @@ class FrameType:
|
||||
class GetSetDescriptorType:
|
||||
__name__: str
|
||||
__objclass__: type
|
||||
def __get__(self, obj: Any, type: type = ...) -> Any: ...
|
||||
def __set__(self, obj: Any) -> None: ...
|
||||
def __get__(self, __obj: Any, __type: type = ...) -> Any: ...
|
||||
def __set__(self, __instance: Any, __value: Any) -> None: ...
|
||||
def __delete__(self, obj: Any) -> None: ...
|
||||
|
||||
class MemberDescriptorType:
|
||||
__name__: str
|
||||
__objclass__: type
|
||||
def __get__(self, obj: Any, type: type = ...) -> Any: ...
|
||||
def __set__(self, obj: Any) -> None: ...
|
||||
def __get__(self, __obj: Any, __type: type = ...) -> Any: ...
|
||||
def __set__(self, __instance: Any, __value: Any) -> None: ...
|
||||
def __delete__(self, obj: Any) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def new_class(
|
||||
name: str, bases: Iterable[object] = ..., kwds: Dict[str, Any] = ..., exec_body: Callable[[Dict[str, Any]], None] = ...
|
||||
name: str,
|
||||
bases: Iterable[object] = ...,
|
||||
kwds: Optional[Dict[str, Any]] = ...,
|
||||
exec_body: Optional[Callable[[Dict[str, Any]], None]] = ...,
|
||||
) -> type: ...
|
||||
def resolve_bases(bases: Iterable[object]) -> Tuple[Any, ...]: ...
|
||||
|
||||
else:
|
||||
def new_class(
|
||||
name: str, bases: Tuple[type, ...] = ..., kwds: Dict[str, Any] = ..., exec_body: Callable[[Dict[str, Any]], None] = ...
|
||||
name: str,
|
||||
bases: Tuple[type, ...] = ...,
|
||||
kwds: Optional[Dict[str, Any]] = ...,
|
||||
exec_body: Optional[Callable[[Dict[str, Any]], None]] = ...,
|
||||
) -> type: ...
|
||||
|
||||
def prepare_class(
|
||||
name: str, bases: Tuple[type, ...] = ..., kwds: Dict[str, Any] = ...
|
||||
name: str, bases: Tuple[type, ...] = ..., kwds: Optional[Dict[str, Any]] = ...
|
||||
) -> Tuple[type, Dict[str, Any], Dict[str, Any]]: ...
|
||||
|
||||
# Actually a different type, but `property` is special and we want that too.
|
||||
DynamicClassAttribute = property
|
||||
|
||||
def coroutine(f: Callable[..., Any]) -> CoroutineType: ...
|
||||
def coroutine(func: Callable[..., Any]) -> CoroutineType: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
class GenericAlias:
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
from typing import IO, Mapping, Optional, Union
|
||||
from email.message import Message
|
||||
from typing import IO, Mapping, Optional, Tuple, Union
|
||||
from urllib.response import addinfourl
|
||||
|
||||
# Stubs for urllib.error
|
||||
|
||||
class URLError(IOError):
|
||||
reason: Union[str, BaseException]
|
||||
def __init__(self, reason: Union[str, BaseException], filename: Optional[str] = ...) -> None: ...
|
||||
|
||||
class HTTPError(URLError, addinfourl):
|
||||
code: int
|
||||
def __init__(self, url: str, code: int, msg: str, hdrs: Mapping[str, str], fp: Optional[IO[bytes]]) -> None: ...
|
||||
|
||||
class ContentTooShortError(URLError): ...
|
||||
class ContentTooShortError(URLError):
|
||||
content: Tuple[str, Message]
|
||||
def __init__(self, message: str, content: Tuple[str, Message]) -> None: ...
|
||||
|
||||
@@ -59,6 +59,8 @@ class ZipExtFile(io.BufferedIOBase):
|
||||
decrypter: Optional[Callable[[Sequence[int]], bytes]] = ...,
|
||||
close_fileobj: bool = ...,
|
||||
) -> None: ...
|
||||
def read(self, n: Optional[int] = ...) -> bytes: ...
|
||||
def readline(self, limit: int = ...) -> bytes: ... # type: ignore
|
||||
def __repr__(self) -> str: ...
|
||||
def peek(self, n: int = ...) -> bytes: ...
|
||||
def read1(self, n: Optional[int]) -> bytes: ... # type: ignore
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
from array import array
|
||||
from typing import Any, Union
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
DEFLATED: int
|
||||
DEF_MEM_LEVEL: int
|
||||
@@ -43,7 +43,12 @@ def compress(__data: bytes, level: int = ...) -> bytes: ...
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
def compressobj(
|
||||
level: int = ..., method: int = ..., wbits: int = ..., memLevel: int = ..., strategy: int = ..., zdict: bytes = ...
|
||||
level: int = ...,
|
||||
method: int = ...,
|
||||
wbits: int = ...,
|
||||
memLevel: int = ...,
|
||||
strategy: int = ...,
|
||||
zdict: Optional[bytes] = ...,
|
||||
) -> _Compress: ...
|
||||
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user