gh-132390: Apply Ruff linting to Tools/build (#132391)

---------

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
Bénédikt Tran 2025-04-20 11:21:41 +02:00 committed by GitHub
parent 246ed23456
commit 5d8e432d9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 109 additions and 99 deletions

View file

@ -17,6 +17,7 @@
See --help for more information
"""
import _imp
import argparse
import collections
import enum
@ -27,12 +28,14 @@
import sys
import sysconfig
import warnings
import _imp
from collections.abc import Iterable
from importlib._bootstrap import _load as bootstrap_load
from importlib.machinery import BuiltinImporter, ExtensionFileLoader, ModuleSpec
from importlib.machinery import (
BuiltinImporter,
ExtensionFileLoader,
ModuleSpec,
)
from importlib.util import spec_from_file_location, spec_from_loader
from typing import Iterable
SRC_DIR = pathlib.Path(__file__).parent.parent.parent
@ -195,7 +198,7 @@ def print_three_column(modinfos: list[ModuleInfo]):
# guarantee zip() doesn't drop anything
while len(names) % 3:
names.append("")
for l, m, r in zip(names[::3], names[1::3], names[2::3]):
for l, m, r in zip(names[::3], names[1::3], names[2::3]): # noqa: E741
print("%-*s %-*s %-*s" % (longest, l, longest, m, longest, r))
if verbose and self.builtin_ok:
@ -420,7 +423,7 @@ def check_module_import(self, modinfo: ModuleInfo):
except ImportError as e:
logger.error("%s failed to import: %s", modinfo.name, e)
raise
except Exception as e:
except Exception:
if not hasattr(_imp, 'create_dynamic'):
logger.warning("Dynamic extension '%s' ignored", modinfo.name)
return