Skip to content

Commit cb1ea95

Browse files
Revert "Sync typeshed (#16918)"
This reverts commit 5ffa6dd.
1 parent 5ffa6dd commit cb1ea95

36 files changed

+553
-653
lines changed

mypy/typeshed/stdlib/_ast.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ PyCF_ONLY_AST: Literal[1024]
66
PyCF_TYPE_COMMENTS: Literal[4096]
77
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
88

9-
# Alias used for fields that must always be valid identifiers
10-
# A string `x` counts as a valid identifier if both the following are True
11-
# (1) `x.isidentifier()` evaluates to `True`
12-
# (2) `keyword.iskeyword(x)` evaluates to `False`
139
_Identifier: typing_extensions.TypeAlias = str
1410

1511
class AST:
@@ -503,7 +499,7 @@ class keyword(AST):
503499
class alias(AST):
504500
if sys.version_info >= (3, 10):
505501
__match_args__ = ("name", "asname")
506-
name: str
502+
name: _Identifier
507503
asname: _Identifier | None
508504

509505
class withitem(AST):

mypy/typeshed/stdlib/_curses.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,5 @@ if sys.platform != "win32":
553553
major: int
554554
minor: int
555555
patch: int
556-
557556
ncurses_version: _ncurses_version
558557
window = _CursesWindow # undocumented

mypy/typeshed/stdlib/_msi.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ if sys.platform == "win32":
4545
# Don't exist at runtime
4646
__new__: None # type: ignore[assignment]
4747
__init__: None # type: ignore[assignment]
48-
4948
def UuidCreate() -> str: ...
5049
def FCICreate(__cabname: str, __files: list[str]) -> None: ...
5150
def OpenDatabase(__path: str, __persist: int) -> _Database: ...

mypy/typeshed/stdlib/_thread.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def get_native_id() -> int: ... # only available on some platforms
3232
class _ExceptHookArgs(structseq[Any], tuple[type[BaseException], BaseException | None, TracebackType | None, Thread | None]):
3333
if sys.version_info >= (3, 10):
3434
__match_args__: Final = ("exc_type", "exc_value", "exc_traceback", "thread")
35-
3635
@property
3736
def exc_type(self) -> type[BaseException]: ...
3837
@property

mypy/typeshed/stdlib/asyncio/sslproto.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ if sys.version_info >= (3, 11):
2525
STATE_CON_MADE: str
2626
STATE_EOF: str
2727
STATE_CON_LOST: str
28-
2928
def add_flowcontrol_defaults(high: int | None, low: int | None, kb: int) -> tuple[int, int]: ...
3029

3130
else:
@@ -156,10 +155,9 @@ class SSLProtocol(_SSLProtocolBase):
156155
def _check_handshake_timeout(self) -> None: ...
157156
def _on_handshake_complete(self, handshake_exc: BaseException | None) -> None: ...
158157
def _fatal_error(self, exc: BaseException, message: str = "Fatal error on transport") -> None: ...
158+
def _abort(self) -> None: ...
159159
if sys.version_info >= (3, 11):
160-
def _abort(self, exc: BaseException | None) -> None: ...
161160
def get_buffer(self, n: int) -> memoryview: ...
162161
else:
163-
def _abort(self) -> None: ...
164162
def _finalize(self) -> None: ...
165163
def _process_write_backlog(self) -> None: ...

mypy/typeshed/stdlib/asyncio/unix_events.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ if sys.platform != "win32":
9696
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
9797
def add_child_handler(self, pid: int, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> None: ...
9898
def remove_child_handler(self, pid: int) -> bool: ...
99-
10099
else:
101100
class SafeChildWatcher(BaseChildWatcher):
102101
def __enter__(self) -> Self: ...
@@ -121,7 +120,6 @@ if sys.platform != "win32":
121120
else:
122121
def get_child_watcher(self) -> AbstractChildWatcher: ...
123122
def set_child_watcher(self, watcher: AbstractChildWatcher | None) -> None: ...
124-
125123
SelectorEventLoop = _UnixSelectorEventLoop
126124

127125
DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy
@@ -138,7 +136,6 @@ if sys.platform != "win32":
138136
def add_child_handler(self, pid: int, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> None: ...
139137
def remove_child_handler(self, pid: int) -> bool: ...
140138
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
141-
142139
else:
143140
class MultiLoopChildWatcher(AbstractChildWatcher):
144141
def is_active(self) -> bool: ...

mypy/typeshed/stdlib/asyncio/windows_events.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ if sys.platform == "win32":
6969
def recvfrom_into(
7070
self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0
7171
) -> futures.Future[tuple[int, socket._RetAddress]]: ...
72-
7372
SelectorEventLoop = _WindowsSelectorEventLoop
7473

7574
class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
@@ -81,5 +80,4 @@ if sys.platform == "win32":
8180
_loop_factory: ClassVar[type[ProactorEventLoop]]
8281
def get_child_watcher(self) -> NoReturn: ...
8382
def set_child_watcher(self, watcher: Any) -> NoReturn: ...
84-
8583
DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy

mypy/typeshed/stdlib/calendar.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class HTMLCalendar(Calendar):
124124
def formatyear(self, theyear: int, width: int = 3) -> str: ...
125125
def formatyearpage(
126126
self, theyear: int, width: int = 3, css: str | None = "calendar.css", encoding: str | None = None
127-
) -> bytes: ...
127+
) -> str: ...
128128

129129
class different_locale:
130130
def __init__(self, locale: _LocaleType) -> None: ...
@@ -166,7 +166,6 @@ if sys.version_info >= (3, 12):
166166
OCTOBER: Literal[10]
167167
NOVEMBER: Literal[11]
168168
DECEMBER: Literal[12]
169-
170169
JANUARY = Month.JANUARY
171170
FEBRUARY = Month.FEBRUARY
172171
MARCH = Month.MARCH
@@ -188,7 +187,6 @@ if sys.version_info >= (3, 12):
188187
FRIDAY: Literal[4]
189188
SATURDAY: Literal[5]
190189
SUNDAY: Literal[6]
191-
192190
MONDAY = Day.MONDAY
193191
TUESDAY = Day.TUESDAY
194192
WEDNESDAY = Day.WEDNESDAY

mypy/typeshed/stdlib/contextlib.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ class closing(AbstractContextManager[_SupportsCloseT]):
118118
if sys.version_info >= (3, 10):
119119
class _SupportsAclose(Protocol):
120120
def aclose(self) -> Awaitable[object]: ...
121-
122121
_SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose)
123122

124123
class aclosing(AbstractAsyncContextManager[_SupportsAcloseT]):

mypy/typeshed/stdlib/dbm/gnu.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ if sys.platform != "win32":
3737
# Don't exist at runtime
3838
__new__: None # type: ignore[assignment]
3939
__init__: None # type: ignore[assignment]
40-
4140
def open(__filename: str, __flags: str = "r", __mode: int = 0o666) -> _gdbm: ...

mypy/typeshed/stdlib/dbm/ndbm.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ if sys.platform != "win32":
3333
# Don't exist at runtime
3434
__new__: None # type: ignore[assignment]
3535
__init__: None # type: ignore[assignment]
36-
3736
def open(__filename: str, __flags: str = "r", __mode: int = 0o666) -> _dbm: ...

mypy/typeshed/stdlib/enum.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ if sys.version_info >= (3, 11):
175175
name: str
176176
clsname: str
177177
member: Enum | None
178-
179178
_magic_enum_attr = property
180179
else:
181180
_magic_enum_attr = types.DynamicClassAttribute
@@ -262,7 +261,6 @@ if sys.version_info >= (3, 11):
262261
CONTINUOUS: str
263262
NAMED_FLAGS: str
264263
UNIQUE: str
265-
266264
CONTINUOUS = EnumCheck.CONTINUOUS
267265
NAMED_FLAGS = EnumCheck.NAMED_FLAGS
268266
UNIQUE = EnumCheck.UNIQUE
@@ -276,7 +274,6 @@ if sys.version_info >= (3, 11):
276274
CONFORM: str
277275
EJECT: str
278276
KEEP: str
279-
280277
STRICT = FlagBoundary.STRICT
281278
CONFORM = FlagBoundary.CONFORM
282279
EJECT = FlagBoundary.EJECT

mypy/typeshed/stdlib/ftplib.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class FTP:
3131
sock: socket | None
3232
welcome: str | None
3333
passiveserver: int
34-
timeout: float | None
34+
timeout: int
3535
af: int
3636
lastresp: str
3737
file: TextIO | None
@@ -48,7 +48,7 @@ class FTP:
4848
user: str = "",
4949
passwd: str = "",
5050
acct: str = "",
51-
timeout: float | None = ...,
51+
timeout: float = ...,
5252
source_address: tuple[str, int] | None = None,
5353
*,
5454
encoding: str = "utf-8",
@@ -60,7 +60,7 @@ class FTP:
6060
user: str = "",
6161
passwd: str = "",
6262
acct: str = "",
63-
timeout: float | None = ...,
63+
timeout: float = ...,
6464
source_address: tuple[str, int] | None = None,
6565
) -> None: ...
6666

@@ -127,7 +127,7 @@ class FTP_TLS(FTP):
127127
acct: str = "",
128128
*,
129129
context: SSLContext | None = None,
130-
timeout: float | None = ...,
130+
timeout: float = ...,
131131
source_address: tuple[str, int] | None = None,
132132
encoding: str = "utf-8",
133133
) -> None: ...
@@ -141,7 +141,7 @@ class FTP_TLS(FTP):
141141
keyfile: str | None = None,
142142
certfile: str | None = None,
143143
context: SSLContext | None = None,
144-
timeout: float | None = ...,
144+
timeout: float = ...,
145145
source_address: tuple[str, int] | None = None,
146146
*,
147147
encoding: str = "utf-8",
@@ -156,7 +156,7 @@ class FTP_TLS(FTP):
156156
keyfile: str | None = None,
157157
certfile: str | None = None,
158158
context: SSLContext | None = None,
159-
timeout: float | None = ...,
159+
timeout: float = ...,
160160
source_address: tuple[str, int] | None = None,
161161
) -> None: ...
162162
ssl_version: int

mypy/typeshed/stdlib/grp.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ if sys.platform != "win32":
77
class struct_group(structseq[Any], tuple[str, str | None, int, list[str]]):
88
if sys.version_info >= (3, 10):
99
__match_args__: Final = ("gr_name", "gr_passwd", "gr_gid", "gr_mem")
10-
1110
@property
1211
def gr_name(self) -> str: ...
1312
@property

mypy/typeshed/stdlib/importlib/metadata/__init__.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class PackageNotFoundError(ModuleNotFoundError):
4343
if sys.version_info >= (3, 11):
4444
class DeprecatedTuple:
4545
def __getitem__(self, item: int) -> str: ...
46-
4746
_EntryPointBase = DeprecatedTuple
4847
else:
4948
class _EntryPointBase(NamedTuple):

mypy/typeshed/stdlib/inspect.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ if sys.version_info < (3, 11):
430430
varargs: str | None
431431
keywords: str | None
432432
defaults: tuple[Any, ...]
433-
434433
def getargspec(func: object) -> ArgSpec: ...
435434

436435
class FullArgSpec(NamedTuple):

mypy/typeshed/stdlib/io.pyi

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from _typeshed import FileDescriptorOrPath, ReadableBuffer, WriteableBuffer
66
from collections.abc import Callable, Iterable, Iterator
77
from os import _Opener
88
from types import TracebackType
9-
from typing import IO, Any, BinaryIO, Literal, Protocol, TextIO, TypeVar, overload, type_check_only
9+
from typing import IO, Any, BinaryIO, Literal, TextIO, TypeVar, overload
1010
from typing_extensions import Self
1111

1212
__all__ = [
@@ -94,10 +94,7 @@ class BufferedIOBase(IOBase):
9494

9595
class FileIO(RawIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of writelines in the base classes
9696
mode: str
97-
# The type of "name" equals the argument passed in to the constructor,
98-
# but that can make FileIO incompatible with other I/O types that assume
99-
# "name" is a str. In the future, making FileIO generic might help.
100-
name: Any
97+
name: FileDescriptorOrPath
10198
def __init__(
10299
self, file: FileDescriptorOrPath, mode: str = ..., closefd: bool = ..., opener: _Opener | None = ...
103100
) -> None: ...
@@ -149,43 +146,16 @@ class TextIOBase(IOBase):
149146
def readlines(self, __hint: int = -1) -> list[str]: ... # type: ignore[override]
150147
def read(self, __size: int | None = ...) -> str: ...
151148

152-
@type_check_only
153-
class _WrappedBuffer(Protocol):
154-
# "name" is wrapped by TextIOWrapper. Its type is inconsistent between
155-
# the various I/O types, see the comments on TextIOWrapper.name and
156-
# TextIO.name.
157-
@property
158-
def name(self) -> Any: ...
159-
@property
160-
def closed(self) -> bool: ...
161-
def read(self, size: int = ..., /) -> ReadableBuffer: ...
162-
# Optional: def read1(self, size: int, /) -> ReadableBuffer: ...
163-
def write(self, b: bytes, /) -> object: ...
164-
def flush(self) -> object: ...
165-
def close(self) -> object: ...
166-
def seekable(self) -> bool: ...
167-
def readable(self) -> bool: ...
168-
def writable(self) -> bool: ...
169-
def truncate(self, size: int, /) -> int: ...
170-
def fileno(self) -> int: ...
171-
def isatty(self) -> int: ...
172-
# Optional: Only needs to be present if seekable() returns True.
173-
# def seek(self, offset: Literal[0], whence: Literal[2]) -> int: ...
174-
# def tell(self) -> int: ...
175-
176-
# TODO: Should be generic over the buffer type, but needs to wait for
177-
# TypeVar defaults.
178149
class TextIOWrapper(TextIOBase, TextIO): # type: ignore[misc] # incompatible definitions of write in the base classes
179150
def __init__(
180151
self,
181-
buffer: _WrappedBuffer,
152+
buffer: IO[bytes],
182153
encoding: str | None = ...,
183154
errors: str | None = ...,
184155
newline: str | None = ...,
185156
line_buffering: bool = ...,
186157
write_through: bool = ...,
187158
) -> None: ...
188-
# Equals the "buffer" argument passed in to the constructor.
189159
@property
190160
def buffer(self) -> BinaryIO: ...
191161
@property
@@ -210,11 +180,7 @@ class TextIOWrapper(TextIOBase, TextIO): # type: ignore[misc] # incompatible d
210180
def writelines(self, __lines: Iterable[str]) -> None: ... # type: ignore[override]
211181
def readline(self, __size: int = -1) -> str: ... # type: ignore[override]
212182
def readlines(self, __hint: int = -1) -> list[str]: ... # type: ignore[override]
213-
# Equals the "buffer" argument passed in to the constructor.
214-
def detach(self) -> BinaryIO: ...
215-
# TextIOWrapper's version of seek only supports a limited subset of
216-
# operations.
217-
def seek(self, __cookie: int, __whence: int = 0) -> int: ...
183+
def seek(self, __cookie: int, __whence: int = 0) -> int: ... # stubtest needs this
218184

219185
class StringIO(TextIOWrapper):
220186
def __init__(self, initial_value: str | None = ..., newline: str | None = ...) -> None: ...

mypy/typeshed/stdlib/msilib/__init__.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ if sys.platform == "win32":
5656
def gen_id(self, file: str) -> str: ...
5757
def append(self, full: str, file: str, logical: str) -> tuple[int, str]: ...
5858
def commit(self, db: _Database) -> None: ...
59-
6059
_directories: set[str]
6160

6261
class Directory:

mypy/typeshed/stdlib/multiprocessing/reduction.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,4 @@ class AbstractReducer(metaclass=ABCMeta):
8686
sendfds = _sendfds
8787
recvfds = _recvfds
8888
DupFd = _DupFd
89-
9089
def __init__(self, *args: Unused) -> None: ...

mypy/typeshed/stdlib/os/__init__.pyi

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo
341341
# More items may be added at the end by some implementations.
342342
if sys.version_info >= (3, 10):
343343
__match_args__: Final = ("st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size")
344-
345344
@property
346345
def st_mode(self) -> int: ... # protection bits,
347346
@property
@@ -447,7 +446,6 @@ class statvfs_result(structseq[int], tuple[int, int, int, int, int, int, int, in
447446
"f_flag",
448447
"f_namemax",
449448
)
450-
451449
@property
452450
def f_bsize(self) -> int: ...
453451
@property
@@ -490,7 +488,6 @@ def umask(__mask: int) -> int: ...
490488
class uname_result(structseq[str], tuple[str, str, str, str, str]):
491489
if sys.version_info >= (3, 10):
492490
__match_args__: Final = ("sysname", "nodename", "release", "version", "machine")
493-
494491
@property
495492
def sysname(self) -> str: ...
496493
@property
@@ -707,7 +704,6 @@ if sys.platform != "win32":
707704
class terminal_size(structseq[int], tuple[int, int]):
708705
if sys.version_info >= (3, 10):
709706
__match_args__: Final = ("columns", "lines")
710-
711707
@property
712708
def columns(self) -> int: ...
713709
@property
@@ -929,7 +925,6 @@ def system(command: StrOrBytesPath) -> int: ...
929925
class times_result(structseq[float], tuple[float, float, float, float, float]):
930926
if sys.version_info >= (3, 10):
931927
__match_args__: Final = ("user", "system", "children_user", "children_system", "elapsed")
932-
933928
@property
934929
def user(self) -> float: ...
935930
@property
@@ -967,7 +962,6 @@ else:
967962
class waitid_result(structseq[int], tuple[int, int, int, int, int]):
968963
if sys.version_info >= (3, 10):
969964
__match_args__: Final = ("si_pid", "si_uid", "si_signo", "si_status", "si_code")
970-
971965
@property
972966
def si_pid(self) -> int: ...
973967
@property
@@ -1028,7 +1022,6 @@ if sys.platform != "win32":
10281022
class sched_param(structseq[int], tuple[int]):
10291023
if sys.version_info >= (3, 10):
10301024
__match_args__: Final = ("sched_priority",)
1031-
10321025
def __new__(cls, sched_priority: int) -> Self: ...
10331026
@property
10341027
def sched_priority(self) -> int: ...

0 commit comments

Comments
 (0)