mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
chore: move to ruff-format (#4912)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
This commit is contained in:
parent
0a974fed54
commit
c758b81f3b
@ -30,18 +30,13 @@ repos:
|
||||
- id: clang-format
|
||||
types_or: [c++, c, cuda]
|
||||
|
||||
# Black, the code formatter, natively supports pre-commit
|
||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||
rev: "23.10.1" # Keep in sync with blacken-docs
|
||||
hooks:
|
||||
- id: black
|
||||
|
||||
# Ruff, the Python auto-correcting linter written in Rust
|
||||
# Ruff, the Python auto-correcting linter/formatter written in Rust
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.1.4
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: ["--fix", "--show-fixes"]
|
||||
- id: ruff-format
|
||||
|
||||
# Check static types with mypy
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
@ -88,7 +83,7 @@ repos:
|
||||
hooks:
|
||||
- id: blacken-docs
|
||||
additional_dependencies:
|
||||
- black==23.3.0 # keep in sync with black hook
|
||||
- black==23.*
|
||||
|
||||
# Changes tabs to spaces
|
||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||
|
@ -66,7 +66,9 @@ try:
|
||||
from setuptools import Extension as _Extension
|
||||
from setuptools.command.build_ext import build_ext as _build_ext
|
||||
except ImportError:
|
||||
from distutils.command.build_ext import build_ext as _build_ext # type: ignore[assignment]
|
||||
from distutils.command.build_ext import ( # type: ignore[assignment]
|
||||
build_ext as _build_ext,
|
||||
)
|
||||
from distutils.extension import Extension as _Extension # type: ignore[assignment]
|
||||
|
||||
import distutils.ccompiler
|
||||
|
@ -60,7 +60,6 @@ messages_control.disable = [
|
||||
[tool.ruff]
|
||||
target-version = "py37"
|
||||
src = ["src"]
|
||||
line-length = 120
|
||||
|
||||
[tool.ruff.lint]
|
||||
extend-select = [
|
||||
@ -71,7 +70,6 @@ extend-select = [
|
||||
"C4", # flake8-comprehensions
|
||||
"EM", # flake8-errmsg
|
||||
"ICN", # flake8-import-conventions
|
||||
"ISC", # flake8-implicit-str-concat
|
||||
"PGH", # pygrep-hooks
|
||||
"PIE", # flake8-pie
|
||||
"PL", # pylint
|
||||
@ -90,7 +88,6 @@ ignore = [
|
||||
"SIM118", # iter(x) is not always the same as iter(x.keys())
|
||||
]
|
||||
unfixable = ["T20"]
|
||||
exclude = []
|
||||
isort.known-first-party = ["env", "pybind11_cross_module_tests", "pybind11_tests"]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
|
@ -60,9 +60,7 @@ Members:
|
||||
|
||||
ETwo : Docstring for ETwo
|
||||
|
||||
EThree : Docstring for EThree""".split(
|
||||
"\n"
|
||||
):
|
||||
EThree : Docstring for EThree""".split("\n"):
|
||||
assert docstring_line in m.UnscopedEnum.__doc__
|
||||
|
||||
# Unscoped enums will accept ==/!= int comparisons
|
||||
|
@ -232,25 +232,29 @@ def test_no_mixed_overloads():
|
||||
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
m.ExampleMandA.add_mixed_overloads1()
|
||||
assert str(
|
||||
excinfo.value
|
||||
) == "overloading a method with both static and instance methods is not supported; " + (
|
||||
"#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for more details"
|
||||
if not detailed_error_messages_enabled
|
||||
else "error while attempting to bind static method ExampleMandA.overload_mixed1"
|
||||
"(arg0: float) -> str"
|
||||
assert (
|
||||
str(excinfo.value)
|
||||
== "overloading a method with both static and instance methods is not supported; "
|
||||
+ (
|
||||
"#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for more details"
|
||||
if not detailed_error_messages_enabled
|
||||
else "error while attempting to bind static method ExampleMandA.overload_mixed1"
|
||||
"(arg0: float) -> str"
|
||||
)
|
||||
)
|
||||
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
m.ExampleMandA.add_mixed_overloads2()
|
||||
assert str(
|
||||
excinfo.value
|
||||
) == "overloading a method with both static and instance methods is not supported; " + (
|
||||
"#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for more details"
|
||||
if not detailed_error_messages_enabled
|
||||
else "error while attempting to bind instance method ExampleMandA.overload_mixed2"
|
||||
"(self: pybind11_tests.methods_and_attributes.ExampleMandA, arg0: int, arg1: int)"
|
||||
" -> str"
|
||||
assert (
|
||||
str(excinfo.value)
|
||||
== "overloading a method with both static and instance methods is not supported; "
|
||||
+ (
|
||||
"#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for more details"
|
||||
if not detailed_error_messages_enabled
|
||||
else "error while attempting to bind instance method ExampleMandA.overload_mixed2"
|
||||
"(self: pybind11_tests.methods_and_attributes.ExampleMandA, arg0: int, arg1: int)"
|
||||
" -> str"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user