Merge branch 'master' into sh_merge_master

This commit is contained in:
Ralf W. Grosse-Kunstleve 2023-04-30 21:23:26 -07:00
commit 4d597f8aa0
7 changed files with 52 additions and 51 deletions

View File

@ -42,7 +42,7 @@ repos:
# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
rev: "23.1.0" # Keep in sync with blacken-docs
rev: "23.3.0" # Keep in sync with blacken-docs
hooks:
- id: black
@ -52,11 +52,11 @@ repos:
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.1.0 # keep in sync with black hook
- black==23.3.0 # keep in sync with black hook
# Changes tabs to spaces
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: "v1.4.2"
rev: "v1.5.1"
hooks:
- id: remove-tabs
exclude: (^docs/.*|\.patch)?$
@ -70,7 +70,7 @@ repos:
# Ruff, the Python auto-correcting linter written in Rust
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
rev: v0.0.263
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
@ -85,7 +85,7 @@ repos:
# PyLint has native support - not always usable, but works for us
- repo: https://github.com/PyCQA/pylint
rev: "v2.16.4"
rev: "v3.0.0a6"
hooks:
- id: pylint
files: ^pybind11
@ -101,7 +101,7 @@ repos:
# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.0.1"
rev: "v1.1.1"
hooks:
- id: mypy
args: []
@ -121,11 +121,11 @@ repos:
# Use tools/codespell_ignore_lines_from_errors.py
# to rebuild .codespell-ignore-lines
- repo: https://github.com/codespell-project/codespell
rev: "v2.2.2"
rev: "v2.2.4"
hooks:
- id: codespell
exclude: ".supp$"
args: ["-x", ".codespell-ignore-lines"]
args: ["-x.codespell-ignore-lines", "-Lccompiler"]
# Check for common shell mistakes
- repo: https://github.com/shellcheck-py/shellcheck-py
@ -144,7 +144,7 @@ repos:
# Clang format the codebase automatically
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v15.0.7"
rev: "v16.0.0"
hooks:
- id: clang-format
types_or: [c++, c, cuda]

View File

@ -258,9 +258,9 @@ struct value_and_holder {
// Main constructor for a found value/holder:
value_and_holder(instance *i, const detail::type_info *type, size_t vpos, size_t index)
: inst{i}, index{index}, type{type}, vh{inst->simple_layout
? inst->simple_value_holder
: &inst->nonsimple.values_and_holders[vpos]} {}
: inst{i}, index{index}, type{type},
vh{inst->simple_layout ? inst->simple_value_holder
: &inst->nonsimple.values_and_holders[vpos]} {}
// Default constructor (used to signal a value-and-holder not found by get_value_and_holder())
value_and_holder() = default;

View File

@ -93,3 +93,4 @@ isort.known-first-party = ["env", "pybind11_cross_module_tests", "pybind11_tests
[tool.ruff.per-file-ignores]
"tests/**" = ["EM", "N"]
"tests/test_call_policies.py" = ["PLC1901"]

View File

@ -9,16 +9,16 @@ def test_captured(capsys):
m.captured_output(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
m.captured_err(msg)
stdout, stderr = capsys.readouterr()
assert stdout == ""
assert not stdout
assert stderr == msg
@ -30,7 +30,7 @@ def test_captured_large_string(capsys):
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_captured_utf8_2byte_offset0(capsys):
@ -40,7 +40,7 @@ def test_captured_utf8_2byte_offset0(capsys):
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_captured_utf8_2byte_offset1(capsys):
@ -50,7 +50,7 @@ def test_captured_utf8_2byte_offset1(capsys):
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_captured_utf8_3byte_offset0(capsys):
@ -60,7 +60,7 @@ def test_captured_utf8_3byte_offset0(capsys):
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_captured_utf8_3byte_offset1(capsys):
@ -70,7 +70,7 @@ def test_captured_utf8_3byte_offset1(capsys):
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_captured_utf8_3byte_offset2(capsys):
@ -80,7 +80,7 @@ def test_captured_utf8_3byte_offset2(capsys):
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_captured_utf8_4byte_offset0(capsys):
@ -90,7 +90,7 @@ def test_captured_utf8_4byte_offset0(capsys):
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_captured_utf8_4byte_offset1(capsys):
@ -100,7 +100,7 @@ def test_captured_utf8_4byte_offset1(capsys):
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_captured_utf8_4byte_offset2(capsys):
@ -110,7 +110,7 @@ def test_captured_utf8_4byte_offset2(capsys):
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_captured_utf8_4byte_offset3(capsys):
@ -120,7 +120,7 @@ def test_captured_utf8_4byte_offset3(capsys):
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_guard_capture(capsys):
@ -128,7 +128,7 @@ def test_guard_capture(capsys):
m.guard_output(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
def test_series_captured(capture):
@ -145,7 +145,7 @@ def test_flush(capfd):
with m.ostream_redirect():
m.noisy_function(msg, flush=False)
stdout, stderr = capfd.readouterr()
assert stdout == ""
assert not stdout
m.noisy_function(msg2, flush=True)
stdout, stderr = capfd.readouterr()
@ -164,15 +164,15 @@ def test_not_captured(capfd):
m.raw_output(msg)
stdout, stderr = capfd.readouterr()
assert stdout == msg
assert stderr == ""
assert stream.getvalue() == ""
assert not stderr
assert not stream.getvalue()
stream = StringIO()
with redirect_stdout(stream):
m.captured_output(msg)
stdout, stderr = capfd.readouterr()
assert stdout == ""
assert stderr == ""
assert not stdout
assert not stderr
assert stream.getvalue() == msg
@ -182,16 +182,16 @@ def test_err(capfd):
with redirect_stderr(stream):
m.raw_err(msg)
stdout, stderr = capfd.readouterr()
assert stdout == ""
assert not stdout
assert stderr == msg
assert stream.getvalue() == ""
assert not stream.getvalue()
stream = StringIO()
with redirect_stderr(stream):
m.captured_err(msg)
stdout, stderr = capfd.readouterr()
assert stdout == ""
assert stderr == ""
assert not stdout
assert not stderr
assert stream.getvalue() == msg
@ -221,13 +221,13 @@ def test_redirect(capfd):
m.raw_output(msg)
stdout, stderr = capfd.readouterr()
assert stdout == msg
assert stream.getvalue() == ""
assert not stream.getvalue()
stream = StringIO()
with redirect_stdout(stream), m.ostream_redirect():
m.raw_output(msg)
stdout, stderr = capfd.readouterr()
assert stdout == ""
assert not stdout
assert stream.getvalue() == msg
stream = StringIO()
@ -235,7 +235,7 @@ def test_redirect(capfd):
m.raw_output(msg)
stdout, stderr = capfd.readouterr()
assert stdout == msg
assert stream.getvalue() == ""
assert not stream.getvalue()
def test_redirect_err(capfd):
@ -248,7 +248,7 @@ def test_redirect_err(capfd):
m.raw_err(msg2)
stdout, stderr = capfd.readouterr()
assert stdout == msg
assert stderr == ""
assert not stderr
assert stream.getvalue() == msg2
@ -262,8 +262,8 @@ def test_redirect_both(capfd):
m.raw_output(msg)
m.raw_err(msg2)
stdout, stderr = capfd.readouterr()
assert stdout == ""
assert stderr == ""
assert not stdout
assert not stderr
assert stream.getvalue() == msg
assert stream2.getvalue() == msg2

View File

@ -367,7 +367,7 @@ def test_issue_1561():
"""check fix for issue #1561"""
bar = m.Issue1561Outer()
bar.list = [m.Issue1561Inner("bar")]
bar.list
assert bar.list
assert bar.list[0].data == "bar"

View File

@ -45,8 +45,6 @@ using namespace pybind11_tests::vector_unique_ptr_member;
py::object py_cast_VectorOwner_ptr(VectorOwner *ptr) { return py::cast(ptr); }
// PYBIND11_SMART_HOLDER_TYPE_CASTERS(VectorOwner)
TEST_SUBMODULE(vector_unique_ptr_member, m) {
py::class_<VectorOwner>(m, "VectorOwner")
.def_static("Create", &VectorOwner::Create)

View File

@ -5,8 +5,8 @@ Adds the following targets::
pybind11::pybind11 - link to headers and pybind11
pybind11::module - Adds module links
pybind11::embed - Adds embed links
pybind11::lto - Link time optimizations (manual selection)
pybind11::thin_lto - Link time optimizations (manual selection)
pybind11::lto - Link time optimizations (only if CMAKE_INTERPROCEDURAL_OPTIMIZATION is not set)
pybind11::thin_lto - Link time optimizations (only if CMAKE_INTERPROCEDURAL_OPTIMIZATION is not set)
pybind11::python_link_helper - Adds link to Python libraries
pybind11::windows_extras - MSVC bigobj and mp for building multithreaded
pybind11::opt_size - avoid optimizations that increase code size
@ -20,7 +20,7 @@ Adds the following functions::
# CMake 3.10 has an include_guard command, but we can't use that yet
# include_guard(global) (pre-CMake 3.10)
if(TARGET pybind11::lto)
if(TARGET pybind11::pybind11)
return()
endif()
@ -372,11 +372,13 @@ function(_pybind11_generate_lto target prefer_thin_lto)
endif()
endfunction()
add_library(pybind11::lto IMPORTED INTERFACE ${optional_global})
_pybind11_generate_lto(pybind11::lto FALSE)
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
add_library(pybind11::lto IMPORTED INTERFACE ${optional_global})
_pybind11_generate_lto(pybind11::lto FALSE)
add_library(pybind11::thin_lto IMPORTED INTERFACE ${optional_global})
_pybind11_generate_lto(pybind11::thin_lto TRUE)
add_library(pybind11::thin_lto IMPORTED INTERFACE ${optional_global})
_pybind11_generate_lto(pybind11::thin_lto TRUE)
endif()
# ---------------------- pybind11_strip -----------------------------