[PATCH 1/3] scripts: Fix minor lint warnings in build-many-glibcs.py
Carlos O'Donell
carlos@redhat.com
Wed Nov 12 14:12:28 GMT 2025
On 11/12/25 6:45 AM, Yury Khrustalev wrote:
> ---
> scripts/build-many-glibcs.py | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
LGTM. It's an improvement, though ruff detects more python lint issues.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
> index 732cfe2585..67fe279d6c 100755
> --- a/scripts/build-many-glibcs.py
> +++ b/scripts/build-many-glibcs.py
> @@ -56,9 +56,11 @@ import sys
> import time
> import urllib.request
>
> +REQUIRED_TOOLS = {}
> +
> # This is a list of system utilities that are expected to be available
> # to this script, and, if a non-zero version is included, the minimum
> -# version required to work with this sccript.
> +# version required to work with this script.
> def get_list_of_required_tools():
> global REQUIRED_TOOLS
> REQUIRED_TOOLS = {
> @@ -109,6 +111,9 @@ class Context(object):
> def __init__(self, topdir, parallelism, keep, replace_sources, strip,
> full_gcc, action, exclude, shallow=False):
> """Initialize the context."""
> + self.bot_config = None
> + self.build_state = None
> + self.versions = None
> self.topdir = topdir
> self.parallelism = parallelism
> self.keep = keep
> @@ -1918,7 +1923,7 @@ def get_version_common(progname,line,word,arg1):
> v = re.match(r'[0-9]+(.[0-9]+)*', v).group()
> return [int(x) for x in v.split('.')]
> except:
Fixes 7/7 ruff detected unnecessary semicolons.
> - return 'missing';
> + return 'missing'
>
> def get_version_common_stderr(progname,line,word,arg1):
> try:
> @@ -1931,16 +1936,16 @@ def get_version_common_stderr(progname,line,word,arg1):
> v = re.match(r'[0-9]+(.[0-9]+)*', v).group()
> return [int(x) for x in v.split('.')]
> except:
> - return 'missing';
> + return 'missing'
>
> def get_version(progname):
> - return get_version_common(progname, 0, -1, '--version');
> + return get_version_common(progname, 0, -1, '--version')
>
> def get_version_awk(progname):
> - return get_version_common(progname, 0, 2, '--version');
> + return get_version_common(progname, 0, 2, '--version')
>
> def get_version_bzip2(progname):
> - return get_version_common_stderr(progname, 0, 6, '-h');
> + return get_version_common_stderr(progname, 0, 6, '-h')
>
> def check_version(ver, req):
> for v, r in zip(ver, req):
> @@ -1978,11 +1983,11 @@ def check_for_required_tools():
> version_str(v[1])))
>
> if count_old_tools > 0 or count_missing_tools > 0:
> - exit (1);
> + exit (1)
>
> def main(argv):
> """The main entry point."""
> - check_for_required_tools();
> + check_for_required_tools()
> parser = get_parser()
> opts = parser.parse_args(argv)
> topdir = os.path.abspath(opts.topdir)
$ ruff --version
ruff 0.14.3
$ ruff check scripts/build-many-glibcs.py
E722 Do not use bare `except`
--> scripts/build-many-glibcs.py:81:1
|
79 | try:
80 | subprocess.run
81 | except:
| ^^^^^^
82 | class _CompletedProcess:
83 | def __init__(self, args, returncode, stdout=None, stderr=None):
|
E741 Ambiguous variable name: `l`
--> scripts/build-many-glibcs.py:170:13
|
168 | lines = f.readlines()
169 | starttext = '#define VERSION "'
170 | for l in lines:
| ^
171 | if l.startswith(starttext):
172 | l = l[len(starttext):]
|
E741 Ambiguous variable name: `l`
--> scripts/build-many-glibcs.py:172:17
|
170 | for l in lines:
171 | if l.startswith(starttext):
172 | l = l[len(starttext):]
| ^
173 | l = l.rstrip('"\n')
174 | m = re.fullmatch(r'([0-9]+)\.([0-9]+)[.0-9]*', l)
|
E741 Ambiguous variable name: `l`
--> scripts/build-many-glibcs.py:173:17
|
171 | if l.startswith(starttext):
172 | l = l[len(starttext):]
173 | l = l.rstrip('"\n')
| ^
174 | m = re.fullmatch(r'([0-9]+)\.([0-9]+)[.0-9]*', l)
175 | return '%s.%s' % m.group(1, 2)
|
E741 Ambiguous variable name: `l`
--> scripts/build-many-glibcs.py:1757:31
|
1756 | @staticmethod
1757 | def shell_make_quote_list(l, translate_make):
| ^
1758 | """Given a list of strings not containing newlines, quote them for use
1759 | by the shell and make, returning a single string. If translate_make
|
E741 Ambiguous variable name: `l`
--> scripts/build-many-glibcs.py:1761:9
|
1759 | by the shell and make, returning a single string. If translate_make
1760 | is true and the first string is 'make', change it to $(MAKE)."""
1761 | l = [Command.shell_make_quote_string(s) for s in l]
| ^
1762 | if translate_make and l[0] == 'make':
1763 | l[0] = '$(MAKE)'
|
E722 Do not use bare `except`
--> scripts/build-many-glibcs.py:1920:5
|
1918 | v = re.match(r'[0-9]+(.[0-9]+)*', v).group()
1919 | return [int(x) for x in v.split('.')]
1920 | except:
| ^^^^^^
1921 | return 'missing';
|
E703 [*] Statement ends with an unnecessary semicolon
--> scripts/build-many-glibcs.py:1921:25
|
1919 | return [int(x) for x in v.split('.')]
1920 | except:
1921 | return 'missing';
| ^
1922 |
1923 | def get_version_common_stderr(progname,line,word,arg1):
|
help: Remove unnecessary semicolon
E722 Do not use bare `except`
--> scripts/build-many-glibcs.py:1933:5
|
1931 | v = re.match(r'[0-9]+(.[0-9]+)*', v).group()
1932 | return [int(x) for x in v.split('.')]
1933 | except:
| ^^^^^^
1934 | return 'missing';
|
E703 [*] Statement ends with an unnecessary semicolon
--> scripts/build-many-glibcs.py:1934:25
|
1932 | return [int(x) for x in v.split('.')]
1933 | except:
1934 | return 'missing';
| ^
1935 |
1936 | def get_version(progname):
|
help: Remove unnecessary semicolon
E703 [*] Statement ends with an unnecessary semicolon
--> scripts/build-many-glibcs.py:1937:60
|
1936 | def get_version(progname):
1937 | return get_version_common(progname, 0, -1, '--version');
| ^
1938 |
1939 | def get_version_awk(progname):
|
help: Remove unnecessary semicolon
E703 [*] Statement ends with an unnecessary semicolon
--> scripts/build-many-glibcs.py:1940:59
|
1939 | def get_version_awk(progname):
1940 | return get_version_common(progname, 0, 2, '--version');
| ^
1941 |
1942 | def get_version_bzip2(progname):
|
help: Remove unnecessary semicolon
E703 [*] Statement ends with an unnecessary semicolon
--> scripts/build-many-glibcs.py:1943:59
|
1942 | def get_version_bzip2(progname):
1943 | return get_version_common_stderr(progname, 0, 6, '-h');
| ^
1944 |
1945 | def check_version(ver, req):
|
help: Remove unnecessary semicolon
E703 [*] Statement ends with an unnecessary semicolon
--> scripts/build-many-glibcs.py:1981:17
|
1980 | if count_old_tools > 0 or count_missing_tools > 0:
1981 | exit (1);
| ^
1982 |
1983 | def main(argv):
|
help: Remove unnecessary semicolon
E703 [*] Statement ends with an unnecessary semicolon
--> scripts/build-many-glibcs.py:1985:31
|
1983 | def main(argv):
1984 | """The main entry point."""
1985 | check_for_required_tools();
| ^
1986 | parser = get_parser()
1987 | opts = parser.parse_args(argv)
|
help: Remove unnecessary semicolon
Found 15 errors.
[*] 7 fixable with the `--fix` option.
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list