From 5c06e43ae3b286f8d5f35395859ccada159fe0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sat, 8 Feb 2025 15:05:43 +0000 Subject: [PATCH] style: Fix sorted-min-max (FURB192) in build.py Prefer `min` over `sorted()` to compute the minimum value in a sequence Ruff rule: https://docs.astral.sh/ruff/rules/sorted-min-max/ --- build.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 3a482c6a..3504d75b 100755 --- a/build.py +++ b/build.py @@ -934,7 +934,7 @@ def do_regenerate_sysconfig(): # grab the file in that folder and copy it into the Python lib p = opj(td, pybd, '*') - datafile = sorted(glob.glob(opj(td, pybd, '*')))[0] + datafile = min(glob.glob(opj(td, pybd, '*'))) cmd = [PYTHON, '-c', 'import sysconfig; print(sysconfig.get_path("stdlib"))'] stdlib = runcmd(cmd, getOutput=True) shutil.copy(datafile, stdlib) @@ -1335,7 +1335,7 @@ def cmd_sip(options, args): # Write out a sip build file (no longer done by sip itself) sip_tmp_out_dir = opj(tmpdir, 'build', base) sip_pwd = pushDir(sip_tmp_out_dir) - header = sorted(glob.glob('*.h'))[0] + header = min(glob.glob('*.h')) sources = sorted(glob.glob('*.cpp')) del sip_pwd with open(sbf, 'w') as f: @@ -1408,7 +1408,7 @@ def cmd_sip(options, args): with tempfile.TemporaryDirectory() as tmpdir: cmd = 'sip-module --sdist --abi-version {} --target-dir {} wx.siplib'.format(cfg.SIP_ABI, tmpdir) runcmd(cmd) - tf_name = sorted(glob.glob(tmpdir + '/*.tar*'))[0] + tf_name = min(glob.glob(tmpdir + '/*.tar*')) tf_dir = os.path.splitext(os.path.splitext(tf_name)[0])[0] with tarfile.open(tf_name) as tf: try: