Skip to content

Commit 3efe9d4

Browse files
authored
chore: update to black 23 (#4482)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 44e9368 commit 3efe9d4

11 files changed

+13
-30
lines changed

.pre-commit-config.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -54,40 +54,40 @@ repos:
5454

5555
# Black, the code formatter, natively supports pre-commit
5656
- repo: https://github.com/psf/black
57-
rev: "22.12.0" # Keep in sync with blacken-docs
57+
rev: "23.1.0" # Keep in sync with blacken-docs
5858
hooks:
5959
- id: black
6060

6161
# Also code format the docs
6262
- repo: https://github.com/asottile/blacken-docs
63-
rev: "v1.12.1"
63+
rev: "1.13.0"
6464
hooks:
6565
- id: blacken-docs
6666
additional_dependencies:
67-
- black==22.10.0 # keep in sync with black hook
67+
- black==23.1.0 # keep in sync with black hook
6868

6969
# Changes tabs to spaces
7070
- repo: https://github.com/Lucas-C/pre-commit-hooks
71-
rev: "v1.3.1"
71+
rev: "v1.4.2"
7272
hooks:
7373
- id: remove-tabs
7474

7575
- repo: https://github.com/sirosen/texthooks
76-
rev: "0.4.0"
76+
rev: "0.5.0"
7777
hooks:
7878
- id: fix-ligatures
7979
- id: fix-smartquotes
8080

8181
# Autoremoves unused imports
8282
- repo: https://github.com/hadialqattan/pycln
83-
rev: "v2.1.2"
83+
rev: "v2.1.3"
8484
hooks:
8585
- id: pycln
8686
stages: [manual]
8787

8888
# Checking for common mistakes
8989
- repo: https://github.com/pre-commit/pygrep-hooks
90-
rev: "v1.9.0"
90+
rev: "v1.10.0"
9191
hooks:
9292
- id: python-check-blanket-noqa
9393
- id: python-check-blanket-type-ignore
@@ -116,7 +116,7 @@ repos:
116116

117117
# PyLint has native support - not always usable, but works for us
118118
- repo: https://github.com/PyCQA/pylint
119-
rev: "v2.15.9"
119+
rev: "v2.16.0"
120120
hooks:
121121
- id: pylint
122122
files: ^pybind11
@@ -175,7 +175,7 @@ repos:
175175

176176
# Clang format the codebase automatically
177177
- repo: https://github.com/pre-commit/mirrors-clang-format
178-
rev: "v15.0.6"
178+
rev: "v15.0.7"
179179
hooks:
180180
- id: clang-format
181181
types_or: [c++, c, cuda]

docs/conf.py

-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ def clean_up(app, exception):
358358

359359

360360
def setup(app):
361-
362361
# Add hook for building doxygen xml when needed
363362
app.connect("builder-inited", generate_doxygen_xml)
364363

pybind11/__main__.py

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def print_includes() -> None:
2424

2525

2626
def main() -> None:
27-
2827
parser = argparse.ArgumentParser()
2928
parser.add_argument(
3029
"--includes",

pybind11/setup_helpers.py

-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def _add_ldflags(self, flags: List[str]) -> None:
118118
self.extra_link_args[:0] = flags
119119

120120
def __init__(self, *args: Any, **kwargs: Any) -> None:
121-
122121
self._cxx_level = 0
123122
cxx_std = kwargs.pop("cxx_std", 0)
124123

@@ -174,7 +173,6 @@ def cxx_std(self) -> int:
174173

175174
@cxx_std.setter
176175
def cxx_std(self, level: int) -> None:
177-
178176
if self._cxx_level:
179177
warnings.warn("You cannot safely change the cxx_level after setting it!")
180178

@@ -439,7 +437,6 @@ def compile_function(
439437
extra_postargs: Optional[List[str]] = None,
440438
depends: Optional[List[str]] = None,
441439
) -> Any:
442-
443440
# These lines are directly from distutils.ccompiler.CCompiler
444441
macros, objects, extra_postargs, pp_opts, build = compiler._setup_compile( # type: ignore[attr-defined]
445442
output_dir, macros, include_dirs, sources, depends, extra_postargs

tests/extra_python_package/test_files.py

-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def normalize_line_endings(value: bytes) -> bytes:
135135

136136

137137
def test_build_sdist(monkeypatch, tmpdir):
138-
139138
monkeypatch.chdir(MAIN_DIR)
140139

141140
subprocess.run(
@@ -186,7 +185,6 @@ def test_build_sdist(monkeypatch, tmpdir):
186185

187186

188187
def test_build_global_dist(monkeypatch, tmpdir):
189-
190188
monkeypatch.chdir(MAIN_DIR)
191189
monkeypatch.setenv("PYBIND11_GLOBAL_SDIST", "1")
192190
subprocess.run(

tests/test_chrono.py

-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
def test_chrono_system_clock():
10-
1110
# Get the time from both c++ and datetime
1211
date0 = datetime.datetime.today()
1312
date1 = m.test_chrono1()
@@ -122,7 +121,6 @@ def test_chrono_system_clock_roundtrip_time(time1, tz, monkeypatch):
122121

123122

124123
def test_chrono_duration_roundtrip():
125-
126124
# Get the difference between two times (a timedelta)
127125
date1 = datetime.datetime.today()
128126
date2 = datetime.datetime.today()
@@ -143,7 +141,6 @@ def test_chrono_duration_roundtrip():
143141

144142

145143
def test_chrono_duration_subtraction_equivalence():
146-
147144
date1 = datetime.datetime.today()
148145
date2 = datetime.datetime.today()
149146

@@ -154,7 +151,6 @@ def test_chrono_duration_subtraction_equivalence():
154151

155152

156153
def test_chrono_duration_subtraction_equivalence_date():
157-
158154
date1 = datetime.date.today()
159155
date2 = datetime.date.today()
160156

tests/test_class.py

-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ def test_inheritance(msg):
185185

186186

187187
def test_inheritance_init(msg):
188-
189188
# Single base
190189
class Python(m.Pet):
191190
def __init__(self):

tests/test_custom_type_casters.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def test_noconvert_args(msg):
9494

9595
def test_custom_caster_destruction():
9696
"""Tests that returning a pointer to a type that gets converted with a custom type caster gets
97-
destroyed when the function has py::return_value_policy::take_ownership policy applied."""
97+
destroyed when the function has py::return_value_policy::take_ownership policy applied.
98+
"""
9899

99100
cstats = m.destruction_tester_cstats()
100101
# This one *doesn't* have take_ownership: the pointer should be used but not destroyed:

tests/test_eigen_tensor.py

-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def assert_equal_tensor_ref(mat, writeable=True, modified=None):
5959
@pytest.mark.parametrize("m", submodules)
6060
@pytest.mark.parametrize("member_name", ["member", "member_view"])
6161
def test_reference_internal(m, member_name):
62-
6362
if not hasattr(sys, "getrefcount"):
6463
pytest.skip("No reference counting")
6564
foo = m.CustomExample()
@@ -108,7 +107,6 @@ def test_convert_tensor_to_py(m, func_name):
108107

109108
@pytest.mark.parametrize("m", submodules)
110109
def test_bad_cpp_to_python_casts(m):
111-
112110
with pytest.raises(
113111
RuntimeError, match="Cannot use reference internal when there is no parent"
114112
):
@@ -131,7 +129,6 @@ def test_bad_cpp_to_python_casts(m):
131129

132130
@pytest.mark.parametrize("m", submodules)
133131
def test_bad_python_to_cpp_casts(m):
134-
135132
with pytest.raises(
136133
TypeError, match=r"^round_trip_tensor\(\): incompatible function arguments"
137134
):
@@ -194,7 +191,6 @@ def test_bad_python_to_cpp_casts(m):
194191

195192
@pytest.mark.parametrize("m", submodules)
196193
def test_references_actually_refer(m):
197-
198194
a = m.reference_tensor()
199195
temp = a[indices]
200196
a[indices] = 100
@@ -211,7 +207,6 @@ def test_references_actually_refer(m):
211207

212208
@pytest.mark.parametrize("m", submodules)
213209
def test_round_trip(m):
214-
215210
assert_equal_tensor_ref(m.round_trip_tensor(tensor_ref))
216211

217212
with pytest.raises(TypeError, match="^Cannot cast array data from"):
@@ -260,7 +255,6 @@ def test_round_trip(m):
260255

261256
@pytest.mark.parametrize("m", submodules)
262257
def test_round_trip_references_actually_refer(m):
263-
264258
# Need to create a copy that matches the type on the C side
265259
copy = np.array(tensor_ref, dtype=np.float64, order=m.needed_options)
266260
a = m.round_trip_view_tensor(copy)

tests/test_local_bindings.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ def test_stl_bind_global():
130130
def test_mixed_local_global():
131131
"""Local types take precedence over globally registered types: a module with a `module_local`
132132
type can be registered even if the type is already registered globally. With the module,
133-
casting will go to the local type; outside the module casting goes to the global type."""
133+
casting will go to the local type; outside the module casting goes to the global type.
134+
"""
134135
import pybind11_cross_module_tests as cm
135136

136137
m.register_mixed_global()

tests/test_operator_overloading.py

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def test_nested():
130130

131131

132132
def test_overriding_eq_reset_hash():
133-
134133
assert m.Comparable(15) is not m.Comparable(15)
135134
assert m.Comparable(15) == m.Comparable(15)
136135

0 commit comments

Comments
 (0)