Skip to content

Commit ac41e61

Browse files
committed
mypy: Fix all union-attr
1 parent 248ee13 commit ac41e61

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

distutils/command/build_py.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def build_modules(self) -> None:
360360
self.build_module(module, module_file, package)
361361

362362
def build_packages(self) -> None:
363-
for package in self.packages:
363+
for package in self.packages or ():
364364
# Get list of (package, module, module_file) tuples based on
365365
# scanning the package directory. 'package' is only included
366366
# in the tuple so that 'find_modules()' and

distutils/dist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ def _read_list(name):
11981198
self.description = _read_field('summary')
11991199

12001200
if 'keywords' in msg:
1201-
self.keywords = _read_field('keywords').split(',')
1201+
self.keywords = _read_field('keywords').split(',') # type:ignore[union-attr] # Manually checked
12021202

12031203
self.platforms = _read_list('platform')
12041204
self.classifiers = _read_list('classifier')

distutils/filelist.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ def include_pattern(
261261
# delayed loading of allfiles list
262262
if self.allfiles is None:
263263
self.findall()
264+
assert self.allfiles is not None
264265

265266
for name in self.allfiles:
266267
if pattern_re.search(name):

distutils/sysconfig.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,16 @@ def customize_compiler(compiler: CCompiler) -> None:
324324
'AR',
325325
'ARFLAGS',
326326
)
327+
assert isinstance(cc, str)
328+
assert isinstance(cxx, str)
329+
assert isinstance(cflags, str)
330+
assert isinstance(ccshared, str)
331+
assert isinstance(ldshared, str)
332+
assert isinstance(ldcxxshared, str)
333+
assert isinstance(shlib_suffix, str)
334+
assert isinstance(ar_flags, str)
335+
ar = os.environ.get('AR', ar)
336+
assert isinstance(ar, str)
327337

328338
cxxflags = cflags
329339

@@ -354,8 +364,6 @@ def customize_compiler(compiler: CCompiler) -> None:
354364
ldshared = _add_flags(ldshared, 'CPP')
355365
ldcxxshared = _add_flags(ldcxxshared, 'CPP')
356366

357-
ar = os.environ.get('AR', ar)
358-
359367
archiver = ar + ' ' + os.environ.get('ARFLAGS', ar_flags)
360368
cc_cmd = cc + ' ' + cflags
361369
cxx_cmd = cxx + ' ' + cxxflags

distutils/util.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,9 @@ def grok_environment_error(exc: object, prefix: str = "error: ") -> str:
232232

233233

234234
# Needed by 'split_quoted()'
235-
_wordchars_re = _squote_re = _dquote_re = None
236-
237-
238-
def _init_regex():
239-
global _wordchars_re, _squote_re, _dquote_re
240-
_wordchars_re = re.compile(rf'[^\\\'\"{string.whitespace} ]*')
241-
_squote_re = re.compile(r"'(?:[^'\\]|\\.)*'")
242-
_dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"')
235+
_wordchars_re = re.compile(rf'[^\\\'\"{string.whitespace} ]*')
236+
_squote_re = re.compile(r"'(?:[^'\\]|\\.)*'")
237+
_dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"')
243238

244239

245240
def split_quoted(s: str) -> list[str]:
@@ -256,15 +251,14 @@ def split_quoted(s: str) -> list[str]:
256251
# This is a nice algorithm for splitting up a single string, since it
257252
# doesn't require character-by-character examination. It was a little
258253
# bit of a brain-bender to get it working right, though...
259-
if _wordchars_re is None:
260-
_init_regex()
261254

262255
s = s.strip()
263256
words = []
264257
pos = 0
265258

266259
while s:
267260
m = _wordchars_re.match(s, pos)
261+
assert m is not None
268262
end = m.end()
269263
if end == len(s):
270264
words.append(s[:end])
@@ -305,9 +299,6 @@ def split_quoted(s: str) -> list[str]:
305299
return words
306300

307301

308-
# split_quoted ()
309-
310-
311302
def execute(
312303
func: Callable[[Unpack[_Ts]], object],
313304
args: tuple[Unpack[_Ts]],

mypy.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ disable_error_code =
2929
call-overload,
3030
index,
3131
func-returns-value,
32-
union-attr,
3332
str-bytes-safe,
3433
misc,
3534

0 commit comments

Comments
 (0)