Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6a5eb4b

Browse filesBrowse files
author
mypybot
committed
Sync typeshed
Source commit: python/typeshed@9bddd3a
1 parent d62be28 commit 6a5eb4b
Copy full SHA for 6a5eb4b

File tree

Expand file treeCollapse file tree

12 files changed

+151
-30
lines changed
Filter options
Expand file treeCollapse file tree

12 files changed

+151
-30
lines changed

‎mypy/typeshed/stdlib/_ast.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/_ast.pyi
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ class Assign(stmt):
104104
class AugAssign(stmt):
105105
if sys.version_info >= (3, 10):
106106
__match_args__ = ("target", "op", "value")
107-
target: expr
107+
target: Name | Attribute | Subscript
108108
op: operator
109109
value: expr
110110

111111
class AnnAssign(stmt):
112112
if sys.version_info >= (3, 10):
113113
__match_args__ = ("target", "annotation", "value", "simple")
114-
target: expr
114+
target: Name | Attribute | Subscript
115115
annotation: expr
116116
value: expr | None
117117
simple: int
@@ -355,7 +355,7 @@ if sys.version_info >= (3, 8):
355355
class NamedExpr(expr):
356356
if sys.version_info >= (3, 10):
357357
__match_args__ = ("target", "value")
358-
target: expr
358+
target: Name
359359
value: expr
360360

361361
class Attribute(expr):

‎mypy/typeshed/stdlib/asyncio/runners.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/asyncio/runners.pyi
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from _typeshed import Self
33
from collections.abc import Callable, Coroutine
44
from contextvars import Context
55
from typing import Any, TypeVar
6+
from typing_extensions import final
67

78
from .events import AbstractEventLoop
89

@@ -13,6 +14,7 @@ else:
1314
_T = TypeVar("_T")
1415

1516
if sys.version_info >= (3, 11):
17+
@final
1618
class Runner:
1719
def __init__(self, *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...) -> None: ...
1820
def __enter__(self: Self) -> Self: ...
@@ -21,7 +23,12 @@ if sys.version_info >= (3, 11):
2123
def get_loop(self) -> AbstractEventLoop: ...
2224
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = ...) -> _T: ...
2325

24-
if sys.version_info >= (3, 8):
26+
if sys.version_info >= (3, 12):
27+
def run(
28+
main: Coroutine[Any, Any, _T], *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...
29+
) -> _T: ...
30+
31+
elif sys.version_info >= (3, 8):
2532
def run(main: Coroutine[Any, Any, _T], *, debug: bool | None = ...) -> _T: ...
2633

2734
else:

‎mypy/typeshed/stdlib/builtins.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/builtins.pyi
+95-3Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ from typing import ( # noqa: Y027
5454
overload,
5555
type_check_only,
5656
)
57-
from typing_extensions import Literal, SupportsIndex, TypeAlias, TypeGuard, final
57+
from typing_extensions import Literal, LiteralString, SupportsIndex, TypeAlias, TypeGuard, final
5858

5959
if sys.version_info >= (3, 9):
6060
from types import GenericAlias
@@ -413,20 +413,38 @@ class str(Sequence[str]):
413413
def __new__(cls: type[Self], object: object = ...) -> Self: ...
414414
@overload
415415
def __new__(cls: type[Self], object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
416+
@overload
417+
def capitalize(self: LiteralString) -> LiteralString: ...
418+
@overload
416419
def capitalize(self) -> str: ... # type: ignore[misc]
420+
@overload
421+
def casefold(self: LiteralString) -> LiteralString: ...
422+
@overload
417423
def casefold(self) -> str: ... # type: ignore[misc]
424+
@overload
425+
def center(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
426+
@overload
418427
def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
419428
def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
420429
def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ...
421430
def endswith(
422431
self, __suffix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
423432
) -> bool: ...
424433
if sys.version_info >= (3, 8):
434+
@overload
435+
def expandtabs(self: LiteralString, tabsize: SupportsIndex = ...) -> LiteralString: ...
436+
@overload
425437
def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... # type: ignore[misc]
426438
else:
439+
@overload
440+
def expandtabs(self: LiteralString, tabsize: int = ...) -> LiteralString: ...
441+
@overload
427442
def expandtabs(self, tabsize: int = ...) -> str: ... # type: ignore[misc]
428443

429444
def find(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
445+
@overload
446+
def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
447+
@overload
430448
def format(self, *args: object, **kwargs: object) -> str: ... # type: ignore[misc]
431449
def format_map(self, map: _FormatMapMapping) -> str: ...
432450
def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
@@ -442,53 +460,127 @@ class str(Sequence[str]):
442460
def isspace(self) -> bool: ...
443461
def istitle(self) -> bool: ...
444462
def isupper(self) -> bool: ...
463+
@overload
464+
def join(self: LiteralString, __iterable: Iterable[LiteralString]) -> LiteralString: ...
465+
@overload
445466
def join(self, __iterable: Iterable[str]) -> str: ... # type: ignore[misc]
467+
@overload
468+
def ljust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
469+
@overload
446470
def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
471+
@overload
472+
def lower(self: LiteralString) -> LiteralString: ...
473+
@overload
447474
def lower(self) -> str: ... # type: ignore[misc]
475+
@overload
476+
def lstrip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
477+
@overload
448478
def lstrip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
479+
@overload
480+
def partition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
481+
@overload
449482
def partition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
483+
@overload
484+
def replace(
485+
self: LiteralString, __old: LiteralString, __new: LiteralString, __count: SupportsIndex = ...
486+
) -> LiteralString: ...
487+
@overload
450488
def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ... # type: ignore[misc]
451489
if sys.version_info >= (3, 9):
490+
@overload
491+
def removeprefix(self: LiteralString, __prefix: LiteralString) -> LiteralString: ...
492+
@overload
452493
def removeprefix(self, __prefix: str) -> str: ... # type: ignore[misc]
494+
@overload
495+
def removesuffix(self: LiteralString, __suffix: LiteralString) -> LiteralString: ...
496+
@overload
453497
def removesuffix(self, __suffix: str) -> str: ... # type: ignore[misc]
454498

455499
def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
456500
def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ...
501+
@overload
502+
def rjust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ...
503+
@overload
457504
def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc]
505+
@overload
506+
def rpartition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ...
507+
@overload
458508
def rpartition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc]
509+
@overload
510+
def rsplit(self: LiteralString, sep: LiteralString | None = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ...
511+
@overload
459512
def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc]
513+
@overload
514+
def rstrip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
515+
@overload
460516
def rstrip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
517+
@overload
518+
def split(self: LiteralString, sep: LiteralString | None = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ...
519+
@overload
461520
def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc]
521+
@overload
522+
def splitlines(self: LiteralString, keepends: bool = ...) -> list[LiteralString]: ...
523+
@overload
462524
def splitlines(self, keepends: bool = ...) -> list[str]: ... # type: ignore[misc]
463525
def startswith(
464526
self, __prefix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
465527
) -> bool: ...
528+
@overload
529+
def strip(self: LiteralString, __chars: LiteralString | None = ...) -> LiteralString: ...
530+
@overload
466531
def strip(self, __chars: str | None = ...) -> str: ... # type: ignore[misc]
532+
@overload
533+
def swapcase(self: LiteralString) -> LiteralString: ...
534+
@overload
467535
def swapcase(self) -> str: ... # type: ignore[misc]
536+
@overload
537+
def title(self: LiteralString) -> LiteralString: ...
538+
@overload
468539
def title(self) -> str: ... # type: ignore[misc]
469540
def translate(self, __table: _TranslateTable) -> str: ...
541+
@overload
542+
def upper(self: LiteralString) -> LiteralString: ...
543+
@overload
470544
def upper(self) -> str: ... # type: ignore[misc]
545+
@overload
546+
def zfill(self: LiteralString, __width: SupportsIndex) -> LiteralString: ...
547+
@overload
471548
def zfill(self, __width: SupportsIndex) -> str: ... # type: ignore[misc]
472549
@staticmethod
473550
@overload
474551
def maketrans(__x: dict[int, _T] | dict[str, _T] | dict[str | int, _T]) -> dict[int, _T]: ...
475552
@staticmethod
476553
@overload
477554
def maketrans(__x: str, __y: str, __z: str | None = ...) -> dict[int, int | None]: ...
555+
@overload
556+
def __add__(self: LiteralString, __s: LiteralString) -> LiteralString: ...
557+
@overload
478558
def __add__(self, __s: str) -> str: ... # type: ignore[misc]
479559
# Incompatible with Sequence.__contains__
480560
def __contains__(self, __o: str) -> bool: ... # type: ignore[override]
481561
def __eq__(self, __x: object) -> bool: ...
482562
def __ge__(self, __x: str) -> bool: ...
483563
def __getitem__(self, __i: SupportsIndex | slice) -> str: ...
484564
def __gt__(self, __x: str) -> bool: ...
565+
@overload
566+
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
567+
@overload
485568
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
486569
def __le__(self, __x: str) -> bool: ...
487570
def __len__(self) -> int: ...
488571
def __lt__(self, __x: str) -> bool: ...
572+
@overload
573+
def __mod__(self: LiteralString, __x: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ...
574+
@overload
489575
def __mod__(self, __x: Any) -> str: ... # type: ignore[misc]
576+
@overload
577+
def __mul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
578+
@overload
490579
def __mul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
491580
def __ne__(self, __x: object) -> bool: ...
581+
@overload
582+
def __rmul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ...
583+
@overload
492584
def __rmul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc]
493585
def __getnewargs__(self) -> tuple[str]: ...
494586

@@ -1565,11 +1657,11 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
15651657
# Instead, we special-case the most common examples of this: bool and literal integers.
15661658
if sys.version_info >= (3, 8):
15671659
@overload
1568-
def sum(__iterable: Iterable[bool], start: int = ...) -> int: ... # type: ignore[misc]
1660+
def sum(__iterable: Iterable[bool | _LiteralInteger], start: int = ...) -> int: ... # type: ignore[misc]
15691661

15701662
else:
15711663
@overload
1572-
def sum(__iterable: Iterable[bool], __start: int = ...) -> int: ... # type: ignore[misc]
1664+
def sum(__iterable: Iterable[bool | _LiteralInteger], __start: int = ...) -> int: ... # type: ignore[misc]
15731665

15741666
@overload
15751667
def sum(__iterable: Iterable[_SupportsSumNoDefaultT]) -> _SupportsSumNoDefaultT | Literal[0]: ...

‎mypy/typeshed/stdlib/ctypes/__init__.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/ctypes/__init__.pyi
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,11 @@ class Array(Generic[_CT], _CData):
266266
def _type_(self) -> type[_CT]: ...
267267
@_type_.setter
268268
def _type_(self, value: type[_CT]) -> None: ...
269-
raw: bytes # Note: only available if _CT == c_char
269+
# Note: only available if _CT == c_char
270+
@property
271+
def raw(self) -> bytes: ...
272+
@raw.setter
273+
def raw(self, value: ReadableBuffer) -> None: ...
270274
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
271275
# TODO These methods cannot be annotated correctly at the moment.
272276
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT

‎mypy/typeshed/stdlib/email/message.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/email/message.pyi
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from email.charset import Charset
55
from email.contentmanager import ContentManager
66
from email.errors import MessageDefect
77
from email.policy import Policy
8-
from typing import Any, TypeVar
8+
from typing import Any, TypeVar, overload
99
from typing_extensions import TypeAlias
1010

1111
__all__ = ["Message", "EmailMessage"]
@@ -54,7 +54,10 @@ class Message:
5454
def get_filename(self, failobj: _T = ...) -> _T | str: ...
5555
def get_boundary(self, failobj: _T = ...) -> _T | str: ...
5656
def set_boundary(self, boundary: str) -> None: ...
57-
def get_content_charset(self, failobj: _T = ...) -> _T | str: ...
57+
@overload
58+
def get_content_charset(self) -> str | None: ...
59+
@overload
60+
def get_content_charset(self, failobj: _T) -> str | _T: ...
5861
def get_charsets(self, failobj: _T = ...) -> _T | list[str]: ...
5962
def walk(self: Self) -> Generator[Self, None, None]: ...
6063
def get_content_disposition(self) -> str | None: ...

‎mypy/typeshed/stdlib/http/client.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/http/client.pyi
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ class HTTPConnection:
154154
blocksize: int = ...,
155155
) -> None: ...
156156
def request(
157-
self, method: str, url: str, body: _DataType | None = ..., headers: Mapping[str, str] = ..., *, encode_chunked: bool = ...
157+
self,
158+
method: str,
159+
url: str,
160+
body: _DataType | str | None = ...,
161+
headers: Mapping[str, str] = ...,
162+
*,
163+
encode_chunked: bool = ...,
158164
) -> None: ...
159165
def getresponse(self) -> HTTPResponse: ...
160166
def set_debuglevel(self, level: int) -> None: ...

‎mypy/typeshed/stdlib/multiprocessing/context.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/multiprocessing/context.pyi
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ctypes
22
import sys
33
from collections.abc import Callable, Iterable, Sequence
44
from ctypes import _CData
5-
from logging import Logger
5+
from logging import Logger, _Level as _LoggingLevel
66
from multiprocessing import popen_fork, popen_forkserver, popen_spawn_posix, popen_spawn_win32, queues, synchronize
77
from multiprocessing.managers import SyncManager
88
from multiprocessing.pool import Pool as _Pool
@@ -107,7 +107,7 @@ class BaseContext:
107107
) -> Any: ...
108108
def freeze_support(self) -> None: ...
109109
def get_logger(self) -> Logger: ...
110-
def log_to_stderr(self, level: str | None = ...) -> Logger: ...
110+
def log_to_stderr(self, level: _LoggingLevel | None = ...) -> Logger: ...
111111
def allow_connection_pickling(self) -> None: ...
112112
def set_executable(self, executable: str) -> None: ...
113113
def set_forkserver_preload(self, module_names: list[str]) -> None: ...

‎mypy/typeshed/stdlib/multiprocessing/util.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/multiprocessing/util.pyi
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import threading
22
from _typeshed import Incomplete, ReadableBuffer, SupportsTrunc
33
from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence
4-
from logging import Logger
4+
from logging import Logger, _Level as _LoggingLevel
55
from typing import Any, SupportsInt
66
from typing_extensions import SupportsIndex
77

@@ -37,7 +37,7 @@ def debug(msg: object, *args: object) -> None: ...
3737
def info(msg: object, *args: object) -> None: ...
3838
def sub_warning(msg: object, *args: object) -> None: ...
3939
def get_logger() -> Logger: ...
40-
def log_to_stderr(level: int | None = ...) -> Logger: ...
40+
def log_to_stderr(level: _LoggingLevel | None = ...) -> Logger: ...
4141
def is_abstract_socket_namespace(address: str | bytes | None) -> bool: ...
4242

4343
abstract_sockets_supported: bool

‎mypy/typeshed/stdlib/types.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/types.pyi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ _P = ParamSpec("_P")
569569
# it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable
570570
# The type: ignore is due to overlapping overloads, not the use of ParamSpec
571571
@overload
572-
def coroutine(func: Callable[_P, Generator[_R, Any, Any]]) -> Callable[_P, Awaitable[_R]]: ... # type: ignore[misc]
572+
def coroutine(func: Callable[_P, Generator[Any, Any, _R]]) -> Callable[_P, Awaitable[_R]]: ... # type: ignore[misc]
573573
@overload
574574
def coroutine(func: _Fn) -> _Fn: ...
575575

‎mypy/typeshed/stdlib/typing.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/typing.pyi
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class SupportsRound(Protocol[_T_co]):
325325
def __round__(self, __ndigits: int) -> _T_co: ...
326326

327327
@runtime_checkable
328-
class Sized(Protocol):
328+
class Sized(Protocol, metaclass=ABCMeta):
329329
@abstractmethod
330330
def __len__(self) -> int: ...
331331

@@ -452,7 +452,10 @@ class Container(Protocol[_T_co]):
452452
def __contains__(self, __x: object) -> bool: ...
453453

454454
@runtime_checkable
455-
class Collection(Sized, Iterable[_T_co], Container[_T_co], Protocol[_T_co]): ...
455+
class Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]):
456+
# Implement Sized (but don't have it as a base class).
457+
@abstractmethod
458+
def __len__(self) -> int: ...
456459

457460
class Sequence(Collection[_T_co], Reversible[_T_co], Generic[_T_co]):
458461
@overload

‎mypy/typeshed/stdlib/unittest/case.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/unittest/case.pyi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class TestCase:
104104
def tearDownClass(cls) -> None: ...
105105
def run(self, result: unittest.result.TestResult | None = ...) -> unittest.result.TestResult | None: ...
106106
def __call__(self, result: unittest.result.TestResult | None = ...) -> unittest.result.TestResult | None: ...
107-
def skipTest(self, reason: Any) -> None: ...
107+
def skipTest(self, reason: Any) -> NoReturn: ...
108108
def subTest(self, msg: Any = ..., **params: Any) -> AbstractContextManager[None]: ...
109109
def debug(self) -> None: ...
110110
if sys.version_info < (3, 11):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.