Skip to content

Commit 62b9a8e

Browse files
committed
Apply ruff --select UP safe fixes.
1 parent 842cc23 commit 62b9a8e

File tree

8 files changed

+13
-38
lines changed

8 files changed

+13
-38
lines changed

distutils/command/bdist_dumb.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ def run(self):
104104

105105
# And make an archive relative to the root of the
106106
# pseudo-installation tree.
107-
archive_basename = "{}.{}".format(
108-
self.distribution.get_fullname(), self.plat_name
109-
)
107+
archive_basename = f"{self.distribution.get_fullname()}.{self.plat_name}"
110108

111109
pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
112110
if not self.relative:

distutils/command/bdist_rpm.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,7 @@ def run(self): # noqa: C901
352352
nvr_string = "%{name}-%{version}-%{release}"
353353
src_rpm = nvr_string + ".src.rpm"
354354
non_src_rpm = "%{arch}/" + nvr_string + ".%{arch}.rpm"
355-
q_cmd = r"rpm -q --qf '{} {}\n' --specfile '{}'".format(
356-
src_rpm,
357-
non_src_rpm,
358-
spec_path,
359-
)
355+
q_cmd = rf"rpm -q --qf '{src_rpm} {non_src_rpm}\n' --specfile '{spec_path}'"
360356

361357
out = os.popen(q_cmd)
362358
try:

distutils/command/build_scripts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def _validate_shebang(shebang, encoding):
157157
shebang.encode('utf-8')
158158
except UnicodeEncodeError:
159159
raise ValueError(
160-
"The shebang ({!r}) is not encodable " "to utf-8".format(shebang)
160+
f"The shebang ({shebang!r}) is not encodable " "to utf-8"
161161
)
162162

163163
# If the script is encoded to a custom encoding (use a
@@ -167,6 +167,6 @@ def _validate_shebang(shebang, encoding):
167167
shebang.encode(encoding)
168168
except UnicodeEncodeError:
169169
raise ValueError(
170-
"The shebang ({!r}) is not encodable "
171-
"to the script encoding ({})".format(shebang, encoding)
170+
f"The shebang ({shebang!r}) is not encodable "
171+
f"to the script encoding ({encoding})"
172172
)

distutils/extension.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,7 @@ def __init__(
134134
warnings.warn(msg)
135135

136136
def __repr__(self):
137-
return '<{}.{}({!r}) at {:#x}>'.format(
138-
self.__class__.__module__,
139-
self.__class__.__qualname__,
140-
self.name,
141-
id(self),
142-
)
137+
return f'<{self.__class__.__module__}.{self.__class__.__qualname__}({self.name!r}) at {id(self):#x}>'
143138

144139

145140
def read_setup_file(filename): # noqa: C901

distutils/msvccompiler.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,10 +635,7 @@ def get_msvc_paths(self, path, platform='x86'):
635635

636636
path = path + " dirs"
637637
if self.__version >= 7:
638-
key = r"{}\{:0.1f}\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories".format(
639-
self.__root,
640-
self.__version,
641-
)
638+
key = rf"{self.__root}\{self.__version:0.1f}\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories"
642639
else:
643640
key = (
644641
r"%s\6.0\Build System\Components\Platforms"

distutils/tests/test_unixccompiler.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ def gcv(var):
7373

7474
def do_darwin_test(syscfg_macosx_ver, env_macosx_ver, expected_flag):
7575
env = os.environ
76-
msg = "macOS version = (sysconfig={!r}, env={!r})".format(
77-
syscfg_macosx_ver,
78-
env_macosx_ver,
79-
)
76+
msg = f"macOS version = (sysconfig={syscfg_macosx_ver!r}, env={env_macosx_ver!r})"
8077

8178
# Save
8279
old_gcv = sysconfig.get_config_var

distutils/tests/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,6 @@ def test_dont_write_bytecode(self):
259259

260260
def test_grok_environment_error(self):
261261
# test obsolete function to ensure backward compat (#4931)
262-
exc = IOError("Unable to find batch file")
262+
exc = OSError("Unable to find batch file")
263263
msg = grok_environment_error(exc)
264264
assert msg == "error: Unable to find batch file"

distutils/tests/test_version.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,9 @@ def test_cmp_strict(self):
5252
raise AssertionError(
5353
("cmp(%s, %s) " "shouldn't raise ValueError") % (v1, v2)
5454
)
55-
assert res == wanted, 'cmp({}, {}) should be {}, got {}'.format(
56-
v1, v2, wanted, res
57-
)
55+
assert res == wanted, f'cmp({v1}, {v2}) should be {wanted}, got {res}'
5856
res = StrictVersion(v1)._cmp(v2)
59-
assert res == wanted, 'cmp({}, {}) should be {}, got {}'.format(
60-
v1, v2, wanted, res
61-
)
57+
assert res == wanted, f'cmp({v1}, {v2}) should be {wanted}, got {res}'
6258
res = StrictVersion(v1)._cmp(object())
6359
assert (
6460
res is NotImplemented
@@ -78,13 +74,9 @@ def test_cmp(self):
7874

7975
for v1, v2, wanted in versions:
8076
res = LooseVersion(v1)._cmp(LooseVersion(v2))
81-
assert res == wanted, 'cmp({}, {}) should be {}, got {}'.format(
82-
v1, v2, wanted, res
83-
)
77+
assert res == wanted, f'cmp({v1}, {v2}) should be {wanted}, got {res}'
8478
res = LooseVersion(v1)._cmp(v2)
85-
assert res == wanted, 'cmp({}, {}) should be {}, got {}'.format(
86-
v1, v2, wanted, res
87-
)
79+
assert res == wanted, f'cmp({v1}, {v2}) should be {wanted}, got {res}'
8880
res = LooseVersion(v1)._cmp(object())
8981
assert (
9082
res is NotImplemented

0 commit comments

Comments
 (0)