From d5190037c894a12eb7cbaaee1b89800cbb56615a Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Sun, 7 Apr 2024 18:49:24 -0700 Subject: [PATCH 1/2] gnulib-tool.py: Omit some unnecessary list() calls around sorted(). * pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Remove the list() call in the argument to sorted. The sorted() function works on any iterable and always returns a list. * pygnulib/GLImport.py (GLImport.rewrite_old_files) (GLImport.rewrite_new_files): Likewise. * pygnulib/GLModuleSystem.py (GLModuleTable.transitive_closure) (GLModuleTable.transitive_closure_separately): Likewise. * pygnulib/GLTestDir.py (GLTestDir.rewrite_files): Likewise. --- ChangeLog | 12 ++++++++++++ pygnulib/GLEmiter.py | 4 ++-- pygnulib/GLImport.py | 6 ++---- pygnulib/GLModuleSystem.py | 4 ++-- pygnulib/GLTestDir.py | 3 +-- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 535dfc04cc..4fd962ecbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2024-04-07 Collin Funk + + gnulib-tool.py: Omit some unnecessary list() calls around sorted(). + * pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Remove the list() + call in the argument to sorted. The sorted() function works on any + iterable and always returns a list. + * pygnulib/GLImport.py (GLImport.rewrite_old_files) + (GLImport.rewrite_new_files): Likewise. + * pygnulib/GLModuleSystem.py (GLModuleTable.transitive_closure) + (GLModuleTable.transitive_closure_separately): Likewise. + * pygnulib/GLTestDir.py (GLTestDir.rewrite_files): Likewise. + 2024-04-07 Collin Funk gnulib-tool.py: Don't remove duplicate avoided modules. diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index cb813b3baa..45462c5fe3 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -879,8 +879,8 @@ AC_DEFUN([%V1%_LIBSOURCES], [ capture_output=True) if result.returncode == 0: # sort -u - emit += lines_to_multiline(sorted(list(set(x.strip() - for x in result.stdout.decode(encoding='utf-8').splitlines())))) + emit += lines_to_multiline(sorted({ x.strip() + for x in result.stdout.decode(encoding='utf-8').splitlines() })) else: emit += '== gnulib-tool GNU Make output failed as follows ==\n' emit += ['# stderr: ' + x + '\n' for x in diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 2776f2c964..08e83c5c9a 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -336,8 +336,7 @@ class GLImport: else: # file is not a special file path = file result += [os.path.normpath(path)] - result = sorted(set(result)) - return list(result) + return sorted(set(result)) def rewrite_new_files(self, files: list[str]) -> list[str]: '''Replace auxdir, docbase, sourcebase, m4base and testsbase from @@ -373,8 +372,7 @@ class GLImport: else: # file is not a special file path = file result += [os.path.normpath(path)] - result = sorted(set(result)) - return list(result) + return sorted(set(result)) def actioncmd(self) -> str: '''Return command-line invocation comment.''' diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index f8ff71383a..3997668538 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -935,7 +935,7 @@ class GLModuleTable: inc_all_tests = self.inc_all_indirect_tests modules = sorted(set(outmodules)) self.modules = modules - return list(modules) + return modules def transitive_closure_separately(self, basemodules: list[GLModule], finalmodules: list[GLModule]) -> tuple[list[GLModule], list[GLModule]]: @@ -978,7 +978,7 @@ class GLModuleTable: # + [ m # for m in main_modules # if m.getApplicability() != 'main' ] - tests_modules = sorted(list(set(tests_modules))) + tests_modules = sorted(set(tests_modules)) # If testsrelated_modules consists only of modules with applicability 'all', # set it to empty (because such modules are only helper modules for other modules). have_nontrivial_testsrelated_modules = False diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py index 829e26fb3f..8defe52fc6 100644 --- a/pygnulib/GLTestDir.py +++ b/pygnulib/GLTestDir.py @@ -165,8 +165,7 @@ class GLTestDir: else: # file is not a special file path = file result += [os.path.normpath(path)] - result = sorted(set(result)) - return list(result) + return sorted(set(result)) def execute(self) -> None: '''Create a scratch package with the given modules.''' -- 2.44.0