Various stubtest exceptions (#5227)

This commit is contained in:
hatal175
2021-04-17 17:03:28 +03:00
committed by GitHub
parent 4d734e38dd
commit c9d996fe55
10 changed files with 108 additions and 70 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -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] = ...,

View File

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

View File

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

View File

@@ -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

View File

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

View File

@@ -251,39 +251,24 @@ tempfile.SpooledTemporaryFile.__next__
tempfile.SpooledTemporaryFile.readable
tempfile.SpooledTemporaryFile.seekable
tempfile.SpooledTemporaryFile.writable
threading.Condition.acquire
threading.Condition.release
threading.Lock
threading.Semaphore.__enter__
threading.Semaphore.acquire
threading.Thread.__init__
timeit.main
tkinter.Misc.grid_propagate
tkinter.Misc.pack_propagate
threading.Condition.acquire # Condition functions are exported in __init__
threading.Condition.release # Condition functions are exported in __init__
threading.Lock # A factory function that returns 'most efficient lock'. Marking it as a function will make it harder for users to mark the Lock type.
tkinter.Misc.grid_propagate # The noarg placeholder is a set value list
tkinter.Misc.pack_propagate # The noarg placeholder is a set value list
tkinter.Tk.eval # from __getattr__
tkinter.Tk.report_callback_exception # A bit of a lie, since it's actually a method, but typing it as an attribute allows it to be assigned to
tkinter.Wm.wm_iconphoto # Default value of argument can't be used without runtime error
tkinter.font.Font.__getitem__ # Argument name differs (doesn't matter for __dunder__ methods)
trace.CoverageResults.__init__
traceback.FrameSummary.__init__
traceback.TracebackException.__init__
traceback.TracebackException.from_exception
types.GetSetDescriptorType.__get__
types.GetSetDescriptorType.__set__
types.MemberDescriptorType.__get__
types.MemberDescriptorType.__set__
types.SimpleNamespace.__init__
types.coroutine
types.new_class
types.prepare_class
typing.AwaitableGenerator
typing.IO.__iter__
typing.IO.__next__
typing.type_check_only
traceback.TracebackException.from_exception # explicitly expanding arguemnts going into TracebackException __init__
types.GetSetDescriptorType.__get__ # this function can accept no value for the type parameter.
types.MemberDescriptorType.__get__ # this function can accept no value for the type parameter.
types.SimpleNamespace.__init__ # class doesn't accept positional arguments but has default C signature
typing.IO.__iter__ # Added because IO streams are iterable. See https://github.com/python/typeshed/commit/97bc450acd60c1bcdafef3ce8fbe3b95a9c0cac3
typing.IO.__next__ # Added because IO streams are iterable. See https://github.com/python/typeshed/commit/97bc450acd60c1bcdafef3ce8fbe3b95a9c0cac3
typing.type_check_only # typing decorator that is not available at runtime
unittest.mock.patch # It's a complicated overload and I haven't been able to figure out why stubtest doesn't like it
urllib.error.ContentTooShortError.__init__
urllib.error.URLError.__init__
urllib.parse._DefragResultBase.__new__
urllib.parse._DefragResultBase.__new__ # Generic NamedTuple is problematic in mypy, so regular tuple was used. See https://github.com/python/mypy/issues/685
# The following methods were changed in point releases from Python 3.6 to 3.9
# as part of a security fix. These excludes can be removed when the GitHub
# action workflow uses Python versions that include the fix (adding a
@@ -293,7 +278,7 @@ urllib.parse.parse_qsl
urllib.request.BaseHandler.http_error_nnn
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__
urllib.robotparser.RobotFileParser.can_fetch
warnings.catch_warnings.__init__
warnings.catch_warnings.__init__ # Defining this ruins the __new__ overrides
weakref.CallableProxyType.__getattr__
weakref.ProxyType.__getattr__
weakref.ReferenceType.__call__
@@ -306,9 +291,6 @@ webbrowser.UnixBrowser.remote_action
webbrowser.UnixBrowser.remote_action_newtab
webbrowser.UnixBrowser.remote_action_newwin
wsgiref.types # Doesn't exist, see comments in file
zipfile.ZipExtFile.read
zipfile.ZipExtFile.readline
zlib.compressobj
# These enums derive from (int, IntEnum) or (str, Enum). Strangely,
# at runtime, they inherit Enum.__new__, not int.__new__ or