Skip to content

Commit f8ab1e8

Browse files
committed
Apply ruff --select UP unsafe fixes.
1 parent 62b9a8e commit f8ab1e8

13 files changed

+33
-50
lines changed

distutils/ccompiler.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ class (via the 'executables' class attribute), but most will have:
169169
for key in kwargs:
170170
if key not in self.executables:
171171
raise ValueError(
172-
"unknown executable '%s' for class %s"
173-
% (key, self.__class__.__name__)
172+
f"unknown executable '{key}' for class {self.__class__.__name__}"
174173
)
175174
self.set_executable(key, kwargs[key])
176175

@@ -1162,8 +1161,8 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
11621161
)
11631162
except KeyError:
11641163
raise DistutilsModuleError(
1165-
"can't compile C/C++ code: unable to find class '%s' "
1166-
"in module '%s'" % (class_name, module_name)
1164+
f"can't compile C/C++ code: unable to find class '{class_name}' "
1165+
f"in module '{module_name}'"
11671166
)
11681167

11691168
# XXX The None is necessary to preserve backwards compatibility
@@ -1210,7 +1209,7 @@ def gen_preprocess_options(macros, include_dirs):
12101209
# XXX *don't* need to be clever about quoting the
12111210
# macro value here, because we're going to avoid the
12121211
# shell at all costs when we spawn the command!
1213-
pp_opts.append("-D%s=%s" % macro)
1212+
pp_opts.append("-D{}={}".format(*macro))
12141213

12151214
for dir in include_dirs:
12161215
pp_opts.append("-I%s" % dir)

distutils/command/bdist_dumb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def run(self):
115115
):
116116
raise DistutilsPlatformError(
117117
"can't make a dumb built distribution where "
118-
"base and platbase are different (%s, %s)"
119-
% (repr(install.install_base), repr(install.install_platbase))
118+
f"base and platbase are different ({repr(install.install_base)}, {repr(install.install_platbase)})"
120119
)
121120
else:
122121
archive_root = os.path.join(

distutils/command/bdist_rpm.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ def finalize_package_data(self):
232232
self.ensure_string('group', "Development/Libraries")
233233
self.ensure_string(
234234
'vendor',
235-
"%s <%s>"
236-
% (self.distribution.get_contact(), self.distribution.get_contact_email()),
235+
f"{self.distribution.get_contact()} <{self.distribution.get_contact_email()}>",
237236
)
238237
self.ensure_string('packager')
239238
self.ensure_string_list('doc_files')

distutils/command/build_scripts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ def _copy_script(self, script, outfiles, updated_files): # noqa: C901
109109
else:
110110
executable = os.path.join(
111111
sysconfig.get_config_var("BINDIR"),
112-
"python%s%s"
113-
% (
112+
"python{}{}".format(
114113
sysconfig.get_config_var("VERSION"),
115114
sysconfig.get_config_var("EXE"),
116115
),

distutils/command/install_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def run(self):
5151
if self.warn_dir:
5252
self.warn(
5353
"setup script did not provide a directory for "
54-
"'%s' -- installing right in '%s'" % (f, self.install_dir)
54+
f"'{f}' -- installing right in '{self.install_dir}'"
5555
)
5656
(out, _) = self.copy_file(f, self.install_dir)
5757
self.outfiles.append(out)

distutils/dist.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,8 @@ def _parse_command_opts(self, parser, args): # noqa: C901
592592
func()
593593
else:
594594
raise DistutilsClassError(
595-
"invalid help function %r for help option '%s': "
595+
f"invalid help function {func!r} for help option '{help_option}': "
596596
"must be a callable object (function, etc.)"
597-
% (func, help_option)
598597
)
599598

600599
if help_option_found:
@@ -834,8 +833,7 @@ def get_command_class(self, command):
834833
klass = getattr(module, klass_name)
835834
except AttributeError:
836835
raise DistutilsModuleError(
837-
"invalid command '%s' (no class '%s' in module '%s')"
838-
% (command, klass_name, module_name)
836+
f"invalid command '{command}' (no class '{klass_name}' in module '{module_name}')"
839837
)
840838

841839
self.cmdclass[command] = klass
@@ -909,8 +907,7 @@ def _set_command_options(self, command_obj, option_dict=None): # noqa: C901
909907
setattr(command_obj, option, value)
910908
else:
911909
raise DistutilsOptionError(
912-
"error in %s: command '%s' has no such option '%s'"
913-
% (source, command_name, option)
910+
f"error in {source}: command '{command_name}' has no such option '{option}'"
914911
)
915912
except ValueError as msg:
916913
raise DistutilsOptionError(msg)

distutils/fancy_getopt.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,11 @@ def _check_alias_dict(self, aliases, what):
116116
for alias, opt in aliases.items():
117117
if alias not in self.option_index:
118118
raise DistutilsGetoptError(
119-
("invalid %s '%s': " "option '%s' not defined")
120-
% (what, alias, alias)
119+
f"invalid {what} '{alias}': " f"option '{alias}' not defined"
121120
)
122121
if opt not in self.option_index:
123122
raise DistutilsGetoptError(
124-
("invalid %s '%s': " "aliased option '%s' not defined")
125-
% (what, alias, opt)
123+
f"invalid {what} '{alias}': " f"aliased option '{opt}' not defined"
126124
)
127125

128126
def set_aliases(self, alias):
@@ -187,8 +185,8 @@ def _grok_option_table(self): # noqa: C901
187185
if alias_to is not None:
188186
if self.takes_arg[alias_to]:
189187
raise DistutilsGetoptError(
190-
"invalid negative alias '%s': "
191-
"aliased option '%s' takes a value" % (long, alias_to)
188+
f"invalid negative alias '{long}': "
189+
f"aliased option '{alias_to}' takes a value"
192190
)
193191

194192
self.long_opts[-1] = long # XXX redundant?!
@@ -200,9 +198,9 @@ def _grok_option_table(self): # noqa: C901
200198
if alias_to is not None:
201199
if self.takes_arg[long] != self.takes_arg[alias_to]:
202200
raise DistutilsGetoptError(
203-
"invalid alias '%s': inconsistent with "
204-
"aliased option '%s' (one of them takes a value, "
205-
"the other doesn't" % (long, alias_to)
201+
f"invalid alias '{long}': inconsistent with "
202+
f"aliased option '{alias_to}' (one of them takes a value, "
203+
"the other doesn't"
206204
)
207205

208206
# Now enforce some bondage on the long option name, so we can

distutils/file_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ def move_file(src, dst, verbose=1, dry_run=0): # noqa: C901
220220
except OSError:
221221
pass
222222
raise DistutilsFileError(
223-
"couldn't move '%s' to '%s' by copy/delete: "
224-
"delete '%s' failed: %s" % (src, dst, src, msg)
223+
f"couldn't move '{src}' to '{dst}' by copy/delete: "
224+
f"delete '{src}' failed: {msg}"
225225
)
226226
return dst
227227

distutils/msvccompiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,8 @@ def get_msvc_paths(self, path, platform='x86'):
638638
key = rf"{self.__root}\{self.__version:0.1f}\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories"
639639
else:
640640
key = (
641-
r"%s\6.0\Build System\Components\Platforms"
642-
r"\Win32 (%s)\Directories" % (self.__root, platform)
641+
rf"{self.__root}\6.0\Build System\Components\Platforms"
642+
rf"\Win32 ({platform})\Directories"
643643
)
644644

645645
for base in HKEYS:

distutils/tests/test_bdist_dumb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_simple_built(self):
7373
fp.close()
7474

7575
contents = sorted(filter(None, map(os.path.basename, contents)))
76-
wanted = ['foo-0.1-py%s.%s.egg-info' % sys.version_info[:2], 'foo.py']
76+
wanted = ['foo-0.1-py{}.{}.egg-info'.format(*sys.version_info[:2]), 'foo.py']
7777
if not sys.dont_write_bytecode:
7878
wanted.append('foo.%s.pyc' % sys.implementation.cache_tag)
7979
assert contents == sorted(wanted)

0 commit comments

Comments
 (0)