Skip to content

Commit d776697

Browse files
authored
Merge pull request pypa/distutils#265 from DimitriPapadopoulos/PERF
Enforce ruff/Perflint rules (PERF)
2 parents 164f276 + 2b5815c commit d776697

File tree

6 files changed

+10
-13
lines changed

6 files changed

+10
-13
lines changed

distutils/archive_util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ def make_archive(
266266
raise ValueError(f"unknown archive format '{format}'")
267267

268268
func = format_info[0]
269-
for arg, val in format_info[1]:
270-
kwargs[arg] = val
269+
kwargs.update(format_info[1])
271270

272271
if format != 'zip':
273272
kwargs['owner'] = owner

distutils/command/build_ext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,7 @@ def swig_sources(self, sources, extension):
638638

639639
# Do not override commandline arguments
640640
if not self.swig_opts:
641-
for o in extension.swig_opts:
642-
swig_cmd.append(o)
641+
swig_cmd.extend(extension.swig_opts)
643642

644643
for source in swig_sources:
645644
target = swig_targets[source]

distutils/command/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def create_home_path(self):
680680
if not self.user:
681681
return
682682
home = convert_path(os.path.expanduser("~"))
683-
for _name, path in self.config_vars.items():
683+
for path in self.config_vars.values():
684684
if str(path).startswith(home) and not os.path.isdir(path):
685685
self.debug_print(f"os.makedirs('{path}', 0o700)")
686686
os.makedirs(path, 0o700)

distutils/cygwinccompiler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,7 @@ def link(
172172

173173
# Generate .def file
174174
contents = [f"LIBRARY {os.path.basename(output_filename)}", "EXPORTS"]
175-
for sym in export_symbols:
176-
contents.append(sym)
175+
contents.extend(export_symbols)
177176
self.execute(write_file, (def_file, contents), f"writing {def_file}")
178177

179178
# next add options for def-file

distutils/dist.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,7 @@ def print_commands(self):
741741
import distutils.command
742742

743743
std_commands = distutils.command.__all__
744-
is_std = set()
745-
for cmd in std_commands:
746-
is_std.add(cmd)
744+
is_std = set(std_commands)
747745

748746
extra_commands = [cmd for cmd in self.cmdclass.keys() if cmd not in is_std]
749747

@@ -769,9 +767,7 @@ def get_command_list(self):
769767
import distutils.command
770768

771769
std_commands = distutils.command.__all__
772-
is_std = set()
773-
for cmd in std_commands:
774-
is_std.add(cmd)
770+
is_std = set(std_commands)
775771

776772
extra_commands = [cmd for cmd in self.cmdclass.keys() if cmd not in is_std]
777773

ruff.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ extend-select = [
88
"B",
99
"I",
1010
"ISC",
11+
"PERF",
1112
"RUF010",
1213
"RUF100",
1314
"UP",
1415
]
1516
ignore = [
17+
# local
18+
"PERF203",
19+
1620
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
1721
"W191",
1822
"E111",

0 commit comments

Comments
 (0)