Skip to content

Commit cd1b8f5

Browse files
author
mypybot
committed
Sync typeshed
Source commit: python/typeshed@7fb8466
1 parent c9d4c61 commit cd1b8f5

26 files changed

+344
-225
lines changed

mypy/typeshed/stdlib/_ctypes.pyi

+5-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ class Array(_CData, Generic[_CT]):
171171
def _type_(self) -> type[_CT]: ...
172172
@_type_.setter
173173
def _type_(self, value: type[_CT]) -> None: ...
174-
raw: bytes # Note: only available if _CT == c_char
174+
# Note: only available if _CT == c_char
175+
@property
176+
def raw(self) -> bytes: ...
177+
@raw.setter
178+
def raw(self, value: ReadableBuffer) -> None: ...
175179
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
176180
# TODO These methods cannot be annotated correctly at the moment.
177181
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT

mypy/typeshed/stdlib/builtins.pyi

+100-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ from typing import ( # noqa: Y022
6363
from typing_extensions import ( # noqa: Y023
6464
Concatenate,
6565
Literal,
66+
LiteralString,
6667
ParamSpec,
6768
Self,
6869
TypeAlias,
@@ -437,16 +438,31 @@ class str(Sequence[str]):
437438
def __new__(cls, object: object = ...) -> Self: ...
438439
@overload
439440
def __new__(cls, object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...
441+
@overload
442+
def capitalize(self: LiteralString) -> LiteralString: ...
443+
@overload
440444
def capitalize(self) -> str: ... # type: ignore[misc]
445+
@overload
446+
def casefold(self: LiteralString) -> LiteralString: ...
447+
@overload
441448
def casefold(self) -> str: ... # type: ignore[misc]
449+
@overload
450+
def center(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = " ", /) -> LiteralString: ...
451+
@overload
442452
def center(self, width: SupportsIndex, fillchar: str = " ", /) -> str: ... # type: ignore[misc]
443453
def count(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
444454
def encode(self, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
445455
def endswith(
446456
self, suffix: str | tuple[str, ...], start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /
447457
) -> bool: ...
458+
@overload
459+
def expandtabs(self: LiteralString, tabsize: SupportsIndex = 8) -> LiteralString: ...
460+
@overload
448461
def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]
449462
def find(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
463+
@overload
464+
def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...
465+
@overload
450466
def format(self, *args: object, **kwargs: object) -> str: ...
451467
def format_map(self, mapping: _FormatMapMapping, /) -> str: ...
452468
def index(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
@@ -462,35 +478,99 @@ class str(Sequence[str]):
462478
def isspace(self) -> bool: ...
463479
def istitle(self) -> bool: ...
464480
def isupper(self) -> bool: ...
481+
@overload
482+
def join(self: LiteralString, iterable: Iterable[LiteralString], /) -> LiteralString: ...
483+
@overload
465484
def join(self, iterable: Iterable[str], /) -> str: ... # type: ignore[misc]
485+
@overload
486+
def ljust(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = " ", /) -> LiteralString: ...
487+
@overload
466488
def ljust(self, width: SupportsIndex, fillchar: str = " ", /) -> str: ... # type: ignore[misc]
489+
@overload
490+
def lower(self: LiteralString) -> LiteralString: ...
491+
@overload
467492
def lower(self) -> str: ... # type: ignore[misc]
493+
@overload
494+
def lstrip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...
495+
@overload
468496
def lstrip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]
497+
@overload
498+
def partition(self: LiteralString, sep: LiteralString, /) -> tuple[LiteralString, LiteralString, LiteralString]: ...
499+
@overload
469500
def partition(self, sep: str, /) -> tuple[str, str, str]: ... # type: ignore[misc]
470501
if sys.version_info >= (3, 13):
502+
@overload
503+
def replace(
504+
self: LiteralString, old: LiteralString, new: LiteralString, /, count: SupportsIndex = -1
505+
) -> LiteralString: ...
506+
@overload
471507
def replace(self, old: str, new: str, /, count: SupportsIndex = -1) -> str: ... # type: ignore[misc]
472508
else:
509+
@overload
510+
def replace(
511+
self: LiteralString, old: LiteralString, new: LiteralString, count: SupportsIndex = -1, /
512+
) -> LiteralString: ...
513+
@overload
473514
def replace(self, old: str, new: str, count: SupportsIndex = -1, /) -> str: ... # type: ignore[misc]
474515
if sys.version_info >= (3, 9):
516+
@overload
517+
def removeprefix(self: LiteralString, prefix: LiteralString, /) -> LiteralString: ...
518+
@overload
475519
def removeprefix(self, prefix: str, /) -> str: ... # type: ignore[misc]
520+
@overload
521+
def removesuffix(self: LiteralString, suffix: LiteralString, /) -> LiteralString: ...
522+
@overload
476523
def removesuffix(self, suffix: str, /) -> str: ... # type: ignore[misc]
477524

478525
def rfind(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
479526
def rindex(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
527+
@overload
528+
def rjust(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = " ", /) -> LiteralString: ...
529+
@overload
480530
def rjust(self, width: SupportsIndex, fillchar: str = " ", /) -> str: ... # type: ignore[misc]
531+
@overload
532+
def rpartition(self: LiteralString, sep: LiteralString, /) -> tuple[LiteralString, LiteralString, LiteralString]: ...
533+
@overload
481534
def rpartition(self, sep: str, /) -> tuple[str, str, str]: ... # type: ignore[misc]
535+
@overload
536+
def rsplit(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...
537+
@overload
482538
def rsplit(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]
539+
@overload
540+
def rstrip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...
541+
@overload
483542
def rstrip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]
543+
@overload
544+
def split(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...
545+
@overload
484546
def split(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]
547+
@overload
548+
def splitlines(self: LiteralString, keepends: bool = False) -> list[LiteralString]: ...
549+
@overload
485550
def splitlines(self, keepends: bool = False) -> list[str]: ... # type: ignore[misc]
486551
def startswith(
487552
self, prefix: str | tuple[str, ...], start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /
488553
) -> bool: ...
554+
@overload
555+
def strip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...
556+
@overload
489557
def strip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]
558+
@overload
559+
def swapcase(self: LiteralString) -> LiteralString: ...
560+
@overload
490561
def swapcase(self) -> str: ... # type: ignore[misc]
562+
@overload
563+
def title(self: LiteralString) -> LiteralString: ...
564+
@overload
491565
def title(self) -> str: ... # type: ignore[misc]
492566
def translate(self, table: _TranslateTable, /) -> str: ...
567+
@overload
568+
def upper(self: LiteralString) -> LiteralString: ...
569+
@overload
493570
def upper(self) -> str: ... # type: ignore[misc]
571+
@overload
572+
def zfill(self: LiteralString, width: SupportsIndex, /) -> LiteralString: ...
573+
@overload
494574
def zfill(self, width: SupportsIndex, /) -> str: ... # type: ignore[misc]
495575
@staticmethod
496576
@overload
@@ -501,21 +581,39 @@ class str(Sequence[str]):
501581
@staticmethod
502582
@overload
503583
def maketrans(x: str, y: str, z: str, /) -> dict[int, int | None]: ...
584+
@overload
585+
def __add__(self: LiteralString, value: LiteralString, /) -> LiteralString: ...
586+
@overload
504587
def __add__(self, value: str, /) -> str: ... # type: ignore[misc]
505588
# Incompatible with Sequence.__contains__
506589
def __contains__(self, key: str, /) -> bool: ... # type: ignore[override]
507590
def __eq__(self, value: object, /) -> bool: ...
508591
def __ge__(self, value: str, /) -> bool: ...
509-
def __getitem__(self, key: SupportsIndex | slice, /) -> str: ...
592+
@overload
593+
def __getitem__(self: LiteralString, key: SupportsIndex | slice, /) -> LiteralString: ...
594+
@overload
595+
def __getitem__(self, key: SupportsIndex | slice, /) -> str: ... # type: ignore[misc]
510596
def __gt__(self, value: str, /) -> bool: ...
511597
def __hash__(self) -> int: ...
598+
@overload
599+
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
600+
@overload
512601
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
513602
def __le__(self, value: str, /) -> bool: ...
514603
def __len__(self) -> int: ...
515604
def __lt__(self, value: str, /) -> bool: ...
605+
@overload
606+
def __mod__(self: LiteralString, value: LiteralString | tuple[LiteralString, ...], /) -> LiteralString: ...
607+
@overload
516608
def __mod__(self, value: Any, /) -> str: ...
609+
@overload
610+
def __mul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ...
611+
@overload
517612
def __mul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]
518613
def __ne__(self, value: object, /) -> bool: ...
614+
@overload
615+
def __rmul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ...
616+
@overload
519617
def __rmul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]
520618
def __getnewargs__(self) -> tuple[str]: ...
521619

@@ -1662,7 +1760,7 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
16621760
# without creating many false-positive errors (see #7578).
16631761
# Instead, we special-case the most common examples of this: bool and literal integers.
16641762
@overload
1665-
def sum(iterable: Iterable[bool], /, start: int = 0) -> int: ...
1763+
def sum(iterable: Iterable[bool | _LiteralInteger], /, start: int = 0) -> int: ...
16661764
@overload
16671765
def sum(iterable: Iterable[_SupportsSumNoDefaultT], /) -> _SupportsSumNoDefaultT | Literal[0]: ...
16681766
@overload
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from _typeshed import Unused
1+
from _typeshed import Incomplete, Unused
22
from collections.abc import Callable
3-
from typing import Any, ClassVar
3+
from typing import ClassVar
44

55
from ..cmd import Command
66

@@ -15,13 +15,13 @@ class bdist(Command):
1515
default_format: ClassVar[dict[str, str]]
1616
format_commands: ClassVar[list[str]]
1717
format_command: ClassVar[dict[str, tuple[str, str]]]
18-
bdist_base: Any
19-
plat_name: Any
20-
formats: Any
21-
dist_dir: Any
18+
bdist_base: Incomplete
19+
plat_name: Incomplete
20+
formats: Incomplete
21+
dist_dir: Incomplete
2222
skip_build: int
23-
group: Any
24-
owner: Any
23+
group: Incomplete
24+
owner: Incomplete
2525
def initialize_options(self) -> None: ...
2626
def finalize_options(self) -> None: ...
2727
def run(self) -> None: ...
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, ClassVar
1+
from _typeshed import Incomplete
2+
from typing import ClassVar
23

34
from ..cmd import Command
45

@@ -7,15 +8,15 @@ class bdist_dumb(Command):
78
user_options: ClassVar[list[tuple[str, str | None, str]]]
89
boolean_options: ClassVar[list[str]]
910
default_format: ClassVar[dict[str, str]]
10-
bdist_dir: Any
11-
plat_name: Any
12-
format: Any
11+
bdist_dir: Incomplete
12+
plat_name: Incomplete
13+
format: Incomplete
1314
keep_temp: int
14-
dist_dir: Any
15-
skip_build: Any
15+
dist_dir: Incomplete
16+
skip_build: Incomplete
1617
relative: int
17-
owner: Any
18-
group: Any
18+
owner: Incomplete
19+
group: Incomplete
1920
def initialize_options(self) -> None: ...
2021
def finalize_options(self) -> None: ...
2122
def run(self) -> None: ...

mypy/typeshed/stdlib/distutils/command/bdist_msi.pyi

+18-17
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
import sys
2-
from typing import Any, ClassVar, Literal
2+
from _typeshed import Incomplete
3+
from typing import ClassVar, Literal
34

45
from ..cmd import Command
56

67
if sys.platform == "win32":
7-
from msilib import Dialog
8+
from msilib import Control, Dialog
89

910
class PyDialog(Dialog):
1011
def __init__(self, *args, **kw) -> None: ...
1112
def title(self, title) -> None: ...
12-
def back(self, title, next, name: str = "Back", active: bool | Literal[0, 1] = 1): ...
13-
def cancel(self, title, next, name: str = "Cancel", active: bool | Literal[0, 1] = 1): ...
14-
def next(self, title, next, name: str = "Next", active: bool | Literal[0, 1] = 1): ...
15-
def xbutton(self, name, title, next, xpos): ...
13+
def back(self, title, next, name: str = "Back", active: bool | Literal[0, 1] = 1) -> Control: ...
14+
def cancel(self, title, next, name: str = "Cancel", active: bool | Literal[0, 1] = 1) -> Control: ...
15+
def next(self, title, next, name: str = "Next", active: bool | Literal[0, 1] = 1) -> Control: ...
16+
def xbutton(self, name, title, next, xpos) -> Control: ...
1617

1718
class bdist_msi(Command):
1819
description: str
1920
user_options: ClassVar[list[tuple[str, str | None, str]]]
2021
boolean_options: ClassVar[list[str]]
21-
all_versions: Any
22+
all_versions: Incomplete
2223
other_version: str
2324
if sys.version_info >= (3, 9):
2425
def __init__(self, *args, **kw) -> None: ...
25-
bdist_dir: Any
26-
plat_name: Any
26+
bdist_dir: Incomplete
27+
plat_name: Incomplete
2728
keep_temp: int
2829
no_target_compile: int
2930
no_target_optimize: int
30-
target_version: Any
31-
dist_dir: Any
32-
skip_build: Any
33-
install_script: Any
34-
pre_install_script: Any
35-
versions: Any
31+
target_version: Incomplete
32+
dist_dir: Incomplete
33+
skip_build: Incomplete
34+
install_script: Incomplete
35+
pre_install_script: Incomplete
36+
versions: Incomplete
3637
def initialize_options(self) -> None: ...
37-
install_script_key: Any
38+
install_script_key: Incomplete
3839
def finalize_options(self) -> None: ...
39-
db: Any
40+
db: Incomplete
4041
def run(self) -> None: ...
4142
def add_files(self) -> None: ...
4243
def add_find_python(self) -> None: ...

0 commit comments

Comments
 (0)