From ea55396cc4df42720b8557a13f4fd80283fc32e8 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 13 Apr 2024 11:46:42 +0200 Subject: [PATCH 1/5] Apply ruff/refurb rule (FURB105) FURB105 Unnecessary empty string passed to `print` --- distutils/dist.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/distutils/dist.py b/distutils/dist.py index f29a34fa..668ce7eb 100644 --- a/distutils/dist.py +++ b/distutils/dist.py @@ -647,7 +647,7 @@ def _show_help( options = self.global_options parser.set_option_table(options) parser.print_help(self.common_usage + "\nGlobal options:") - print('') + print() if display_options: parser.set_option_table(self.display_options) @@ -655,7 +655,7 @@ def _show_help( "Information display options (just display " + "information, ignore any commands)" ) - print('') + print() for command in self.commands: if isinstance(command, type) and issubclass(command, Command): @@ -669,7 +669,7 @@ def _show_help( else: parser.set_option_table(klass.user_options) parser.print_help("Options for '%s' command:" % klass.__name__) - print('') + print() print(gen_usage(self.script_name)) @@ -686,7 +686,7 @@ def handle_display_options(self, option_order): # we ignore "foo bar"). if self.help_commands: self.print_commands() - print('') + print() print(gen_usage(self.script_name)) return 1 From 0d6794fdc2987703982f7d0e89123fffc9bbda79 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 13 Apr 2024 11:48:29 +0200 Subject: [PATCH 2/5] Apply ruff/refurb rule (FURB129) FURB129 Instead of calling `readlines()`, iterate over file object directly --- distutils/tests/test_msvc9compiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distutils/tests/test_msvc9compiler.py b/distutils/tests/test_msvc9compiler.py index 58e24f01..6f6aabee 100644 --- a/distutils/tests/test_msvc9compiler.py +++ b/distutils/tests/test_msvc9compiler.py @@ -161,7 +161,7 @@ def test_remove_visual_c_ref(self): f = open(manifest) try: # removing trailing spaces - content = '\n'.join([line.rstrip() for line in f.readlines()]) + content = '\n'.join([line.rstrip() for line in f]) finally: f.close() From bfadc24bc9c120a6feae918cea5a9d80453cc8c6 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 13 Apr 2024 11:50:52 +0200 Subject: [PATCH 3/5] Apply ruff/refurb rule (FURB142) FURB142 Use of `set.add()` in a for loop --- distutils/dir_util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/distutils/dir_util.py b/distutils/dir_util.py index 2021bed8..8a3aca65 100644 --- a/distutils/dir_util.py +++ b/distutils/dir_util.py @@ -95,8 +95,7 @@ def create_tree(base_dir, files, mode=0o777, verbose=1, dry_run=0): """ # First get the list of directories to create need_dir = set() - for file in files: - need_dir.add(os.path.join(base_dir, os.path.dirname(file))) + need_dir.update(os.path.join(base_dir, os.path.dirname(file)) for file in files) # Now create them for dir in sorted(need_dir): From ec303d5963920fb8e6fce5919615fcffb0c93fe5 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 13 Apr 2024 11:53:21 +0200 Subject: [PATCH 4/5] Apply ruff/refurb rule (FURB140) FURB140 Use `itertools.starmap` instead of the generator --- distutils/unixccompiler.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/distutils/unixccompiler.py b/distutils/unixccompiler.py index a1fe2b57..caf4cd33 100644 --- a/distutils/unixccompiler.py +++ b/distutils/unixccompiler.py @@ -389,10 +389,7 @@ def find_library_file(self, dirs, lib, debug=0): roots = map(self._library_root, dirs) - searched = ( - os.path.join(root, lib_name) - for root, lib_name in itertools.product(roots, lib_names) - ) + searched = itertools.starmap(os.path.join, itertools.product(roots, lib_names)) found = filter(os.path.exists, searched) From 8b9f35e00549615b43793efd3c90f75739b55abf Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 13 Apr 2024 09:31:27 -0400 Subject: [PATCH 5/5] Construct the set in one expression. --- distutils/dir_util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/distutils/dir_util.py b/distutils/dir_util.py index 8a3aca65..370c6ffd 100644 --- a/distutils/dir_util.py +++ b/distutils/dir_util.py @@ -94,8 +94,7 @@ def create_tree(base_dir, files, mode=0o777, verbose=1, dry_run=0): 'dry_run' flags are as for 'mkpath()'. """ # First get the list of directories to create - need_dir = set() - need_dir.update(os.path.join(base_dir, os.path.dirname(file)) for file in files) + need_dir = set(os.path.join(base_dir, os.path.dirname(file)) for file in files) # Now create them for dir in sorted(need_dir):