Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Tools/build/.ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
extend = "../../.ruff.toml" # Inherit the project-wide settings

[per-file-target-version]
"deepfreeze.py" = "py311" # requires `code.co_exceptiontable`
"stable_abi.py" = "py311" # requires 'tomllib'

[format]
preview = true
docstring-code-format = true

[lint]
select = [
"C4", # flake8-comprehensions
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"PGH", # pygrep-hooks
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RUF100", # Ban unused `# noqa` comments
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
]
ignore = [
"E501", # Line too long
"F541", # f-string without any placeholders
"PYI024", # Use `typing.NamedTuple` instead of `collections.namedtuple`
"PYI025", # Use `from collections.abc import Set as AbstractSet`
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
]

[lint.per-file-ignores]
"{check_extension_modules,freeze_modules}.py" = [
"UP031", # Use format specifiers instead of percent format
]
"generate_{re_casefix,sre_constants,token}.py" = [
"UP031", # Use format specifiers instead of percent format
]
9 changes: 9 additions & 0 deletions Tools/build/.warningignore_macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Files listed will be ignored by the compiler warning checker
# for the macOS/build and test job.
# Keep lines sorted lexicographically to help avoid merge conflicts.
# Format example:
# /path/to/file (number of warnings in file)
Modules/expat/siphash.h 7
Modules/expat/xmlparse.c 13
Modules/expat/xmltok.c 3
Modules/expat/xmltok_impl.c 26
5 changes: 5 additions & 0 deletions Tools/build/.warningignore_ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Files listed will be ignored by the compiler warning checker
# for the Ubuntu/build and test job.
# Keep lines sorted lexicographically to help avoid merge conflicts.
# Format example:
# /path/to/file (number of warnings in file)
15 changes: 10 additions & 5 deletions Tools/build/check_extension_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@
import sys
import sysconfig
import warnings

from collections.abc import Iterable
from importlib._bootstrap import _load as bootstrap_load # type: ignore[attr-defined]
from importlib.machinery import BuiltinImporter, ExtensionFileLoader, ModuleSpec
from importlib._bootstrap import ( # type: ignore[attr-defined]
_load as bootstrap_load,
)
from importlib.machinery import (
BuiltinImporter,
ExtensionFileLoader,
ModuleSpec,
)
from importlib.util import spec_from_file_location, spec_from_loader
from typing import NamedTuple

Expand Down Expand Up @@ -201,7 +206,7 @@ def print_three_column(modinfos: list[ModuleInfo]) -> None:
# 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:
Expand Down Expand Up @@ -433,7 +438,7 @@ def check_module_import(self, modinfo: ModuleInfo) -> None:
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
Expand Down
Loading