Skip to content

Commit 124b62a

Browse files
committed
Merge branch 'master' into sh_merge_master
2 parents e5ce963 + c758b81 commit 124b62a

File tree

7 files changed

+34
-33
lines changed

7 files changed

+34
-33
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,18 @@ repos:
2525

2626
# Clang format the codebase automatically
2727
- repo: https://github.com/pre-commit/mirrors-clang-format
28-
rev: "v17.0.3"
28+
rev: "v17.0.4"
2929
hooks:
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.4
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
@@ -89,7 +84,7 @@ repos:
8984
hooks:
9085
- id: blacken-docs
9186
additional_dependencies:
92-
- black==23.3.0 # keep in sync with black hook
87+
- black==23.*
9388

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

include/pybind11/pybind11.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3011,10 +3011,15 @@ get_type_override(const void *this_ptr, const type_info *this_type, const char *
30113011
if ((std::string) str(f_code->co_name) == name && f_code->co_argcount > 0) {
30123012
PyObject *locals = PyEval_GetLocals();
30133013
if (locals != nullptr) {
3014+
# if PY_VERSION_HEX >= 0x030b0000
3015+
PyObject *co_varnames = PyCode_GetVarnames(f_code);
3016+
# else
30143017
PyObject *co_varnames = PyObject_GetAttrString((PyObject *) f_code, "co_varnames");
3018+
# endif
30153019
PyObject *self_arg = PyTuple_GET_ITEM(co_varnames, 0);
30163020
Py_DECREF(co_varnames);
30173021
PyObject *self_caller = dict_getitem(locals, self_arg);
3022+
Py_DECREF(locals);
30183023
if (self_caller == self.ptr()) {
30193024
Py_DECREF(f_code);
30203025
Py_DECREF(frame);

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

tools/pybind11Config.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ default is ``MODULE``. There are several options:
149149
``OPT_SIZE``
150150
Optimize for size, even if the ``CMAKE_BUILD_TYPE`` is not ``MinSizeRel``.
151151
``THIN_LTO``
152-
Use thin TLO instead of regular if there's a choice (pybind11's selection
152+
Use thin LTO instead of regular if there's a choice (pybind11's selection
153153
is disabled if ``CMAKE_INTERPROCEDURAL_OPTIMIZATIONS`` is set).
154154
``WITHOUT_SOABI``
155155
Disable the SOABI component (``PYBIND11_NEWPYTHON`` mode only).

0 commit comments

Comments
 (0)