Skip to content

Commit 082c937

Browse files
authored
Sync typeshed (#10924)
Source commit: python/typeshed@b2e429c Co-authored-by: hauntsaninja <>
1 parent 14eaa18 commit 082c937

40 files changed

+974
-217
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ def TemporaryFile(
5555
bufsize: int = ...,
5656
suffix: Union[bytes, unicode] = ...,
5757
prefix: Union[bytes, unicode] = ...,
58-
dir: Union[bytes, unicode] = ...,
58+
dir: Optional[Union[bytes, unicode]] = ...,
5959
) -> _TemporaryFileWrapper: ...
6060
def NamedTemporaryFile(
6161
mode: Union[bytes, unicode] = ...,
6262
bufsize: int = ...,
6363
suffix: Union[bytes, unicode] = ...,
6464
prefix: Union[bytes, unicode] = ...,
65-
dir: Union[bytes, unicode] = ...,
65+
dir: Optional[Union[bytes, unicode]] = ...,
6666
delete: bool = ...,
6767
) -> _TemporaryFileWrapper: ...
6868
def SpooledTemporaryFile(
@@ -71,7 +71,7 @@ def SpooledTemporaryFile(
7171
buffering: int = ...,
7272
suffix: Union[bytes, unicode] = ...,
7373
prefix: Union[bytes, unicode] = ...,
74-
dir: Union[bytes, unicode] = ...,
74+
dir: Optional[Union[bytes, unicode]] = ...,
7575
) -> _TemporaryFileWrapper: ...
7676

7777
class TemporaryDirectory:

mypy/typeshed/stdlib/_typeshed/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class SupportsDivMod(Protocol[_T_contra, _T_co]):
3737
class SupportsRDivMod(Protocol[_T_contra, _T_co]):
3838
def __rdivmod__(self, __other: _T_contra) -> _T_co: ...
3939

40+
class SupportsLenAndGetItem(Protocol[_T_co]):
41+
def __len__(self) -> int: ...
42+
def __getitem__(self, __k: int) -> _T_co: ...
43+
4044
# Mapping-like protocols
4145

4246
# stable

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ from _typeshed import (
1111
StrOrBytesPath,
1212
SupportsDivMod,
1313
SupportsKeysAndGetItem,
14+
SupportsLenAndGetItem,
1415
SupportsLessThan,
1516
SupportsLessThanT,
1617
SupportsRDivMod,
@@ -159,8 +160,8 @@ class type(object):
159160
@classmethod
160161
def __prepare__(metacls, __name: str, __bases: Tuple[type, ...], **kwds: Any) -> Mapping[str, Any]: ...
161162
if sys.version_info >= (3, 10):
162-
def __or__(self, t: Any) -> types.Union: ...
163-
def __ror__(self, t: Any) -> types.Union: ...
163+
def __or__(self, t: Any) -> types.UnionType: ...
164+
def __ror__(self, t: Any) -> types.UnionType: ...
164165

165166
class super(object):
166167
@overload
@@ -1059,10 +1060,10 @@ def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ...
10591060

10601061
if sys.version_info >= (3, 10):
10611062
def isinstance(
1062-
__obj: object, __class_or_tuple: Union[type, types.Union, Tuple[Union[type, types.Union, Tuple[Any, ...]], ...]]
1063+
__obj: object, __class_or_tuple: Union[type, types.UnionType, Tuple[Union[type, types.UnionType, Tuple[Any, ...]], ...]]
10631064
) -> bool: ...
10641065
def issubclass(
1065-
__cls: type, __class_or_tuple: Union[type, types.Union, Tuple[Union[type, types.Union, Tuple[Any, ...]], ...]]
1066+
__cls: type, __class_or_tuple: Union[type, types.UnionType, Tuple[Union[type, types.UnionType, Tuple[Any, ...]], ...]]
10661067
) -> bool: ...
10671068

10681069
else:
@@ -1286,10 +1287,10 @@ else:
12861287
def quit(code: object = ...) -> NoReturn: ...
12871288

12881289
class reversed(Iterator[_T], Generic[_T]):
1289-
@overload
1290-
def __init__(self, __sequence: Sequence[_T]) -> None: ...
12911290
@overload
12921291
def __init__(self, __sequence: Reversible[_T]) -> None: ...
1292+
@overload
1293+
def __init__(self, __sequence: SupportsLenAndGetItem[_T]) -> None: ...
12931294
def __iter__(self) -> Iterator[_T]: ...
12941295
def __next__(self) -> _T: ...
12951296

mypy/typeshed/stdlib/code.pyi

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
1+
from codeop import CommandCompiler
12
from types import CodeType
2-
from typing import Any, Callable, Mapping, Optional
3+
from typing import Any, Callable, Mapping
34

45
class InteractiveInterpreter:
5-
def __init__(self, locals: Optional[Mapping[str, Any]] = ...) -> None: ...
6+
locals: Mapping[str, Any] # undocumented
7+
compile: CommandCompiler # undocumented
8+
def __init__(self, locals: Mapping[str, Any] | None = ...) -> None: ...
69
def runsource(self, source: str, filename: str = ..., symbol: str = ...) -> bool: ...
710
def runcode(self, code: CodeType) -> None: ...
8-
def showsyntaxerror(self, filename: Optional[str] = ...) -> None: ...
11+
def showsyntaxerror(self, filename: str | None = ...) -> None: ...
912
def showtraceback(self) -> None: ...
1013
def write(self, data: str) -> None: ...
1114

1215
class InteractiveConsole(InteractiveInterpreter):
13-
def __init__(self, locals: Optional[Mapping[str, Any]] = ..., filename: str = ...) -> None: ...
14-
def interact(self, banner: Optional[str] = ..., exitmsg: Optional[str] = ...) -> None: ...
16+
buffer: list[str] # undocumented
17+
filename: str # undocumented
18+
def __init__(self, locals: Mapping[str, Any] | None = ..., filename: str = ...) -> None: ...
19+
def interact(self, banner: str | None = ..., exitmsg: str | None = ...) -> None: ...
1520
def push(self, line: str) -> bool: ...
1621
def resetbuffer(self) -> None: ...
1722
def raw_input(self, prompt: str = ...) -> str: ...
1823

1924
def interact(
20-
banner: Optional[str] = ...,
21-
readfunc: Optional[Callable[[str], str]] = ...,
22-
local: Optional[Mapping[str, Any]] = ...,
23-
exitmsg: Optional[str] = ...,
25+
banner: str | None = ...,
26+
readfunc: Callable[[str], str] | None = ...,
27+
local: Mapping[str, Any] | None = ...,
28+
exitmsg: str | None = ...,
2429
) -> None: ...
25-
def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ...
30+
def compile_command(source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ...

mypy/typeshed/stdlib/dataclasses.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ class _MISSING_TYPE: ...
1313
MISSING: _MISSING_TYPE
1414

1515
if sys.version_info >= (3, 10):
16-
class _KW_ONLY_TYPE: ...
17-
KW_ONLY: _KW_ONLY_TYPE
16+
class KW_ONLY: ...
1817

1918
@overload
2019
def asdict(obj: Any) -> Dict[str, Any]: ...
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from typing import Any
2+
3+
from ..cmd import Command
4+
5+
def show_formats() -> None: ...
6+
7+
class bdist(Command):
8+
description: str
9+
user_options: Any
10+
boolean_options: Any
11+
help_options: Any
12+
no_format_option: Any
13+
default_format: Any
14+
format_commands: Any
15+
format_command: Any
16+
bdist_base: Any
17+
plat_name: Any
18+
formats: Any
19+
dist_dir: Any
20+
skip_build: int
21+
group: Any
22+
owner: Any
23+
def initialize_options(self) -> None: ...
24+
def finalize_options(self) -> None: ...
25+
def run(self) -> None: ...
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from typing import Any
2+
3+
from ..cmd import Command
4+
5+
class bdist_dumb(Command):
6+
description: str
7+
user_options: Any
8+
boolean_options: Any
9+
default_format: Any
10+
bdist_dir: Any
11+
plat_name: Any
12+
format: Any
13+
keep_temp: int
14+
dist_dir: Any
15+
skip_build: Any
16+
relative: int
17+
owner: Any
18+
group: Any
19+
def initialize_options(self) -> None: ...
20+
def finalize_options(self) -> None: ...
21+
def run(self) -> None: ...
Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,43 @@
1-
from distutils.cmd import Command
1+
import sys
2+
from typing import Any
23

3-
class bdist_msi(Command):
4-
def initialize_options(self) -> None: ...
5-
def finalize_options(self) -> None: ...
6-
def run(self) -> None: ...
4+
from ..cmd import Command
5+
6+
if sys.platform == "win32":
7+
from msilib import Dialog
8+
class PyDialog(Dialog):
9+
def __init__(self, *args, **kw) -> None: ...
10+
def title(self, title) -> None: ...
11+
def back(self, title, next, name: str = ..., active: int = ...): ...
12+
def cancel(self, title, next, name: str = ..., active: int = ...): ...
13+
def next(self, title, next, name: str = ..., active: int = ...): ...
14+
def xbutton(self, name, title, next, xpos): ...
15+
class bdist_msi(Command):
16+
description: str
17+
user_options: Any
18+
boolean_options: Any
19+
all_versions: Any
20+
other_version: str
21+
if sys.version_info >= (3, 9):
22+
def __init__(self, *args, **kw) -> None: ...
23+
bdist_dir: Any
24+
plat_name: Any
25+
keep_temp: int
26+
no_target_compile: int
27+
no_target_optimize: int
28+
target_version: Any
29+
dist_dir: Any
30+
skip_build: Any
31+
install_script: Any
32+
pre_install_script: Any
33+
versions: Any
34+
def initialize_options(self) -> None: ...
35+
install_script_key: Any
36+
def finalize_options(self) -> None: ...
37+
db: Any
38+
def run(self) -> None: ...
39+
def add_files(self) -> None: ...
40+
def add_find_python(self) -> None: ...
41+
def add_scripts(self) -> None: ...
42+
def add_ui(self) -> None: ...
43+
def get_installer_filename(self, fullname): ...
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from typing import Any
2+
3+
from ..cmd import Command
4+
5+
class bdist_rpm(Command):
6+
description: str
7+
user_options: Any
8+
boolean_options: Any
9+
negative_opt: Any
10+
bdist_base: Any
11+
rpm_base: Any
12+
dist_dir: Any
13+
python: Any
14+
fix_python: Any
15+
spec_only: Any
16+
binary_only: Any
17+
source_only: Any
18+
use_bzip2: Any
19+
distribution_name: Any
20+
group: Any
21+
release: Any
22+
serial: Any
23+
vendor: Any
24+
packager: Any
25+
doc_files: Any
26+
changelog: Any
27+
icon: Any
28+
prep_script: Any
29+
build_script: Any
30+
install_script: Any
31+
clean_script: Any
32+
verify_script: Any
33+
pre_install: Any
34+
post_install: Any
35+
pre_uninstall: Any
36+
post_uninstall: Any
37+
prep: Any
38+
provides: Any
39+
requires: Any
40+
conflicts: Any
41+
build_requires: Any
42+
obsoletes: Any
43+
keep_temp: int
44+
use_rpm_opt_flags: int
45+
rpm3_mode: int
46+
no_autoreq: int
47+
force_arch: Any
48+
quiet: int
49+
def initialize_options(self) -> None: ...
50+
def finalize_options(self) -> None: ...
51+
def finalize_package_data(self) -> None: ...
52+
def run(self) -> None: ...
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from typing import Any
2+
3+
from ..cmd import Command
4+
5+
def show_compilers() -> None: ...
6+
7+
class build(Command):
8+
description: str
9+
user_options: Any
10+
boolean_options: Any
11+
help_options: Any
12+
build_base: str
13+
build_purelib: Any
14+
build_platlib: Any
15+
build_lib: Any
16+
build_temp: Any
17+
build_scripts: Any
18+
compiler: Any
19+
plat_name: Any
20+
debug: Any
21+
force: int
22+
executable: Any
23+
parallel: Any
24+
def initialize_options(self) -> None: ...
25+
def finalize_options(self) -> None: ...
26+
def run(self) -> None: ...
27+
def has_pure_modules(self): ...
28+
def has_c_libraries(self): ...
29+
def has_ext_modules(self): ...
30+
def has_scripts(self): ...
31+
sub_commands: Any
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from typing import Any
2+
3+
from ..cmd import Command
4+
5+
def show_compilers() -> None: ...
6+
7+
class build_clib(Command):
8+
description: str
9+
user_options: Any
10+
boolean_options: Any
11+
help_options: Any
12+
build_clib: Any
13+
build_temp: Any
14+
libraries: Any
15+
include_dirs: Any
16+
define: Any
17+
undef: Any
18+
debug: Any
19+
force: int
20+
compiler: Any
21+
def initialize_options(self) -> None: ...
22+
def finalize_options(self) -> None: ...
23+
def run(self) -> None: ...
24+
def check_library_list(self, libraries) -> None: ...
25+
def get_library_names(self): ...
26+
def get_source_files(self): ...
27+
def build_libraries(self, libraries) -> None: ...
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from typing import Any
2+
3+
from ..cmd import Command
4+
5+
extension_name_re: Any
6+
7+
def show_compilers() -> None: ...
8+
9+
class build_ext(Command):
10+
description: str
11+
sep_by: Any
12+
user_options: Any
13+
boolean_options: Any
14+
help_options: Any
15+
extensions: Any
16+
build_lib: Any
17+
plat_name: Any
18+
build_temp: Any
19+
inplace: int
20+
package: Any
21+
include_dirs: Any
22+
define: Any
23+
undef: Any
24+
libraries: Any
25+
library_dirs: Any
26+
rpath: Any
27+
link_objects: Any
28+
debug: Any
29+
force: Any
30+
compiler: Any
31+
swig: Any
32+
swig_cpp: Any
33+
swig_opts: Any
34+
user: Any
35+
parallel: Any
36+
def initialize_options(self) -> None: ...
37+
def finalize_options(self) -> None: ...
38+
def run(self) -> None: ...
39+
def check_extensions_list(self, extensions) -> None: ...
40+
def get_source_files(self): ...
41+
def get_outputs(self): ...
42+
def build_extensions(self) -> None: ...
43+
def build_extension(self, ext) -> None: ...
44+
def swig_sources(self, sources, extension): ...
45+
def find_swig(self): ...
46+
def get_ext_fullpath(self, ext_name): ...
47+
def get_ext_fullname(self, ext_name): ...
48+
def get_ext_filename(self, ext_name): ...
49+
def get_export_symbols(self, ext): ...
50+
def get_libraries(self, ext): ...

0 commit comments

Comments
 (0)