Skip to content

Commit a9f832b

Browse files
authored
Merge pull request #314 from Avasam/Ruff-0.8.0
Run Ruff 0.8.0 (automated fixes only)
2 parents b24919b + 1bae350 commit a9f832b

14 files changed

+58
-55
lines changed

distutils/command/build_clib.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ def check_library_list(self, libraries):
138138

139139
if '/' in name or (os.sep != '/' and os.sep in name):
140140
raise DistutilsSetupError(
141-
f"bad library name '{lib[0]}': "
142-
"may not contain directory separators"
141+
f"bad library name '{lib[0]}': may not contain directory separators"
143142
)
144143

145144
if not isinstance(build_info, dict):

distutils/command/build_ext.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,7 @@ def check_extensions_list(self, extensions): # noqa: C901
443443
for macro in macros:
444444
if not (isinstance(macro, tuple) and len(macro) in (1, 2)):
445445
raise DistutilsSetupError(
446-
"'macros' element of build info dict "
447-
"must be 1- or 2-tuple"
446+
"'macros' element of build info dict must be 1- or 2-tuple"
448447
)
449448
if len(macro) == 1:
450449
ext.undef_macros.append(macro[0])
@@ -672,8 +671,7 @@ def find_swig(self):
672671
return "swig.exe"
673672
else:
674673
raise DistutilsPlatformError(
675-
"I don't know how to find (much less run) SWIG "
676-
f"on platform '{os.name}'"
674+
f"I don't know how to find (much less run) SWIG on platform '{os.name}'"
677675
)
678676

679677
# -- Name generators -----------------------------------------------

distutils/command/check.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ class check(Command):
4646
(
4747
'restructuredtext',
4848
'r',
49-
(
50-
'Checks if long string meta-data syntax '
51-
'are reStructuredText-compliant'
52-
),
49+
'Checks if long string meta-data syntax are reStructuredText-compliant',
5350
),
5451
('strict', 's', 'Will exit with an error if a check fails'),
5552
]

distutils/command/install_data.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import functools
1111
import os
12-
from typing import Iterable
12+
from collections.abc import Iterable
1313

1414
from ..core import Command
1515
from ..util import change_root, convert_path
@@ -22,8 +22,7 @@ class install_data(Command):
2222
(
2323
'install-dir=',
2424
'd',
25-
"base directory for installing data files "
26-
"[default: installation base dir]",
25+
"base directory for installing data files [default: installation base dir]",
2726
),
2827
('root=', None, "install everything relative to this alternate root directory"),
2928
('force', 'f', "force installation (overwrite existing files)"),

distutils/fancy_getopt.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
import re
1313
import string
1414
import sys
15-
from typing import Any, Sequence
15+
from collections.abc import Sequence
16+
from typing import Any
1617

1718
from .errors import DistutilsArgError, DistutilsGetoptError
1819

@@ -167,8 +168,7 @@ def _grok_option_table(self): # noqa: C901
167168

168169
if not ((short is None) or (isinstance(short, str) and len(short) == 1)):
169170
raise DistutilsGetoptError(
170-
f"invalid short option '{short}': "
171-
"must a single character or None"
171+
f"invalid short option '{short}': must a single character or None"
172172
)
173173

174174
self.repeat[long] = repeat

distutils/filelist.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ def process_template_line(self, line): # noqa: C901
127127
for pattern in patterns:
128128
if not self.exclude_pattern(pattern, anchor=True):
129129
log.warning(
130-
(
131-
"warning: no previously-included files "
132-
"found matching '%s'"
133-
),
130+
"warning: no previously-included files found matching '%s'",
134131
pattern,
135132
)
136133

distutils/spawn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import subprocess
1313
import sys
1414
import warnings
15-
from typing import Mapping
15+
from collections.abc import Mapping
1616

1717
from ._log import log
1818
from .debug import DEBUG

distutils/tests/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
import shutil
11-
from typing import Sequence
11+
from collections.abc import Sequence
1212

1313

1414
def missing_compiler_executable(cmd_names: Sequence[str] = []): # pragma: no cover

distutils/tests/test_file_util.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,19 @@ def test_move_file_verbosity(self, caplog):
4444

4545
def test_move_file_exception_unpacking_rename(self):
4646
# see issue 22182
47-
with mock.patch("os.rename", side_effect=OSError("wrong", 1)), pytest.raises(
48-
DistutilsFileError
47+
with (
48+
mock.patch("os.rename", side_effect=OSError("wrong", 1)),
49+
pytest.raises(DistutilsFileError),
4950
):
5051
jaraco.path.build({self.source: 'spam eggs'})
5152
move_file(self.source, self.target, verbose=False)
5253

5354
def test_move_file_exception_unpacking_unlink(self):
5455
# see issue 22182
55-
with mock.patch(
56-
"os.rename", side_effect=OSError(errno.EXDEV, "wrong")
57-
), mock.patch("os.unlink", side_effect=OSError("wrong", 1)), pytest.raises(
58-
DistutilsFileError
56+
with (
57+
mock.patch("os.rename", side_effect=OSError(errno.EXDEV, "wrong")),
58+
mock.patch("os.unlink", side_effect=OSError("wrong", 1)),
59+
pytest.raises(DistutilsFileError),
5960
):
6061
jaraco.path.build({self.source: 'spam eggs'})
6162
move_file(self.source, self.target, verbose=False)

distutils/tests/test_spawn.py

+22-12
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ def test_find_executable(self, tmp_path):
7373
# PATH='': no match, except in the current directory
7474
with os_helper.EnvironmentVarGuard() as env:
7575
env['PATH'] = ''
76-
with mock.patch(
77-
'distutils.spawn.os.confstr', return_value=tmp_dir, create=True
78-
), mock.patch('distutils.spawn.os.defpath', tmp_dir):
76+
with (
77+
mock.patch(
78+
'distutils.spawn.os.confstr', return_value=tmp_dir, create=True
79+
),
80+
mock.patch('distutils.spawn.os.defpath', tmp_dir),
81+
):
7982
rv = find_executable(program)
8083
assert rv is None
8184

@@ -87,9 +90,10 @@ def test_find_executable(self, tmp_path):
8790
# PATH=':': explicitly looks in the current directory
8891
with os_helper.EnvironmentVarGuard() as env:
8992
env['PATH'] = os.pathsep
90-
with mock.patch(
91-
'distutils.spawn.os.confstr', return_value='', create=True
92-
), mock.patch('distutils.spawn.os.defpath', ''):
93+
with (
94+
mock.patch('distutils.spawn.os.confstr', return_value='', create=True),
95+
mock.patch('distutils.spawn.os.defpath', ''),
96+
):
9397
rv = find_executable(program)
9498
assert rv is None
9599

@@ -103,16 +107,22 @@ def test_find_executable(self, tmp_path):
103107
env.pop('PATH', None)
104108

105109
# without confstr
106-
with mock.patch(
107-
'distutils.spawn.os.confstr', side_effect=ValueError, create=True
108-
), mock.patch('distutils.spawn.os.defpath', tmp_dir):
110+
with (
111+
mock.patch(
112+
'distutils.spawn.os.confstr', side_effect=ValueError, create=True
113+
),
114+
mock.patch('distutils.spawn.os.defpath', tmp_dir),
115+
):
109116
rv = find_executable(program)
110117
assert rv == filename
111118

112119
# with confstr
113-
with mock.patch(
114-
'distutils.spawn.os.confstr', return_value=tmp_dir, create=True
115-
), mock.patch('distutils.spawn.os.defpath', ''):
120+
with (
121+
mock.patch(
122+
'distutils.spawn.os.confstr', return_value=tmp_dir, create=True
123+
),
124+
mock.patch('distutils.spawn.os.defpath', ''),
125+
):
116126
rv = find_executable(program)
117127
assert rv == filename
118128

distutils/tests/test_unixccompiler.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,12 @@ def gcvs(*args, _orig=sysconfig.get_config_vars):
272272

273273
sysconfig.get_config_var = gcv
274274
sysconfig.get_config_vars = gcvs
275-
with mock.patch.object(
276-
self.cc, 'spawn', return_value=None
277-
) as mock_spawn, mock.patch.object(
278-
self.cc, '_need_link', return_value=True
279-
), mock.patch.object(
280-
self.cc, 'mkpath', return_value=None
281-
), EnvironmentVarGuard() as env:
275+
with (
276+
mock.patch.object(self.cc, 'spawn', return_value=None) as mock_spawn,
277+
mock.patch.object(self.cc, '_need_link', return_value=True),
278+
mock.patch.object(self.cc, 'mkpath', return_value=None),
279+
EnvironmentVarGuard() as env,
280+
):
282281
env['CC'] = 'ccache my_cc'
283282
env['CXX'] = 'my_cxx'
284283
del env['LDSHARED']

distutils/tests/test_version.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def test_cmp_strict(self):
5353
res = StrictVersion(v1)._cmp(v2)
5454
assert res == wanted, f'cmp({v1}, {v2}) should be {wanted}, got {res}'
5555
res = StrictVersion(v1)._cmp(object())
56-
assert (
57-
res is NotImplemented
58-
), f'cmp({v1}, {v2}) should be NotImplemented, got {res}'
56+
assert res is NotImplemented, (
57+
f'cmp({v1}, {v2}) should be NotImplemented, got {res}'
58+
)
5959

6060
def test_cmp(self):
6161
versions = (
@@ -75,6 +75,6 @@ def test_cmp(self):
7575
res = LooseVersion(v1)._cmp(v2)
7676
assert res == wanted, f'cmp({v1}, {v2}) should be {wanted}, got {res}'
7777
res = LooseVersion(v1)._cmp(object())
78-
assert (
79-
res is NotImplemented
80-
), f'cmp({v1}, {v2}) should be NotImplemented, got {res}'
78+
assert res is NotImplemented, (
79+
f'cmp({v1}, {v2}) should be NotImplemented, got {res}'
80+
)

distutils/version.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def __init__(self, vstring=None):
5353
if vstring:
5454
self.parse(vstring)
5555
warnings.warn(
56-
"distutils Version classes are deprecated. "
57-
"Use packaging.version instead.",
56+
"distutils Version classes are deprecated. Use packaging.version instead.",
5857
DeprecationWarning,
5958
stacklevel=2,
6059
)

ruff.toml

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ extend-select = [
1919
"YTT",
2020
]
2121
ignore = [
22+
# TODO: Fix these new violations in Ruff 0.8.0
23+
"UP031",
24+
"UP036",
25+
2226
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
2327
"W191",
2428
"E111",

0 commit comments

Comments
 (0)