6
6
import os
7
7
import sysconfig
8
8
import typing as t
9
+ from collections .abc import Iterator
9
10
from contextlib import contextmanager , nullcontext , suppress
10
11
from functools import partial
11
12
from pathlib import Path
56
57
'get_requires_for_build_wheel' ,
57
58
'prepare_metadata_for_build_wheel' ,
58
59
* (
59
- () if _setuptools_build_editable is None
60
+ () if _setuptools_build_editable is None # type: ignore[redundant-expr]
60
61
else (
61
62
'build_editable' ,
62
63
'get_requires_for_build_editable' ,
87
88
"""A fallback for ``pure-python`` is not set."""
88
89
89
90
90
- def _is_truthy_setting_value (setting_value ) -> bool :
91
+ def _is_truthy_setting_value (setting_value : str ) -> bool :
91
92
truthy_values = {'' , None , 'true' , '1' , 'on' }
92
93
return setting_value .lower () in truthy_values
93
94
@@ -108,7 +109,7 @@ def _get_setting_value(
108
109
continue
109
110
110
111
with suppress (lookup_errors ): # type: ignore[arg-type]
111
- return _is_truthy_setting_value (src_mapping [src_key ]) # type: ignore[index]
112
+ return _is_truthy_setting_value (src_mapping [src_key ]) # type: ignore[arg-type, index]
112
113
113
114
return default
114
115
@@ -125,7 +126,7 @@ def _make_pure_python(config_settings: _ConfigDict | None = None) -> bool:
125
126
def _include_cython_line_tracing (
126
127
config_settings : _ConfigDict | None = None ,
127
128
* ,
128
- default = False ,
129
+ default : bool = False ,
129
130
) -> bool :
130
131
return _get_setting_value (
131
132
config_settings ,
@@ -136,60 +137,61 @@ def _include_cython_line_tracing(
136
137
137
138
138
139
@contextmanager
139
- def patched_distutils_cmd_install ():
140
+ def patched_distutils_cmd_install () -> Iterator [ None ] :
140
141
"""Make `install_lib` of `install` cmd always use `platlib`.
141
142
142
143
:yields: None
143
144
"""
144
145
# Without this, build_lib puts stuff under `*.data/purelib/` folder
145
146
orig_finalize = _distutils_install_cmd .finalize_options
146
147
147
- def new_finalize_options (self ): # noqa: WPS430
148
+ def new_finalize_options (self : _distutils_install_cmd ) -> None :
148
149
self .install_lib = self .install_platlib
149
150
orig_finalize (self )
150
151
151
- _distutils_install_cmd .finalize_options = new_finalize_options
152
+ _distutils_install_cmd .finalize_options = new_finalize_options # type: ignore[method-assign]
152
153
try :
153
154
yield
154
155
finally :
155
- _distutils_install_cmd .finalize_options = orig_finalize
156
+ _distutils_install_cmd .finalize_options = orig_finalize # type: ignore[method-assign]
156
157
157
158
158
159
@contextmanager
159
- def patched_dist_has_ext_modules ():
160
+ def patched_dist_has_ext_modules () -> Iterator [ None ] :
160
161
"""Make `has_ext_modules` of `Distribution` always return `True`.
161
162
162
163
:yields: None
163
164
"""
164
165
# Without this, build_lib puts stuff under `*.data/platlib/` folder
165
166
orig_func = _DistutilsDistribution .has_ext_modules
166
167
167
- _DistutilsDistribution .has_ext_modules = lambda * args , ** kwargs : True
168
+ _DistutilsDistribution .has_ext_modules = lambda * args , ** kwargs : True # type: ignore[method-assign]
168
169
try :
169
170
yield
170
171
finally :
171
- _DistutilsDistribution .has_ext_modules = orig_func
172
+ _DistutilsDistribution .has_ext_modules = orig_func # type: ignore[method-assign]
172
173
173
174
174
175
@contextmanager
175
- def patched_dist_get_long_description ():
176
+ def patched_dist_get_long_description () -> Iterator [ None ] :
176
177
"""Make `has_ext_modules` of `Distribution` always return `True`.
177
178
178
179
:yields: None
179
180
"""
180
181
# Without this, build_lib puts stuff under `*.data/platlib/` folder
181
182
_orig_func = _DistutilsDistributionMetadata .get_long_description
182
183
183
- def _get_sanitized_long_description (self ):
184
+ def _get_sanitized_long_description (self : _DistutilsDistributionMetadata ) -> str :
185
+ assert self .long_description is not None
184
186
return sanitize_rst_roles (self .long_description )
185
187
186
- _DistutilsDistributionMetadata .get_long_description = (
188
+ _DistutilsDistributionMetadata .get_long_description = ( # type: ignore[method-assign]
187
189
_get_sanitized_long_description
188
190
)
189
191
try :
190
192
yield
191
193
finally :
192
- _DistutilsDistributionMetadata .get_long_description = _orig_func
194
+ _DistutilsDistributionMetadata .get_long_description = _orig_func # type: ignore[method-assign]
193
195
194
196
195
197
def _exclude_dir_path (
@@ -293,7 +295,7 @@ def maybe_prebuild_c_extensions(
293
295
294
296
cythonize_args = _make_cythonize_cli_args_from_config (config )
295
297
with _patched_cython_env (config ['env' ], cython_line_tracing_requested ):
296
- _cythonize_cli_cmd (cythonize_args )
298
+ _cythonize_cli_cmd (cythonize_args ) # type: ignore[no-untyped-call]
297
299
with patched_distutils_cmd_install ():
298
300
with patched_dist_has_ext_modules ():
299
301
yield
0 commit comments