Skip to content

Commit a6c6bc1

Browse files
authored
Fix stdlib/disutils testing (#9734)
1 parent 880c0da commit a6c6bc1

18 files changed

+171
-268
lines changed

.github/workflows/daily.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
cache: pip
4949
cache-dependency-path: requirements-tests.txt
5050
- name: Install dependencies
51-
run: pip install $(grep mypy== requirements-tests.txt)
51+
run: pip install -r requirements-tests.txt
5252
- name: Run stubtest
5353
run: python tests/stubtest_stdlib.py
5454

.github/workflows/stubtest_stdlib.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ jobs:
4444
cache: pip
4545
cache-dependency-path: requirements-tests.txt
4646
- name: Install dependencies
47-
run: pip install $(grep mypy== requirements-tests.txt)
47+
run: pip install -r requirements-tests.txt
4848
- name: Run stubtest
4949
run: python tests/stubtest_stdlib.py

pyrightconfig.stricter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// test cases use a custom pyrightconfig file
1010
"stubs/**/@tests/test_cases",
1111
"stdlib/distutils/command",
12+
"stdlib/distutils/dist.pyi",
1213
"stdlib/lib2to3/refactor.pyi",
1314
"stdlib/_tkinter.pyi",
1415
"stdlib/tkinter/__init__.pyi",

stdlib/distutils/cmd.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import Incomplete
12
from abc import abstractmethod
23
from collections.abc import Callable, Iterable
34
from distutils.dist import Distribution
@@ -60,3 +61,5 @@ class Command:
6061
skip_msg: str | None = None,
6162
level: Any = 1,
6263
) -> None: ... # level is not used
64+
def ensure_finalized(self) -> None: ...
65+
def dump_options(self, header: Incomplete | None = None, indent: str = "") -> None: ...

stdlib/distutils/core.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1+
from _typeshed import StrOrBytesPath
12
from collections.abc import Mapping
23
from distutils.cmd import Command as Command
34
from distutils.dist import Distribution as Distribution
45
from distutils.extension import Extension as Extension
56
from typing import Any
67

8+
USAGE: str
9+
10+
def gen_usage(script_name: StrOrBytesPath) -> str: ...
11+
12+
setup_keywords: tuple[str, ...]
13+
extension_keywords: tuple[str, ...]
14+
715
def setup(
816
*,
917
name: str = ...,

stdlib/distutils/cygwinccompiler.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
from distutils.unixccompiler import UnixCCompiler
2+
from distutils.version import LooseVersion
3+
from re import Pattern
4+
from typing_extensions import Literal
5+
6+
def get_msvcr() -> list[str] | None: ...
27

38
class CygwinCCompiler(UnixCCompiler): ...
49
class Mingw32CCompiler(CygwinCCompiler): ...
10+
11+
CONFIG_H_OK: str
12+
CONFIG_H_NOTOK: str
13+
CONFIG_H_UNCERTAIN: str
14+
15+
def check_config_h() -> tuple[Literal["ok", "not ok", "uncertain"], str]: ...
16+
17+
RE_VERSION: Pattern[bytes]
18+
19+
def get_versions() -> tuple[LooseVersion | None, ...]: ...
20+
def is_cygwingcc() -> bool: ...

stdlib/distutils/dist.pyi

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
from _typeshed import FileDescriptorOrPath, SupportsWrite
1+
from _typeshed import FileDescriptorOrPath, Incomplete, SupportsWrite
22
from collections.abc import Iterable, Mapping
33
from distutils.cmd import Command
4+
from re import Pattern
45
from typing import IO, Any
56

7+
command_re: Pattern[str]
8+
69
class DistributionMetadata:
710
def __init__(self, path: FileDescriptorOrPath | None = None) -> None: ...
811
name: str | None
@@ -57,3 +60,57 @@ class Distribution:
5760
def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ...
5861
def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ...
5962
def get_command_obj(self, command: str, create: bool = ...) -> Command | None: ...
63+
global_options: Incomplete
64+
common_usage: str
65+
display_options: Incomplete
66+
display_option_names: Incomplete
67+
negative_opt: Incomplete
68+
verbose: int
69+
dry_run: int
70+
help: int
71+
command_packages: Incomplete
72+
script_name: Incomplete
73+
script_args: Incomplete
74+
command_options: Incomplete
75+
dist_files: Incomplete
76+
packages: Incomplete
77+
package_data: Incomplete
78+
package_dir: Incomplete
79+
py_modules: Incomplete
80+
libraries: Incomplete
81+
headers: Incomplete
82+
ext_modules: Incomplete
83+
ext_package: Incomplete
84+
include_dirs: Incomplete
85+
extra_path: Incomplete
86+
scripts: Incomplete
87+
data_files: Incomplete
88+
password: str
89+
command_obj: Incomplete
90+
have_run: Incomplete
91+
want_user_cfg: bool
92+
def dump_option_dicts(
93+
self, header: Incomplete | None = ..., commands: Incomplete | None = ..., indent: str = ...
94+
) -> None: ...
95+
def find_config_files(self): ...
96+
commands: Incomplete
97+
def parse_command_line(self): ...
98+
def finalize_options(self) -> None: ...
99+
def handle_display_options(self, option_order): ...
100+
def print_command_list(self, commands, header, max_length) -> None: ...
101+
def print_commands(self) -> None: ...
102+
def get_command_list(self): ...
103+
def get_command_packages(self): ...
104+
def get_command_class(self, command): ...
105+
def reinitialize_command(self, command, reinit_subcommands: int = ...): ...
106+
def announce(self, msg, level=...) -> None: ...
107+
def run_commands(self) -> None: ...
108+
def run_command(self, command) -> None: ...
109+
def has_pure_modules(self): ...
110+
def has_ext_modules(self): ...
111+
def has_c_libraries(self): ...
112+
def has_modules(self): ...
113+
def has_headers(self): ...
114+
def has_scripts(self): ...
115+
def has_data_files(self): ...
116+
def is_pure(self): ...

stdlib/distutils/fancy_getopt.pyi

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
from collections.abc import Iterable, Mapping
2+
from re import Pattern
23
from typing import Any, overload
34
from typing_extensions import TypeAlias
45

56
_Option: TypeAlias = tuple[str, str | None, str]
67
_GR: TypeAlias = tuple[list[str], OptionDummy]
78

8-
def fancy_getopt(
9-
options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None
10-
) -> list[str] | _GR: ...
11-
def wrap_text(text: str, width: int) -> list[str]: ...
9+
longopt_pat: str
10+
longopt_re: Pattern[str]
11+
neg_alias_re: Pattern[str]
12+
longopt_xlate: dict[int, int]
1213

1314
class FancyGetopt:
1415
def __init__(self, option_table: list[_Option] | None = None) -> None: ...
@@ -20,5 +21,14 @@ class FancyGetopt:
2021
def get_option_order(self) -> list[tuple[str, str]]: ...
2122
def generate_help(self, header: str | None = None) -> list[str]: ...
2223

24+
def fancy_getopt(
25+
options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None
26+
) -> list[str] | _GR: ...
27+
28+
WS_TRANS: dict[int, str]
29+
30+
def wrap_text(text: str, width: int) -> list[str]: ...
31+
def translate_longopt(opt: str) -> str: ...
32+
2333
class OptionDummy:
2434
def __init__(self, options: Iterable[str] = ...) -> None: ...

stdlib/distutils/sysconfig.pyi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
import sys
12
from collections.abc import Mapping
23
from distutils.ccompiler import CCompiler
34

45
PREFIX: str
56
EXEC_PREFIX: str
7+
BASE_PREFIX: str
8+
BASE_EXEC_PREFIX: str
9+
project_base: str
10+
python_build: bool
611

12+
def expand_makefile_vars(s: str, vars: Mapping[str, str]) -> str: ...
713
def get_config_var(name: str) -> int | str | None: ...
814
def get_config_vars(*args: str) -> Mapping[str, int | str]: ...
915
def get_config_h_filename() -> str: ...
1016
def get_makefile_filename() -> str: ...
1117
def get_python_inc(plat_specific: bool = ..., prefix: str | None = None) -> str: ...
1218
def get_python_lib(plat_specific: bool = ..., standard_lib: bool = ..., prefix: str | None = None) -> str: ...
1319
def customize_compiler(compiler: CCompiler) -> None: ...
20+
21+
if sys.version_info < (3, 10):
22+
def get_python_version() -> str: ...

stdlib/distutils/util.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import sys
12
from _typeshed import StrPath, Unused
23
from collections.abc import Callable, Container, Iterable, Mapping
34
from typing import Any
45
from typing_extensions import Literal
56

7+
if sys.version_info >= (3, 8):
8+
def get_host_platform() -> str: ...
9+
610
def get_platform() -> str: ...
711
def convert_path(pathname: str) -> str: ...
812
def change_root(new_root: str, pathname: str) -> str: ...

tests/stubtest_allowlists/py310.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ _collections_abc.MappingView.__class_getitem__
8686
_csv.Reader
8787
_csv.Writer
8888
bdb.Breakpoint.clearBreakpoints
89-
distutils.util.get_host_platform
9089
inspect.Signature.from_builtin # Removed in 3.11, can add if someone needs this
9190
inspect.Signature.from_function # Removed in 3.11, can add if someone needs this
9291
multiprocessing.managers.SharedMemoryServer.create
@@ -169,7 +168,3 @@ ast.ImportFrom.level # None on the class, but never None on instances
169168

170169
# White lies around defaults
171170
dataclasses.KW_ONLY
172-
173-
# stubtest confuses stdlib distutils with setuptools-bundled distutils (#8410),
174-
# and the whole directory is going to be removed in 3.12 anyway
175-
distutils\..*

tests/stubtest_allowlists/py311.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,3 @@ typing._TypedDict.values
139139

140140
# White lies around defaults
141141
dataclasses.KW_ONLY
142-
143-
# stubtest confuses stdlib distutils with setuptools-bundled distutils (#8410),
144-
# and the whole directory is going to be removed in 3.12 anyway
145-
distutils\..*

tests/stubtest_allowlists/py37.txt

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ tkinter.Tk.__init__
7575
# Exists at runtime, but missing from stubs
7676
contextvars.ContextVar.__class_getitem__
7777
datetime.datetime_CAPI
78-
distutils.sysconfig.expand_makefile_vars
79-
distutils.sysconfig.get_python_version
80-
distutils.cygwinccompiler.RE_VERSION
81-
distutils.dist.command_re
82-
distutils.fancy_getopt.longopt_re
83-
distutils.fancy_getopt.neg_alias_re
84-
distutils.core.USAGE
85-
distutils.core.extension_keywords
86-
distutils.core.gen_usage
87-
distutils.core.setup_keywords
8878
dummy_threading.Lock
8979
dummy_threading.RLock
9080
html.parser.HTMLParser.unescape
@@ -162,54 +152,3 @@ types.GetSetDescriptorType.__get__
162152
types.MemberDescriptorType.__get__
163153
types.MethodDescriptorType.__get__
164154
types.WrapperDescriptorType.__get__
165-
166-
# Missing from distutils (deprecated, to be removed in 3.12)
167-
distutils.core.USAGE
168-
distutils.core.extension_keywords
169-
distutils.core.gen_usage
170-
distutils.core.setup_keywords
171-
distutils.core.Command.dump_options
172-
distutils.core.Command.ensure_finalized
173-
distutils.core.Distribution.announce
174-
distutils.core.Distribution.common_usage
175-
distutils.core.Distribution.display_option_names
176-
distutils.core.Distribution.display_options
177-
distutils.core.Distribution.dump_option_dicts
178-
distutils.core.Distribution.find_config_files
179-
distutils.core.Distribution.get_command_packages
180-
distutils.core.Distribution.global_options
181-
distutils.core.Distribution.has_c_libraries
182-
distutils.core.Distribution.has_data_files
183-
distutils.core.Distribution.has_ext_modules
184-
distutils.core.Distribution.has_headers
185-
distutils.core.Distribution.has_modules
186-
distutils.core.Distribution.has_pure_modules
187-
distutils.core.Distribution.has_scripts
188-
distutils.core.Distribution.is_pure
189-
distutils.core.Distribution.negative_opt
190-
distutils.core.Distribution.parse_command_line
191-
distutils.core.Distribution.print_command_list
192-
distutils.core.Distribution.reinitialize_command
193-
distutils.core.Distribution.run_commands
194-
distutils.cygwinccompiler.is_cygwingcc
195-
distutils.dist.Distribution.announce
196-
distutils.dist.Distribution.common_usage
197-
distutils.dist.Distribution.display_option_names
198-
distutils.dist.Distribution.display_options
199-
distutils.dist.Distribution.dump_option_dicts
200-
distutils.dist.Distribution.find_config_files
201-
distutils.dist.Distribution.get_command_packages
202-
distutils.dist.Distribution.global_options
203-
distutils.dist.Distribution.has_c_libraries
204-
distutils.dist.Distribution.has_data_files
205-
distutils.dist.Distribution.has_ext_modules
206-
distutils.dist.Distribution.has_headers
207-
distutils.dist.Distribution.has_modules
208-
distutils.dist.Distribution.has_pure_modules
209-
distutils.dist.Distribution.has_scripts
210-
distutils.dist.Distribution.is_pure
211-
distutils.dist.Distribution.negative_opt
212-
distutils.dist.Distribution.parse_command_line
213-
distutils.dist.Distribution.print_command_list
214-
distutils.dist.Distribution.reinitialize_command
215-
distutils.dist.Distribution.run_commands

tests/stubtest_allowlists/py38.txt

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ collections.KeysView.__reversed__
3535
collections.ValuesView.__reversed__
3636
collections.Mapping.__reversed__ # Set to None at runtime for a better error message
3737
distutils.command.bdist_wininst # see #6523
38-
distutils.core.USAGE
39-
distutils.core.extension_keywords
40-
distutils.core.gen_usage
41-
distutils.core.setup_keywords
4238
dummy_threading.Condition.acquire
4339
dummy_threading.Condition.release
4440
dummy_threading.Event.isSet
@@ -97,13 +93,6 @@ tkinter.Tk.__init__
9793
# Exists at runtime, but missing from stubs
9894
contextvars.ContextVar.__class_getitem__
9995
datetime.datetime_CAPI
100-
distutils.sysconfig.expand_makefile_vars
101-
distutils.sysconfig.get_python_version
102-
distutils.util.get_host_platform
103-
distutils.cygwinccompiler.RE_VERSION
104-
distutils.dist.command_re
105-
distutils.fancy_getopt.longopt_re
106-
distutils.fancy_getopt.neg_alias_re
10796
dummy_threading.ExceptHookArgs
10897
dummy_threading.Lock
10998
dummy_threading.RLock
@@ -180,54 +169,3 @@ types.GetSetDescriptorType.__get__
180169
types.MemberDescriptorType.__get__
181170
types.MethodDescriptorType.__get__
182171
types.WrapperDescriptorType.__get__
183-
184-
# Missing from distutils (deprecated, to be removed in 3.12)
185-
distutils.core.USAGE
186-
distutils.core.extension_keywords
187-
distutils.core.gen_usage
188-
distutils.core.setup_keywords
189-
distutils.core.Command.dump_options
190-
distutils.core.Command.ensure_finalized
191-
distutils.core.Distribution.announce
192-
distutils.core.Distribution.common_usage
193-
distutils.core.Distribution.display_option_names
194-
distutils.core.Distribution.display_options
195-
distutils.core.Distribution.dump_option_dicts
196-
distutils.core.Distribution.find_config_files
197-
distutils.core.Distribution.get_command_packages
198-
distutils.core.Distribution.global_options
199-
distutils.core.Distribution.has_c_libraries
200-
distutils.core.Distribution.has_data_files
201-
distutils.core.Distribution.has_ext_modules
202-
distutils.core.Distribution.has_headers
203-
distutils.core.Distribution.has_modules
204-
distutils.core.Distribution.has_pure_modules
205-
distutils.core.Distribution.has_scripts
206-
distutils.core.Distribution.is_pure
207-
distutils.core.Distribution.negative_opt
208-
distutils.core.Distribution.parse_command_line
209-
distutils.core.Distribution.print_command_list
210-
distutils.core.Distribution.reinitialize_command
211-
distutils.core.Distribution.run_commands
212-
distutils.cygwinccompiler.is_cygwingcc
213-
distutils.dist.Distribution.announce
214-
distutils.dist.Distribution.common_usage
215-
distutils.dist.Distribution.display_option_names
216-
distutils.dist.Distribution.display_options
217-
distutils.dist.Distribution.dump_option_dicts
218-
distutils.dist.Distribution.find_config_files
219-
distutils.dist.Distribution.get_command_packages
220-
distutils.dist.Distribution.global_options
221-
distutils.dist.Distribution.has_c_libraries
222-
distutils.dist.Distribution.has_data_files
223-
distutils.dist.Distribution.has_ext_modules
224-
distutils.dist.Distribution.has_headers
225-
distutils.dist.Distribution.has_modules
226-
distutils.dist.Distribution.has_pure_modules
227-
distutils.dist.Distribution.has_scripts
228-
distutils.dist.Distribution.is_pure
229-
distutils.dist.Distribution.negative_opt
230-
distutils.dist.Distribution.parse_command_line
231-
distutils.dist.Distribution.print_command_list
232-
distutils.dist.Distribution.reinitialize_command
233-
distutils.dist.Distribution.run_commands

0 commit comments

Comments
 (0)