Skip to content

Commit 6afa757

Browse files
committed
Merge branch 'master' into type_caster_PyObject_master
2 parents cf4c282 + da91926 commit 6afa757

File tree

7 files changed

+52
-54
lines changed

7 files changed

+52
-54
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ repos:
4141

4242
# Black, the code formatter, natively supports pre-commit
4343
- repo: https://github.com/psf/black
44-
rev: "23.1.0" # Keep in sync with blacken-docs
44+
rev: "23.3.0" # Keep in sync with blacken-docs
4545
hooks:
4646
- id: black
4747

@@ -51,11 +51,11 @@ repos:
5151
hooks:
5252
- id: blacken-docs
5353
additional_dependencies:
54-
- black==23.1.0 # keep in sync with black hook
54+
- black==23.3.0 # keep in sync with black hook
5555

5656
# Changes tabs to spaces
5757
- repo: https://github.com/Lucas-C/pre-commit-hooks
58-
rev: "v1.4.2"
58+
rev: "v1.5.1"
5959
hooks:
6060
- id: remove-tabs
6161

@@ -68,7 +68,7 @@ repos:
6868

6969
# Ruff, the Python auto-correcting linter written in Rust
7070
- repo: https://github.com/charliermarsh/ruff-pre-commit
71-
rev: v0.0.254
71+
rev: v0.0.263
7272
hooks:
7373
- id: ruff
7474
args: ["--fix", "--show-fixes"]
@@ -84,7 +84,7 @@ repos:
8484

8585
# PyLint has native support - not always usable, but works for us
8686
- repo: https://github.com/PyCQA/pylint
87-
rev: "v2.16.4"
87+
rev: "v3.0.0a6"
8888
hooks:
8989
- id: pylint
9090
files: ^pybind11
@@ -100,7 +100,7 @@ repos:
100100

101101
# Check static types with mypy
102102
- repo: https://github.com/pre-commit/mirrors-mypy
103-
rev: "v1.0.1"
103+
rev: "v1.1.1"
104104
hooks:
105105
- id: mypy
106106
args: []
@@ -120,11 +120,11 @@ repos:
120120
# Use tools/codespell_ignore_lines_from_errors.py
121121
# to rebuild .codespell-ignore-lines
122122
- repo: https://github.com/codespell-project/codespell
123-
rev: "v2.2.2"
123+
rev: "v2.2.4"
124124
hooks:
125125
- id: codespell
126126
exclude: ".supp$"
127-
args: ["-x", ".codespell-ignore-lines"]
127+
args: ["-x.codespell-ignore-lines", "-Lccompiler"]
128128

129129
# Check for common shell mistakes
130130
- repo: https://github.com/shellcheck-py/shellcheck-py
@@ -143,7 +143,7 @@ repos:
143143

144144
# Clang format the codebase automatically
145145
- repo: https://github.com/pre-commit/mirrors-clang-format
146-
rev: "v15.0.7"
146+
rev: "v16.0.0"
147147
hooks:
148148
- id: clang-format
149149
types_or: [c++, c, cuda]

include/pybind11/detail/type_caster_base.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ struct value_and_holder {
258258

259259
// Main constructor for a found value/holder:
260260
value_and_holder(instance *i, const detail::type_info *type, size_t vpos, size_t index)
261-
: inst{i}, index{index}, type{type}, vh{inst->simple_layout
262-
? inst->simple_value_holder
263-
: &inst->nonsimple.values_and_holders[vpos]} {}
261+
: inst{i}, index{index}, type{type},
262+
vh{inst->simple_layout ? inst->simple_value_holder
263+
: &inst->nonsimple.values_and_holders[vpos]} {}
264264

265265
// Default constructor (used to signal a value-and-holder not found by get_value_and_holder())
266266
value_and_holder() = default;

pybind11/setup_helpers.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
144144
self.cxx_std = cxx_std
145145

146146
cflags = []
147-
ldflags = []
148147
if WIN:
149148
cflags += ["/EHsc", "/bigobj"]
150149
else:
@@ -154,11 +153,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
154153
c_cpp_flags = shlex.split(env_cflags) + shlex.split(env_cppflags)
155154
if not any(opt.startswith("-g") for opt in c_cpp_flags):
156155
cflags += ["-g0"]
157-
if MACOS:
158-
cflags += ["-stdlib=libc++"]
159-
ldflags += ["-stdlib=libc++"]
160156
self._add_cflags(cflags)
161-
self._add_ldflags(ldflags)
162157

163158
@property
164159
def cxx_std(self) -> int:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,4 @@ isort.known-first-party = ["env", "pybind11_cross_module_tests", "pybind11_tests
9393

9494
[tool.ruff.per-file-ignores]
9595
"tests/**" = ["EM", "N"]
96+
"tests/test_call_policies.py" = ["PLC1901"]

tests/test_iostream.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ def test_captured(capsys):
99
m.captured_output(msg)
1010
stdout, stderr = capsys.readouterr()
1111
assert stdout == msg
12-
assert stderr == ""
12+
assert not stderr
1313

1414
m.captured_output_default(msg)
1515
stdout, stderr = capsys.readouterr()
1616
assert stdout == msg
17-
assert stderr == ""
17+
assert not stderr
1818

1919
m.captured_err(msg)
2020
stdout, stderr = capsys.readouterr()
21-
assert stdout == ""
21+
assert not stdout
2222
assert stderr == msg
2323

2424

@@ -30,7 +30,7 @@ def test_captured_large_string(capsys):
3030
m.captured_output_default(msg)
3131
stdout, stderr = capsys.readouterr()
3232
assert stdout == msg
33-
assert stderr == ""
33+
assert not stderr
3434

3535

3636
def test_captured_utf8_2byte_offset0(capsys):
@@ -40,7 +40,7 @@ def test_captured_utf8_2byte_offset0(capsys):
4040
m.captured_output_default(msg)
4141
stdout, stderr = capsys.readouterr()
4242
assert stdout == msg
43-
assert stderr == ""
43+
assert not stderr
4444

4545

4646
def test_captured_utf8_2byte_offset1(capsys):
@@ -50,7 +50,7 @@ def test_captured_utf8_2byte_offset1(capsys):
5050
m.captured_output_default(msg)
5151
stdout, stderr = capsys.readouterr()
5252
assert stdout == msg
53-
assert stderr == ""
53+
assert not stderr
5454

5555

5656
def test_captured_utf8_3byte_offset0(capsys):
@@ -60,7 +60,7 @@ def test_captured_utf8_3byte_offset0(capsys):
6060
m.captured_output_default(msg)
6161
stdout, stderr = capsys.readouterr()
6262
assert stdout == msg
63-
assert stderr == ""
63+
assert not stderr
6464

6565

6666
def test_captured_utf8_3byte_offset1(capsys):
@@ -70,7 +70,7 @@ def test_captured_utf8_3byte_offset1(capsys):
7070
m.captured_output_default(msg)
7171
stdout, stderr = capsys.readouterr()
7272
assert stdout == msg
73-
assert stderr == ""
73+
assert not stderr
7474

7575

7676
def test_captured_utf8_3byte_offset2(capsys):
@@ -80,7 +80,7 @@ def test_captured_utf8_3byte_offset2(capsys):
8080
m.captured_output_default(msg)
8181
stdout, stderr = capsys.readouterr()
8282
assert stdout == msg
83-
assert stderr == ""
83+
assert not stderr
8484

8585

8686
def test_captured_utf8_4byte_offset0(capsys):
@@ -90,7 +90,7 @@ def test_captured_utf8_4byte_offset0(capsys):
9090
m.captured_output_default(msg)
9191
stdout, stderr = capsys.readouterr()
9292
assert stdout == msg
93-
assert stderr == ""
93+
assert not stderr
9494

9595

9696
def test_captured_utf8_4byte_offset1(capsys):
@@ -100,7 +100,7 @@ def test_captured_utf8_4byte_offset1(capsys):
100100
m.captured_output_default(msg)
101101
stdout, stderr = capsys.readouterr()
102102
assert stdout == msg
103-
assert stderr == ""
103+
assert not stderr
104104

105105

106106
def test_captured_utf8_4byte_offset2(capsys):
@@ -110,7 +110,7 @@ def test_captured_utf8_4byte_offset2(capsys):
110110
m.captured_output_default(msg)
111111
stdout, stderr = capsys.readouterr()
112112
assert stdout == msg
113-
assert stderr == ""
113+
assert not stderr
114114

115115

116116
def test_captured_utf8_4byte_offset3(capsys):
@@ -120,15 +120,15 @@ def test_captured_utf8_4byte_offset3(capsys):
120120
m.captured_output_default(msg)
121121
stdout, stderr = capsys.readouterr()
122122
assert stdout == msg
123-
assert stderr == ""
123+
assert not stderr
124124

125125

126126
def test_guard_capture(capsys):
127127
msg = "I've been redirected to Python, I hope!"
128128
m.guard_output(msg)
129129
stdout, stderr = capsys.readouterr()
130130
assert stdout == msg
131-
assert stderr == ""
131+
assert not stderr
132132

133133

134134
def test_series_captured(capture):
@@ -145,7 +145,7 @@ def test_flush(capfd):
145145
with m.ostream_redirect():
146146
m.noisy_function(msg, flush=False)
147147
stdout, stderr = capfd.readouterr()
148-
assert stdout == ""
148+
assert not stdout
149149

150150
m.noisy_function(msg2, flush=True)
151151
stdout, stderr = capfd.readouterr()
@@ -164,15 +164,15 @@ def test_not_captured(capfd):
164164
m.raw_output(msg)
165165
stdout, stderr = capfd.readouterr()
166166
assert stdout == msg
167-
assert stderr == ""
168-
assert stream.getvalue() == ""
167+
assert not stderr
168+
assert not stream.getvalue()
169169

170170
stream = StringIO()
171171
with redirect_stdout(stream):
172172
m.captured_output(msg)
173173
stdout, stderr = capfd.readouterr()
174-
assert stdout == ""
175-
assert stderr == ""
174+
assert not stdout
175+
assert not stderr
176176
assert stream.getvalue() == msg
177177

178178

@@ -182,16 +182,16 @@ def test_err(capfd):
182182
with redirect_stderr(stream):
183183
m.raw_err(msg)
184184
stdout, stderr = capfd.readouterr()
185-
assert stdout == ""
185+
assert not stdout
186186
assert stderr == msg
187-
assert stream.getvalue() == ""
187+
assert not stream.getvalue()
188188

189189
stream = StringIO()
190190
with redirect_stderr(stream):
191191
m.captured_err(msg)
192192
stdout, stderr = capfd.readouterr()
193-
assert stdout == ""
194-
assert stderr == ""
193+
assert not stdout
194+
assert not stderr
195195
assert stream.getvalue() == msg
196196

197197

@@ -221,21 +221,21 @@ def test_redirect(capfd):
221221
m.raw_output(msg)
222222
stdout, stderr = capfd.readouterr()
223223
assert stdout == msg
224-
assert stream.getvalue() == ""
224+
assert not stream.getvalue()
225225

226226
stream = StringIO()
227227
with redirect_stdout(stream), m.ostream_redirect():
228228
m.raw_output(msg)
229229
stdout, stderr = capfd.readouterr()
230-
assert stdout == ""
230+
assert not stdout
231231
assert stream.getvalue() == msg
232232

233233
stream = StringIO()
234234
with redirect_stdout(stream):
235235
m.raw_output(msg)
236236
stdout, stderr = capfd.readouterr()
237237
assert stdout == msg
238-
assert stream.getvalue() == ""
238+
assert not stream.getvalue()
239239

240240

241241
def test_redirect_err(capfd):
@@ -248,7 +248,7 @@ def test_redirect_err(capfd):
248248
m.raw_err(msg2)
249249
stdout, stderr = capfd.readouterr()
250250
assert stdout == msg
251-
assert stderr == ""
251+
assert not stderr
252252
assert stream.getvalue() == msg2
253253

254254

@@ -262,8 +262,8 @@ def test_redirect_both(capfd):
262262
m.raw_output(msg)
263263
m.raw_err(msg2)
264264
stdout, stderr = capfd.readouterr()
265-
assert stdout == ""
266-
assert stderr == ""
265+
assert not stdout
266+
assert not stderr
267267
assert stream.getvalue() == msg
268268
assert stream2.getvalue() == msg2
269269

tests/test_stl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def test_issue_1561():
367367
"""check fix for issue #1561"""
368368
bar = m.Issue1561Outer()
369369
bar.list = [m.Issue1561Inner("bar")]
370-
bar.list
370+
assert bar.list
371371
assert bar.list[0].data == "bar"
372372

373373

tools/pybind11Common.cmake

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Adds the following targets::
55
pybind11::pybind11 - link to headers and pybind11
66
pybind11::module - Adds module links
77
pybind11::embed - Adds embed links
8-
pybind11::lto - Link time optimizations (manual selection)
9-
pybind11::thin_lto - Link time optimizations (manual selection)
8+
pybind11::lto - Link time optimizations (only if CMAKE_INTERPROCEDURAL_OPTIMIZATION is not set)
9+
pybind11::thin_lto - Link time optimizations (only if CMAKE_INTERPROCEDURAL_OPTIMIZATION is not set)
1010
pybind11::python_link_helper - Adds link to Python libraries
1111
pybind11::windows_extras - MSVC bigobj and mp for building multithreaded
1212
pybind11::opt_size - avoid optimizations that increase code size
@@ -20,7 +20,7 @@ Adds the following functions::
2020

2121
# CMake 3.10 has an include_guard command, but we can't use that yet
2222
# include_guard(global) (pre-CMake 3.10)
23-
if(TARGET pybind11::lto)
23+
if(TARGET pybind11::pybind11)
2424
return()
2525
endif()
2626

@@ -372,11 +372,13 @@ function(_pybind11_generate_lto target prefer_thin_lto)
372372
endif()
373373
endfunction()
374374

375-
add_library(pybind11::lto IMPORTED INTERFACE ${optional_global})
376-
_pybind11_generate_lto(pybind11::lto FALSE)
375+
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
376+
add_library(pybind11::lto IMPORTED INTERFACE ${optional_global})
377+
_pybind11_generate_lto(pybind11::lto FALSE)
377378

378-
add_library(pybind11::thin_lto IMPORTED INTERFACE ${optional_global})
379-
_pybind11_generate_lto(pybind11::thin_lto TRUE)
379+
add_library(pybind11::thin_lto IMPORTED INTERFACE ${optional_global})
380+
_pybind11_generate_lto(pybind11::thin_lto TRUE)
381+
endif()
380382

381383
# ---------------------- pybind11_strip -----------------------------
382384

0 commit comments

Comments
 (0)