Skip to content

Commit 90dfe5b

Browse files
authored
chore: some minor cleanups (wjakob#4)
* docs: fix spelling * chore: clean up some minor stylistic issues * fix: always include build-backend when using pyproject.toml * Update tests/test_classes.py
1 parent e664962 commit 90dfe5b

8 files changed

+21
-22
lines changed

include/nanobind/nb_class.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@ enum class type_flags : uint32_t {
2323
/// Is this a python type that extends a bound C++ type?
2424
is_python_type = (1 << 4),
2525

26-
/// Is the 'scope' field of the type_data struture set?
26+
/// Is the 'scope' field of the type_data structure set?
2727
has_scope = (1 << 5),
2828

29-
/// Is the 'doc' field of the type_data struture set?
29+
/// Is the 'doc' field of the type_data structure set?
3030
has_doc = (1 << 6),
3131

32-
/// Is the 'base' field of the type_data struture set?
32+
/// Is the 'base' field of the type_data structure set?
3333
has_base = (1 << 7),
3434

35-
/// Is the 'base_py' field of the type_data struture set?
35+
/// Is the 'base_py' field of the type_data structure set?
3636
has_base_py = (1 << 8),
3737

38-
/// Is the 'destruct' field of the type_data struture set?
38+
/// Is the 'destruct' field of the type_data structure set?
3939
has_destruct = (1 << 9),
4040

41-
/// Is the 'copy' field of the type_data struture set?
41+
/// Is the 'copy' field of the type_data structure set?
4242
has_copy = (1 << 10),
4343

44-
/// Is the 'move' field of the type_data struture set?
44+
/// Is the 'move' field of the type_data structure set?
4545
has_move = (1 << 11),
4646

4747
/// Internal: does the type maintain a list of implicit conversions?

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[build-system]
22
requires = ["setuptools>=42", "wheel", "scikit-build", "cmake>=3.17", "ninja"]
3+
build-backend = "setuptools.build_meta"
4+
35

46
[tool.pytest.ini_options]
57
testpaths = [ "tests" ]

setup.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
from setuptools import setup
42
import re
53
import os
@@ -13,8 +11,8 @@
1311
matches = dict(VERSION_REGEX.findall(f.read()))
1412
nanobind_version = "{MAJOR}.{MINOR}.{PATCH}".format(**matches)
1513

16-
long_description = \
17-
'''_nanobind_ is a small binding library that exposes C++ types in Python and
14+
long_description = '''\
15+
_nanobind_ is a small binding library that exposes C++ types in Python and
1816
vice versa. It is reminiscent of
1917
_[Boost.Python](https://www.boost.org/doc/libs/1_64_0/libs/python/doc/html)_
2018
and _[pybind11](http://github.com/pybind/pybind11)_ and uses near-identical
@@ -28,7 +26,7 @@
2826
try:
2927
os.symlink(os.path.join(dirname, name),
3028
os.path.join(dirname, 'src', 'nanobind', name))
31-
except FileExistsError:
29+
except FileExistsError:
3230
pass
3331

3432
setup(

src/nb_func.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ static PyObject *nb_func_vectorcall_simple(PyObject *self,
730730
static PyObject *nb_meth_descr_get(PyObject *self, PyObject *inst, PyObject *) {
731731
if (inst) {
732732
/* Return a classic bound method. This should be avoidable
733-
in most cases via the 'CALL_METHOD' opcode and vector calls. PyTest
733+
in most cases via the 'CALL_METHOD' opcode and vector calls. Pytest
734734
rewrites the bytecode in a way that breaks this optimization :-/ */
735735
return PyMethod_New(self, inst);
736736
} else {

tests/test_classes.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def test06_reference_internal(clean):
129129

130130
def test07_big():
131131
x = [t.Big() for i in range(1024)]
132-
x = [t.BigAligned() for i in range(1024)]
132+
x2 = [t.BigAligned() for i in range(1024)]
133133

134134

135135
def test08_inheritance():
@@ -151,20 +151,20 @@ def test09_method_vectorcall():
151151
def f(a, b, c, d, e):
152152
out.append((a, b, c, d, e))
153153

154-
class my_class:
154+
class MyClass:
155155
def f(self, a, b, c, d, e):
156156
self.out = ((a, b, c, d, e))
157157

158158
t.call_function(f)
159159

160-
i = my_class()
160+
i = MyClass()
161161
t.call_method(i)
162162
assert out == [(1, 2, "hello", True, 4)]
163163
assert i.out == (1, 2, "hello", True, 4)
164164

165165

166166
def test10_trampoline(clean):
167-
for i in range(10):
167+
for _ in range(10):
168168
class Dachshund(t.Animal):
169169
def __init__(self):
170170
super().__init__()
@@ -174,7 +174,7 @@ def what(self):
174174
return "yap"
175175

176176
d = Dachshund()
177-
for i in range(10):
177+
for _ in range(10):
178178
assert t.go(d) == 'Dachshund says yap'
179179

180180
a = 0

tests/test_enum.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import test_enum_ext as t
22
import pytest
3-
import gc
43

54
def test01_unsigned_enum():
65
assert repr(t.Enum.A) == 'Enum.A'

tests/test_functions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def test01_capture():
55
# Functions with and without capture object of different sizes
6-
assert t.test_01() == None
6+
assert t.test_01() is None
77
assert t.test_02(5, 3) == 2
88
assert t.test_03(5, 3) == 44
99
assert t.test_04() == 60
@@ -127,7 +127,7 @@ def test13_call_guard():
127127
assert t.call_guard_value() == 0
128128
assert t.test_call_guard() == 1
129129
assert t.call_guard_value() == 2
130-
assert t.test_release_gil() == False
130+
assert not t.test_release_gil()
131131

132132
def test14_print(capsys):
133133
t.test_print()

tests/test_holders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test07_uniqueptr_passthrough(clean):
139139
t.reset()
140140

141141
with pytest.warns(RuntimeWarning, match=r'nanobind::detail::nb_relinquish_ownership()'):
142-
with pytest.raises(TypeError) as excinfo:
142+
with pytest.raises(TypeError):
143143
assert t.passthrough_unique(t.Example(1)).value == 1
144144
assert t.passthrough_unique_2(t.Example(1)).value == 1
145145
assert t.stats() == (2, 2)

0 commit comments

Comments
 (0)