Skip to content

Commit d16fc3e

Browse files
committed
Resolve conflicts with #354
2 parents bb565a4 + b2beb1c commit d16fc3e

File tree

9 files changed

+32
-36
lines changed

9 files changed

+32
-36
lines changed

distutils/command/build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,16 @@ def run(self) -> None:
136136

137137
# -- Predicates for the sub-command list ---------------------------
138138

139-
def has_pure_modules(self):
139+
def has_pure_modules(self) -> bool:
140140
return self.distribution.has_pure_modules()
141141

142-
def has_c_libraries(self):
142+
def has_c_libraries(self) -> bool:
143143
return self.distribution.has_c_libraries()
144144

145-
def has_ext_modules(self):
145+
def has_ext_modules(self) -> bool:
146146
return self.distribution.has_ext_modules()
147147

148-
def has_scripts(self):
148+
def has_scripts(self) -> bool:
149149
return self.distribution.has_scripts()
150150

151151
sub_commands = [

distutils/command/install.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,12 @@ def initialize_options(self) -> None:
264264
# supplied by the user, they are filled in using the installation
265265
# scheme implied by prefix/exec-prefix/home and the contents of
266266
# that installation scheme.
267-
self.install_purelib = None # for pure module distributions
268-
self.install_platlib = None # non-pure (dists w/ extensions)
269-
self.install_headers = None # for C/C++ headers
267+
self.install_purelib: str | None = None # for pure module distributions
268+
self.install_platlib: str | None = None # non-pure (dists w/ extensions)
269+
self.install_headers: str | None = None # for C/C++ headers
270270
self.install_lib: str | None = None # set to either purelib or platlib
271-
self.install_scripts = None
272-
self.install_data = None
271+
self.install_scripts: str | None = None
272+
self.install_data: str | None = None
273273
self.install_userbase = USER_BASE
274274
self.install_usersite = USER_SITE
275275

@@ -772,24 +772,24 @@ def get_inputs(self):
772772

773773
# -- Predicates for sub-command list -------------------------------
774774

775-
def has_lib(self):
775+
def has_lib(self) -> bool:
776776
"""Returns true if the current distribution has any Python
777777
modules to install."""
778778
return (
779779
self.distribution.has_pure_modules() or self.distribution.has_ext_modules()
780780
)
781781

782-
def has_headers(self):
782+
def has_headers(self) -> bool:
783783
"""Returns true if the current distribution has any headers to
784784
install."""
785785
return self.distribution.has_headers()
786786

787-
def has_scripts(self):
787+
def has_scripts(self) -> bool:
788788
"""Returns true if the current distribution has any scripts to.
789789
install."""
790790
return self.distribution.has_scripts()
791791

792-
def has_data(self):
792+
def has_data(self) -> bool:
793793
"""Returns true if the current distribution has any data to.
794794
install."""
795795
return self.distribution.has_data_files()

distutils/compilers/C/cygwin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
cygwin in no-cygwin mode).
77
"""
88

9+
from __future__ import annotations
10+
911
import copy
1012
import os
1113
import pathlib
@@ -327,7 +329,7 @@ def check_config_h():
327329
return code, f"{fn!r} {mention_inflected} {substring!r}"
328330

329331

330-
def is_cygwincc(cc):
332+
def is_cygwincc(cc: str | shlex._ShlexInstream) -> bool:
331333
"""Try to determine if the compiler that would be used is from cygwin."""
332334
out_string = check_output(shlex.split(cc) + ['-dumpmachine'])
333335
return out_string.strip().endswith(b'cygwin')

distutils/dist.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
# type-only import because of mutual dependence between these modules
4747
from .cmd import Command
48+
from .extension import Extension
4849

4950
_CommandT = TypeVar("_CommandT", bound="Command")
5051
_OptionsList: TypeAlias = list[
@@ -220,18 +221,18 @@ def __init__(self, attrs: MutableMapping[str, Any] | None = None) -> None: # no
220221
# These options are really the business of various commands, rather
221222
# than of the Distribution itself. We provide aliases for them in
222223
# Distribution as a convenience to the developer.
223-
self.packages = None
224+
self.packages: list[str] | None = None
224225
self.package_data: dict[str, list[str]] = {}
225-
self.package_dir = None
226-
self.py_modules = None
226+
self.package_dir: dict[str, str] | None = None
227+
self.py_modules: list[str] | None = None
227228
self.libraries = None
228229
self.headers = None
229-
self.ext_modules = None
230+
self.ext_modules: list[Extension] | None = None
230231
self.ext_package = None
231232
self.include_dirs = None
232233
self.extra_path = None
233234
self.scripts = None
234-
self.data_files = None
235+
self.data_files: list[str | tuple] | None = None
235236
self.password = ''
236237

237238
# And now initialize bookkeeping stuff that can't be supplied by
@@ -1024,25 +1025,25 @@ def run_command(self, command: str) -> None:
10241025
# -- Distribution query methods ------------------------------------
10251026

10261027
def has_pure_modules(self) -> bool:
1027-
return len(self.packages or self.py_modules or []) > 0
1028+
return bool(self.packages or self.py_modules)
10281029

10291030
def has_ext_modules(self) -> bool:
1030-
return self.ext_modules and len(self.ext_modules) > 0
1031+
return bool(self.ext_modules)
10311032

10321033
def has_c_libraries(self) -> bool:
1033-
return self.libraries and len(self.libraries) > 0
1034+
return bool(self.libraries)
10341035

10351036
def has_modules(self) -> bool:
10361037
return self.has_pure_modules() or self.has_ext_modules()
10371038

10381039
def has_headers(self) -> bool:
1039-
return self.headers and len(self.headers) > 0
1040+
return bool(self.headers)
10401041

10411042
def has_scripts(self) -> bool:
1042-
return self.scripts and len(self.scripts) > 0
1043+
return bool(self.scripts)
10431044

10441045
def has_data_files(self) -> bool:
1045-
return self.data_files and len(self.data_files) > 0
1046+
return bool(self.data_files)
10461047

10471048
def is_pure(self) -> bool:
10481049
return (

distutils/fancy_getopt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def add_option(self, long_option, short_option=None, help_string=None):
105105
self.option_table.append(option)
106106
self.option_index[long_option] = option
107107

108-
def has_option(self, long_option):
108+
def has_option(self, long_option: str) -> bool:
109109
"""Return true if the option table for this parser has an
110110
option with long name 'long_option'."""
111111
return long_option in self.option_index

distutils/tests/test_check.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ def test_check_author_maintainer(self):
126126
assert cmd._warnings == 0
127127

128128
def test_check_document(self):
129-
pytest.importorskip('docutils')
130129
pkg_info, dist = self.create_dist()
131130
cmd = _check.check(dist)
132131

@@ -141,7 +140,6 @@ def test_check_document(self):
141140
assert len(msgs) == 0
142141

143142
def test_check_restructuredtext(self):
144-
pytest.importorskip('docutils')
145143
# let's see if it detects broken rest in long_description
146144
broken_rest = 'title\n===\n\ntest'
147145
pkg_info, dist = self.create_dist(long_description=broken_rest)

distutils/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,6 @@ def is_mingw() -> bool:
513513
return sys.platform == 'win32' and get_platform().startswith('mingw')
514514

515515

516-
def is_freethreaded():
516+
def is_freethreaded() -> bool:
517517
"""Return True if the Python interpreter is built with free threading support."""
518518
return bool(sysconfig.get_config_var('Py_GIL_DISABLED'))

mypy.ini

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ disable_error_code =
3131
misc,
3232
has-type,
3333

34-
# Is only imported in a test and doesn't seem relevant.
35-
# TODO: Should we add types-pygments or remove from the test?
36-
[mypy-pygments.*]
37-
ignore_missing_imports = True
38-
3934
# stdlib's test module is not typed on typeshed
4035
[mypy-test.*]
4136
ignore_missing_imports = True

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ test = [
3434
"pytest >= 6, != 8.1.*",
3535

3636
# local
37-
"pytest >= 7.4.3", # 186
37+
"pytest >= 7.4.3", # pypa/distutils#186
3838
"jaraco.envs>=2.4",
3939
"jaraco.path",
4040
"jaraco.text",
4141
"path >= 10.6",
4242
"docutils",
43+
"Pygments",
4344
"pyfakefs",
4445
"more_itertools",
45-
"pygments",
4646

4747
# workaround for pytest-dev/pytest#12490
4848
"pytest < 8.1; python_version < '3.12'",

0 commit comments

Comments
 (0)