Skip to content

Commit 3c91647

Browse files
authored
Sync typeshed (#10383)
Source commit: python/typeshed@8bd3e16
1 parent e14cb14 commit 3c91647

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+424
-354
lines changed

mypy/typeshed/stdlib/@python2/__builtin__.pyi

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ from typing import (
4343
Union,
4444
ValuesView,
4545
overload,
46-
runtime_checkable,
4746
)
4847
from typing_extensions import Literal
4948

@@ -838,15 +837,6 @@ def cmp(__x: Any, __y: Any) -> int: ...
838837
_N1 = TypeVar("_N1", bool, int, float, complex)
839838

840839
def coerce(__x: _N1, __y: _N1) -> Tuple[_N1, _N1]: ...
841-
842-
# This class is to be exported as PathLike from os,
843-
# but we define it here as _PathLike to avoid import cycle issues.
844-
# See https://github.com/python/typeshed/pull/991#issuecomment-288160993
845-
_AnyStr_co = TypeVar("_AnyStr_co", str, bytes, covariant=True)
846-
@runtime_checkable
847-
class _PathLike(Protocol[_AnyStr_co]):
848-
def __fspath__(self) -> _AnyStr_co: ...
849-
850840
def compile(source: Union[Text, mod], filename: Text, mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ...
851841
def delattr(__obj: Any, __name: Text) -> None: ...
852842
def dir(__o: object = ...) -> List[str]: ...
@@ -1017,11 +1007,7 @@ def round(number: SupportsFloat) -> float: ...
10171007
def round(number: SupportsFloat, ndigits: int) -> float: ...
10181008
def setattr(__obj: Any, __name: Text, __value: Any) -> None: ...
10191009
def sorted(
1020-
__iterable: Iterable[_T],
1021-
*,
1022-
cmp: Callable[[_T, _T], int] = ...,
1023-
key: Optional[Callable[[_T], Any]] = ...,
1024-
reverse: bool = ...,
1010+
__iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ...
10251011
) -> List[_T]: ...
10261012
@overload
10271013
def sum(__iterable: Iterable[_T]) -> Union[_T, int]: ...

mypy/typeshed/stdlib/@python2/_functools.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from typing import Any, Callable, Dict, Iterable, Optional, Tuple, TypeVar, over
22

33
_T = TypeVar("_T")
44
_S = TypeVar("_S")
5+
56
@overload
67
def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T]) -> _T: ...
78
@overload

mypy/typeshed/stdlib/@python2/builtins.pyi

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ from typing import (
4343
Union,
4444
ValuesView,
4545
overload,
46-
runtime_checkable,
4746
)
4847
from typing_extensions import Literal
4948

@@ -838,15 +837,6 @@ def cmp(__x: Any, __y: Any) -> int: ...
838837
_N1 = TypeVar("_N1", bool, int, float, complex)
839838

840839
def coerce(__x: _N1, __y: _N1) -> Tuple[_N1, _N1]: ...
841-
842-
# This class is to be exported as PathLike from os,
843-
# but we define it here as _PathLike to avoid import cycle issues.
844-
# See https://github.com/python/typeshed/pull/991#issuecomment-288160993
845-
_AnyStr_co = TypeVar("_AnyStr_co", str, bytes, covariant=True)
846-
@runtime_checkable
847-
class _PathLike(Protocol[_AnyStr_co]):
848-
def __fspath__(self) -> _AnyStr_co: ...
849-
850840
def compile(source: Union[Text, mod], filename: Text, mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ...
851841
def delattr(__obj: Any, __name: Text) -> None: ...
852842
def dir(__o: object = ...) -> List[str]: ...
@@ -1017,11 +1007,7 @@ def round(number: SupportsFloat) -> float: ...
10171007
def round(number: SupportsFloat, ndigits: int) -> float: ...
10181008
def setattr(__obj: Any, __name: Text, __value: Any) -> None: ...
10191009
def sorted(
1020-
__iterable: Iterable[_T],
1021-
*,
1022-
cmp: Callable[[_T, _T], int] = ...,
1023-
key: Optional[Callable[[_T], Any]] = ...,
1024-
reverse: bool = ...,
1010+
__iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ...
10251011
) -> List[_T]: ...
10261012
@overload
10271013
def sum(__iterable: Iterable[_T]) -> Union[_T, int]: ...

mypy/typeshed/stdlib/@python2/functools.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ _AnyCallable = Callable[..., Any]
55

66
_T = TypeVar("_T")
77
_S = TypeVar("_S")
8+
89
@overload
910
def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T]) -> _T: ...
1011
@overload

mypy/typeshed/stdlib/@python2/itertools.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ _T3 = TypeVar("_T3")
3838
_T4 = TypeVar("_T4")
3939
_T5 = TypeVar("_T5")
4040
_T6 = TypeVar("_T6")
41+
4142
@overload
4243
def imap(func: Callable[[_T1], _S], iter1: Iterable[_T1]) -> Iterator[_S]: ...
4344
@overload

mypy/typeshed/stdlib/@python2/logging/__init__.pyi

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,13 @@ class Logger(Filterer):
7373
) -> None: ...
7474
fatal = critical
7575
def log(
76-
self,
77-
level: int,
78-
msg: Any,
79-
*args: Any,
80-
exc_info: _ExcInfoType = ...,
81-
extra: Optional[Dict[str, Any]] = ...,
82-
**kwargs: Any,
76+
self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any
8377
) -> None: ...
8478
def exception(
8579
self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any
8680
) -> None: ...
8781
def _log(
88-
self,
89-
level: int,
90-
msg: Any,
91-
args: _ArgsType,
92-
exc_info: Optional[_ExcInfoType] = ...,
93-
extra: Optional[Dict[str, Any]] = ...,
82+
self, level: int, msg: Any, args: _ArgsType, exc_info: Optional[_ExcInfoType] = ..., extra: Optional[Dict[str, Any]] = ...
9483
) -> None: ... # undocumented
9584
def filter(self, record: LogRecord) -> bool: ...
9685
def addHandler(self, hdlr: Handler) -> None: ...
@@ -210,13 +199,7 @@ class LoggerAdapter:
210199
self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any
211200
) -> None: ...
212201
def log(
213-
self,
214-
level: int,
215-
msg: Any,
216-
*args: Any,
217-
exc_info: _ExcInfoType = ...,
218-
extra: Optional[Dict[str, Any]] = ...,
219-
**kwargs: Any,
202+
self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any
220203
) -> None: ...
221204
def isEnabledFor(self, level: int) -> bool: ...
222205

mypy/typeshed/stdlib/@python2/os/__init__.pyi

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ if sys.platform != "win32":
153153
TMP_MAX: int # Undocumented, but used by tempfile
154154

155155
# ----- os classes (structures) -----
156-
if sys.version_info >= (3, 6):
157-
from builtins import _PathLike
158-
159-
PathLike = _PathLike # See comment in builtins
160-
161156
class _StatVFS(NamedTuple):
162157
f_bsize: int
163158
f_frsize: int

mypy/typeshed/stdlib/_ast.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class mod(AST): ...
2525

2626
if sys.version_info >= (3, 8):
2727
class type_ignore(AST): ...
28-
class TypeIgnore(type_ignore): ...
28+
class TypeIgnore(type_ignore):
29+
tag: str
2930
class FunctionType(mod):
3031
argtypes: typing.List[expr]
3132
returns: expr

mypy/typeshed/stdlib/_typeshed/__init__.pyi

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,7 @@ OpenTextModeUpdating = Literal[
104104
"t+x",
105105
"+tx",
106106
]
107-
OpenTextModeWriting = Literal[
108-
"w",
109-
"wt",
110-
"tw",
111-
"a",
112-
"at",
113-
"ta",
114-
"x",
115-
"xt",
116-
"tx",
117-
]
107+
OpenTextModeWriting = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"]
118108
OpenTextModeReading = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"]
119109
OpenTextMode = Union[OpenTextModeUpdating, OpenTextModeWriting, OpenTextModeReading]
120110
OpenBinaryModeUpdating = Literal[

mypy/typeshed/stdlib/abc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _FuncT = TypeVar("_FuncT", bound=Callable[..., Any])
77
class ABCMeta(type):
88
def register(cls: ABCMeta, subclass: Type[_T]) -> Type[_T]: ...
99

10-
def abstractmethod(callable: _FuncT) -> _FuncT: ...
10+
def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
1111

1212
class abstractproperty(property): ...
1313

mypy/typeshed/stdlib/asyncio/base_events.pyi

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ class Server(AbstractServer):
3333
ssl_handshake_timeout: Optional[float],
3434
) -> None: ...
3535
else:
36-
def __init__(
37-
self,
38-
loop: AbstractEventLoop,
39-
sockets: List[socket],
40-
) -> None: ...
36+
def __init__(self, loop: AbstractEventLoop, sockets: List[socket]) -> None: ...
4137

4238
class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
4339
def run_forever(self) -> None: ...
@@ -357,7 +353,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
357353
def sock_accept(self, sock: socket) -> Future[Tuple[socket, _RetAddress]]: ...
358354
# Signal handling.
359355
def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ...
360-
def remove_signal_handler(self, sig: int) -> None: ...
356+
def remove_signal_handler(self, sig: int) -> bool: ...
361357
# Error handlers.
362358
def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ...
363359
def get_exception_handler(self) -> Optional[_ExceptionHandler]: ...

mypy/typeshed/stdlib/asyncio/events.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
447447
@abstractmethod
448448
def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ...
449449
@abstractmethod
450-
def remove_signal_handler(self, sig: int) -> None: ...
450+
def remove_signal_handler(self, sig: int) -> bool: ...
451451
# Error handlers.
452452
@abstractmethod
453453
def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ...

0 commit comments

Comments
 (0)