Skip to content

Commit 1cc62a2

Browse files
Sync typeshed (#16493)
Source commit: python/typeshed@643d911
1 parent 5489fd3 commit 1cc62a2

Some content is hidden

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

49 files changed

+208
-171
lines changed

mypy/typeshed/stdlib/_ast.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ if sys.version_info >= (3, 10):
553553

554554
class MatchSingleton(pattern):
555555
__match_args__ = ("value",)
556-
value: Literal[True, False, None]
556+
value: Literal[True, False] | None
557557

558558
class MatchSequence(pattern):
559559
__match_args__ = ("patterns",)

mypy/typeshed/stdlib/_locale.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from _typeshed import StrPath
3-
from collections.abc import Iterable, Mapping
3+
from collections.abc import Mapping
44

55
LC_CTYPE: int
66
LC_COLLATE: int
@@ -10,7 +10,7 @@ LC_NUMERIC: int
1010
LC_ALL: int
1111
CHAR_MAX: int
1212

13-
def setlocale(category: int, locale: str | Iterable[str | None] | None = None) -> str: ...
13+
def setlocale(__category: int, __locale: str | None = None) -> str: ...
1414
def localeconv() -> Mapping[str, int | str | list[int]]: ...
1515

1616
if sys.version_info >= (3, 11):

mypy/typeshed/stdlib/_typeshed/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ class SupportsNoArgReadline(Protocol[_T_co]):
236236
class SupportsWrite(Protocol[_T_contra]):
237237
def write(self, __s: _T_contra) -> object: ...
238238

239+
# stable
240+
class SupportsFlush(Protocol):
241+
def flush(self) -> object: ...
242+
239243
# Unfortunately PEP 688 does not allow us to distinguish read-only
240244
# from writable buffers. We use these aliases for readability for now.
241245
# Perhaps a future extension of the buffer protocol will allow us to

mypy/typeshed/stdlib/_typeshed/wsgi.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ from typing import Any, Protocol
1111
from typing_extensions import TypeAlias
1212

1313
class _Readable(Protocol):
14-
def read(self, size: int = ...) -> bytes: ...
14+
def read(self, __size: int = ...) -> bytes: ...
1515
# Optional: def close(self) -> object: ...
1616

1717
if sys.version_info >= (3, 11):

mypy/typeshed/stdlib/_typeshed/xml.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ from typing import Any, Protocol
44

55
# As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects
66
class DOMImplementation(Protocol):
7-
def hasFeature(self, feature: str, version: str | None) -> bool: ...
8-
def createDocument(self, namespaceUri: str, qualifiedName: str, doctype: Any | None) -> Any: ...
9-
def createDocumentType(self, qualifiedName: str, publicId: str, systemId: str) -> Any: ...
7+
def hasFeature(self, __feature: str, __version: str | None) -> bool: ...
8+
def createDocument(self, __namespaceUri: str, __qualifiedName: str, __doctype: Any | None) -> Any: ...
9+
def createDocumentType(self, __qualifiedName: str, __publicId: str, __systemId: str) -> Any: ...

mypy/typeshed/stdlib/_warnings.pyi

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
1+
import sys
12
from typing import Any, overload
23

34
_defaultaction: str
45
_onceregistry: dict[Any, Any]
56
filters: list[tuple[str, str | None, type[Warning], str | None, int]]
67

7-
@overload
8-
def warn(message: str, category: type[Warning] | None = None, stacklevel: int = 1, source: Any | None = None) -> None: ...
9-
@overload
10-
def warn(message: Warning, category: Any = None, stacklevel: int = 1, source: Any | None = None) -> None: ...
8+
if sys.version_info >= (3, 12):
9+
@overload
10+
def warn(
11+
message: str,
12+
category: type[Warning] | None = None,
13+
stacklevel: int = 1,
14+
source: Any | None = None,
15+
*,
16+
skip_file_prefixes: tuple[str, ...] = (),
17+
) -> None: ...
18+
@overload
19+
def warn(
20+
message: Warning,
21+
category: Any = None,
22+
stacklevel: int = 1,
23+
source: Any | None = None,
24+
*,
25+
skip_file_prefixes: tuple[str, ...] = (),
26+
) -> None: ...
27+
28+
else:
29+
@overload
30+
def warn(message: str, category: type[Warning] | None = None, stacklevel: int = 1, source: Any | None = None) -> None: ...
31+
@overload
32+
def warn(message: Warning, category: Any = None, stacklevel: int = 1, source: Any | None = None) -> None: ...
33+
1134
@overload
1235
def warn_explicit(
1336
message: str,

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class _ActionsContainer:
120120
def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> None: ...
121121

122122
class _FormatterClass(Protocol):
123-
def __call__(self, prog: str) -> HelpFormatter: ...
123+
def __call__(self, *, prog: str) -> HelpFormatter: ...
124124

125125
class ArgumentParser(_AttributeHolder, _ActionsContainer):
126126
prog: str

mypy/typeshed/stdlib/ast.pyi

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,30 @@ from _ast import *
44
from _typeshed import ReadableBuffer, Unused
55
from collections.abc import Iterator
66
from typing import Any, TypeVar as _TypeVar, overload
7-
from typing_extensions import Literal
7+
from typing_extensions import Literal, deprecated
88

99
if sys.version_info >= (3, 8):
1010
class _ABC(type):
1111
if sys.version_info >= (3, 9):
1212
def __init__(cls, *args: Unused) -> None: ...
1313

14+
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
1415
class Num(Constant, metaclass=_ABC):
1516
value: int | float | complex
16-
17+
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
1718
class Str(Constant, metaclass=_ABC):
1819
value: str
1920
# Aliases for value, for backwards compatibility
2021
s: str
21-
22+
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
2223
class Bytes(Constant, metaclass=_ABC):
2324
value: bytes
2425
# Aliases for value, for backwards compatibility
2526
s: bytes
26-
27+
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
2728
class NameConstant(Constant, metaclass=_ABC): ...
29+
30+
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
2831
class Ellipsis(Constant, metaclass=_ABC): ...
2932

3033
if sys.version_info >= (3, 9):

mypy/typeshed/stdlib/asyncio/base_events.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class BaseEventLoop(AbstractEventLoop):
423423
bufsize: Literal[0] = 0,
424424
encoding: None = None,
425425
errors: None = None,
426-
text: Literal[False, None] = None,
426+
text: Literal[False] | None = None,
427427
**kwargs: Any,
428428
) -> tuple[SubprocessTransport, _ProtocolT]: ...
429429
async def subprocess_exec(

mypy/typeshed/stdlib/asyncio/events.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class AbstractEventLoop:
522522
bufsize: Literal[0] = 0,
523523
encoding: None = None,
524524
errors: None = None,
525-
text: Literal[False, None] = ...,
525+
text: Literal[False] | None = ...,
526526
**kwargs: Any,
527527
) -> tuple[SubprocessTransport, _ProtocolT]: ...
528528
@abstractmethod

0 commit comments

Comments
 (0)