Skip to content

Commit e5a082c

Browse files
committed
chore: move to ruff-format
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 14a1aec commit e5a082c

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,13 @@ repos:
3030
- id: clang-format
3131
types_or: [c++, c, cuda]
3232

33-
# Black, the code formatter, natively supports pre-commit
34-
- repo: https://github.com/psf/black-pre-commit-mirror
35-
rev: "23.10.1" # Keep in sync with blacken-docs
36-
hooks:
37-
- id: black
38-
39-
# Ruff, the Python auto-correcting linter written in Rust
33+
# Ruff, the Python auto-correcting linter/formatter written in Rust
4034
- repo: https://github.com/astral-sh/ruff-pre-commit
41-
rev: v0.1.2
35+
rev: v0.1.3
4236
hooks:
4337
- id: ruff
4438
args: ["--fix", "--show-fixes"]
39+
- id: ruff-format
4540

4641
# Check static types with mypy
4742
- repo: https://github.com/pre-commit/mirrors-mypy
@@ -88,7 +83,7 @@ repos:
8883
hooks:
8984
- id: blacken-docs
9085
additional_dependencies:
91-
- black==23.3.0 # keep in sync with black hook
86+
- black==23.*
9287

9388
# Changes tabs to spaces
9489
- repo: https://github.com/Lucas-C/pre-commit-hooks

pybind11/setup_helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
from setuptools import Extension as _Extension
6767
from setuptools.command.build_ext import build_ext as _build_ext
6868
except ImportError:
69-
from distutils.command.build_ext import build_ext as _build_ext # type: ignore[assignment]
69+
from distutils.command.build_ext import ( # type: ignore[assignment]
70+
build_ext as _build_ext,
71+
)
7072
from distutils.extension import Extension as _Extension # type: ignore[assignment]
7173

7274
import distutils.ccompiler

pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ messages_control.disable = [
6060
[tool.ruff]
6161
target-version = "py37"
6262
src = ["src"]
63-
line-length = 120
6463

6564
[tool.ruff.lint]
6665
extend-select = [
@@ -71,7 +70,6 @@ extend-select = [
7170
"C4", # flake8-comprehensions
7271
"EM", # flake8-errmsg
7372
"ICN", # flake8-import-conventions
74-
"ISC", # flake8-implicit-str-concat
7573
"PGH", # pygrep-hooks
7674
"PIE", # flake8-pie
7775
"PL", # pylint
@@ -90,7 +88,6 @@ ignore = [
9088
"SIM118", # iter(x) is not always the same as iter(x.keys())
9189
]
9290
unfixable = ["T20"]
93-
exclude = []
9491
isort.known-first-party = ["env", "pybind11_cross_module_tests", "pybind11_tests"]
9592

9693
[tool.ruff.lint.per-file-ignores]

tests/test_enum.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ def test_unscoped_enum():
6060
6161
ETwo : Docstring for ETwo
6262
63-
EThree : Docstring for EThree""".split(
64-
"\n"
65-
):
63+
EThree : Docstring for EThree""".split("\n"):
6664
assert docstring_line in m.UnscopedEnum.__doc__
6765

6866
# Unscoped enums will accept ==/!= int comparisons

tests/test_methods_and_attributes.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -232,25 +232,29 @@ def test_no_mixed_overloads():
232232

233233
with pytest.raises(RuntimeError) as excinfo:
234234
m.ExampleMandA.add_mixed_overloads1()
235-
assert str(
236-
excinfo.value
237-
) == "overloading a method with both static and instance methods is not supported; " + (
238-
"#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for more details"
239-
if not detailed_error_messages_enabled
240-
else "error while attempting to bind static method ExampleMandA.overload_mixed1"
241-
"(arg0: float) -> str"
235+
assert (
236+
str(excinfo.value)
237+
== "overloading a method with both static and instance methods is not supported; "
238+
+ (
239+
"#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for more details"
240+
if not detailed_error_messages_enabled
241+
else "error while attempting to bind static method ExampleMandA.overload_mixed1"
242+
"(arg0: float) -> str"
243+
)
242244
)
243245

244246
with pytest.raises(RuntimeError) as excinfo:
245247
m.ExampleMandA.add_mixed_overloads2()
246-
assert str(
247-
excinfo.value
248-
) == "overloading a method with both static and instance methods is not supported; " + (
249-
"#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for more details"
250-
if not detailed_error_messages_enabled
251-
else "error while attempting to bind instance method ExampleMandA.overload_mixed2"
252-
"(self: pybind11_tests.methods_and_attributes.ExampleMandA, arg0: int, arg1: int)"
253-
" -> str"
248+
assert (
249+
str(excinfo.value)
250+
== "overloading a method with both static and instance methods is not supported; "
251+
+ (
252+
"#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for more details"
253+
if not detailed_error_messages_enabled
254+
else "error while attempting to bind instance method ExampleMandA.overload_mixed2"
255+
"(self: pybind11_tests.methods_and_attributes.ExampleMandA, arg0: int, arg1: int)"
256+
" -> str"
257+
)
254258
)
255259

256260

0 commit comments

Comments
 (0)