Skip to content

Commit f707c33

Browse files
authored
chore: bump to ruff 0.11, work around bug (#1015)
Working around a bug with the TC checks and submodules (astral-sh/ruff#16186). Signed-off-by: Henry Schreiner <[email protected]>
1 parent 29443d3 commit f707c33

File tree

8 files changed

+90
-38
lines changed

8 files changed

+90
-38
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
exclude: "^tests"
2626

2727
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: v0.9.9
28+
rev: v0.11.0
2929
hooks:
3030
- id: ruff
3131
args: ["--fix", "--show-fixes"]
@@ -129,12 +129,12 @@ repos:
129129
additional_dependencies: [cogapp]
130130

131131
- repo: https://github.com/henryiii/validate-pyproject-schema-store
132-
rev: 2025.02.24
132+
rev: 2025.03.10
133133
hooks:
134134
- id: validate-pyproject
135135

136136
- repo: https://github.com/python-jsonschema/check-jsonschema
137-
rev: 0.31.2
137+
rev: 0.31.3
138138
hooks:
139139
- id: check-dependabot
140140
- id: check-github-workflows

src/scikit_build_core/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def pyproject_format(
7171
"""Generate :py:class:`PyprojectFormatter` dictionary to use in f-string format."""
7272
if dummy:
7373
# Return a dict with all the known keys but with values replaced with dummy values
74-
return {key: "*" for key in PyprojectFormatter.__annotations__}
74+
return dict.fromkeys(PyprojectFormatter.__annotations__, "*")
7575

7676
assert settings is not None
7777
# First set all known values

src/scikit_build_core/hatch/plugin.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import tempfile
1111
import typing
1212
from pathlib import Path
13-
from typing import Any, Literal
13+
from typing import Any
1414

1515
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
1616
from packaging.version import Version
@@ -46,7 +46,9 @@ def _read_config(self) -> SettingsReader:
4646
config_dict.pop("require-runtime-dependencies", None)
4747
config_dict.pop("require-runtime-features", None)
4848

49-
state = typing.cast(Literal["sdist", "wheel", "editable"], self.target_name)
49+
state = typing.cast(
50+
"typing.Literal['sdist', 'wheel', 'editable']", self.target_name
51+
)
5052
return SettingsReader.from_file(
5153
"pyproject.toml", state=state, extra_settings=config_dict
5254
)

src/scikit_build_core/resources/_editable_redirect.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import subprocess
77
import sys
88

9+
# Importing as little as possible is important, since every usage of Python
10+
# imports this file. That's why we use this trick for TYPE_CHECKING
911
TYPE_CHECKING = False
1012
if TYPE_CHECKING:
11-
import importlib.machinery
13+
from importlib.machinery import ModuleSpec
1214

1315

1416
DIR = os.path.abspath(os.path.dirname(__file__))
@@ -133,7 +135,7 @@ def find_spec(
133135
fullname: str,
134136
path: object = None,
135137
target: object = None,
136-
) -> importlib.machinery.ModuleSpec | None:
138+
) -> ModuleSpec | None:
137139
# If no known submodule_search_locations is found, it means it is a root
138140
# module.
139141
if fullname in self.submodule_search_locations:

src/scikit_build_core/settings/sources.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,6 @@ def unrecognized_options(self, options: object) -> Generator[str, None, None]:
639639

640640

641641
if typing.TYPE_CHECKING:
642-
_: Source = typing.cast(EnvSource, None)
643-
_ = typing.cast(ConfSource, None)
644-
_ = typing.cast(TOMLSource, None)
642+
_: Source = typing.cast("EnvSource", None)
643+
_ = typing.cast("ConfSource", None)
644+
_ = typing.cast("TOMLSource", None)

tests/test_builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_builder_macos_arch_extra(monkeypatch):
105105
archflags = "-arch arm64 -arch x86_64"
106106
monkeypatch.setattr(sys, "platform", "darwin")
107107
monkeypatch.setenv("ARCHFLAGS", archflags)
108-
tmpcfg = typing.cast(CMaker, SimpleNamespace(env=os.environ.copy()))
108+
tmpcfg = typing.cast("CMaker", SimpleNamespace(env=os.environ.copy()))
109109

110110
tmpbuilder = Builder(
111111
settings=ScikitBuildSettings(wheel=WheelSettings()),
@@ -125,7 +125,7 @@ def test_builder_macos_arch_extra(monkeypatch):
125125
)
126126
def test_builder_get_cmake_args(monkeypatch, cmake_args, answer):
127127
monkeypatch.setenv("CMAKE_ARGS", cmake_args)
128-
tmpcfg = typing.cast(CMaker, SimpleNamespace(env=os.environ.copy()))
128+
tmpcfg = typing.cast("CMaker", SimpleNamespace(env=os.environ.copy()))
129129
tmpbuilder = Builder(
130130
settings=ScikitBuildSettings(wheel=WheelSettings()),
131131
config=tmpcfg,
@@ -138,7 +138,7 @@ def test_build_tool_args():
138138
settings = ScikitBuildSettings(build=BuildSettings(tool_args=["b"]))
139139
tmpbuilder = Builder(
140140
settings=settings,
141-
config=typing.cast(CMaker, config),
141+
config=typing.cast("CMaker", config),
142142
)
143143
tmpbuilder.build(["a"])
144144
config.build.assert_called_once_with(

tests/test_pyproject_pep660.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@pytest.fixture(params=["redirect", "inplace"])
1313
def editable_mode(request: pytest.FixtureRequest) -> str:
14-
return typing.cast(str, request.param)
14+
return typing.cast("str", request.param)
1515

1616

1717
# TODO: figure out why gmake is reporting no rule to make simple_pure.cpp

tests/test_skbuild_settings.py

Lines changed: 71 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,29 @@ def test_skbuild_settings_pyproject_toml_broken(
390390

391391
ex = capsys.readouterr().out
392392
ex = re.sub(r"\x1b(\[.*?[@-~]|\].*?(\x07|\x1b\\))", "", ex)
393-
assert (
394-
ex.split()
395-
== """\
396-
ERROR: Unrecognized options in pyproject.toml:
397-
tool.scikit-build.cmake.verison -> Did you mean: tool.scikit-build.cmake.version, tool.scikit-build.cmake.verbose, tool.scikit-build.cmake.define?
398-
tool.scikit-build.logger -> Did you mean: tool.scikit-build.logging, tool.scikit-build.generate, tool.scikit-build.search?
399-
""".split()
400-
)
393+
assert ex.split() == [
394+
"ERROR:",
395+
"Unrecognized",
396+
"options",
397+
"in",
398+
"pyproject.toml:",
399+
"tool.scikit-build.cmake.verison",
400+
"->",
401+
"Did",
402+
"you",
403+
"mean:",
404+
"tool.scikit-build.cmake.version,",
405+
"tool.scikit-build.cmake.verbose,",
406+
"tool.scikit-build.cmake.define?",
407+
"tool.scikit-build.logger",
408+
"->",
409+
"Did",
410+
"you",
411+
"mean:",
412+
"tool.scikit-build.logging,",
413+
"tool.scikit-build.generate,",
414+
"tool.scikit-build.search?",
415+
]
401416

402417

403418
def test_skbuild_settings_pyproject_conf_broken(
@@ -430,14 +445,27 @@ def test_skbuild_settings_pyproject_conf_broken(
430445
ex = capsys.readouterr().out
431446
# Filter terminal color codes
432447
ex = re.sub(r"\x1b(\[.*?[@-~]|\].*?(\x07|\x1b\\))", "", ex)
433-
assert (
434-
ex.split()
435-
== """\
436-
ERROR: Unrecognized options in config-settings:
437-
cmake.verison -> Did you mean: cmake.version, cmake.verbose, cmake.define?
438-
logger -> Did you mean: logging?
439-
""".split()
440-
)
448+
assert ex.split() == [
449+
"ERROR:",
450+
"Unrecognized",
451+
"options",
452+
"in",
453+
"config-settings:",
454+
"cmake.verison",
455+
"->",
456+
"Did",
457+
"you",
458+
"mean:",
459+
"cmake.version,",
460+
"cmake.verbose,",
461+
"cmake.define?",
462+
"logger",
463+
"->",
464+
"Did",
465+
"you",
466+
"mean:",
467+
"logging?",
468+
]
441469

442470

443471
def test_skbuild_settings_min_version_defaults_strip(
@@ -742,13 +770,33 @@ def test_skbuild_settings_auto_cmake_warning(
742770
ex = capsys.readouterr().out
743771
ex = re.sub(r"\x1b(\[.*?[@-~]|\].*?(\x07|\x1b\\))", "", ex)
744772
print(ex)
745-
assert (
746-
ex.split()
747-
== """\
748-
WARNING: CMakeLists.txt not found when looking for minimum CMake version.
749-
Report this or (and) set manually to avoid this warning. Using 3.15 as a fall-back.
750-
""".split()
751-
)
773+
assert ex.split() == [
774+
"WARNING:",
775+
"CMakeLists.txt",
776+
"not",
777+
"found",
778+
"when",
779+
"looking",
780+
"for",
781+
"minimum",
782+
"CMake",
783+
"version.",
784+
"Report",
785+
"this",
786+
"or",
787+
"(and)",
788+
"set",
789+
"manually",
790+
"to",
791+
"avoid",
792+
"this",
793+
"warning.",
794+
"Using",
795+
"3.15",
796+
"as",
797+
"a",
798+
"fall-back.",
799+
]
752800

753801

754802
def test_skbuild_settings_cmake_define_list():

0 commit comments

Comments
 (0)