mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-20 15:40:45 +00:00
ruff auto-fixes (to be reviewed)
This commit is contained in:
parent
e0029bd3b0
commit
cee7cec5f4
@ -16,7 +16,7 @@ def test_atyp_constructors():
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"rtrn_f, expected",
|
||||
("rtrn_f", "expected"),
|
||||
[
|
||||
(m.rtrn_valu, "rtrn_valu(_MvCtor)*_MvCtor"),
|
||||
(m.rtrn_rref, "rtrn_rref(_MvCtor)*_MvCtor"),
|
||||
@ -37,7 +37,7 @@ def test_cast(rtrn_f, expected):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pass_f, mtxt, expected",
|
||||
("pass_f", "mtxt", "expected"),
|
||||
[
|
||||
(m.pass_valu, "Valu", "pass_valu:Valu(_MvCtor)*_CpCtor"),
|
||||
(m.pass_cref, "Cref", "pass_cref:Cref(_MvCtor)*_MvCtor"),
|
||||
@ -55,7 +55,7 @@ def test_load_with_mtxt(pass_f, mtxt, expected):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pass_f, rtrn_f, expected",
|
||||
("pass_f", "rtrn_f", "expected"),
|
||||
[
|
||||
(m.pass_udmp, m.rtrn_udmp, "pass_udmp:rtrn_udmp"),
|
||||
(m.pass_udcp, m.rtrn_udcp, "pass_udcp:rtrn_udcp"),
|
||||
@ -66,7 +66,7 @@ def test_load_with_rtrn_f(pass_f, rtrn_f, expected):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pass_f, rtrn_f, expected",
|
||||
("pass_f", "rtrn_f", "expected"),
|
||||
[
|
||||
(m.pass_uqmp, m.rtrn_uqmp, "pass_uqmp:rtrn_uqmp"),
|
||||
(m.pass_uqcp, m.rtrn_uqcp, "pass_uqcp:rtrn_uqcp"),
|
||||
@ -85,7 +85,7 @@ def test_pass_unique_ptr_disowns(pass_f, rtrn_f, expected):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pass_f, rtrn_f",
|
||||
("pass_f", "rtrn_f"),
|
||||
[
|
||||
(m.pass_uqmp, m.rtrn_uqmp),
|
||||
(m.pass_uqcp, m.rtrn_uqcp),
|
||||
@ -120,7 +120,7 @@ def test_unique_ptr_roundtrip(num_round_trips=1000):
|
||||
# This currently fails, because a unique_ptr is always loaded by value
|
||||
# due to pybind11/detail/smart_holder_type_casters.h:689
|
||||
# I think, we need to provide more cast operators.
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.skip()
|
||||
def test_unique_ptr_cref_roundtrip(num_round_trips=1000):
|
||||
orig = m.atyp("passenger")
|
||||
id_orig = id(orig)
|
||||
@ -133,7 +133,7 @@ def test_unique_ptr_cref_roundtrip(num_round_trips=1000):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pass_f, rtrn_f, moved_out, moved_in",
|
||||
("pass_f", "rtrn_f", "moved_out", "moved_in"),
|
||||
[
|
||||
(m.uconsumer.pass_valu, m.uconsumer.rtrn_valu, True, True),
|
||||
(m.uconsumer.pass_rref, m.uconsumer.rtrn_valu, True, True),
|
||||
|
@ -202,7 +202,7 @@ DISOWN_CLS_I_J_V_LIST = [
|
||||
|
||||
|
||||
@pytest.mark.xfail("env.PYPY", strict=False)
|
||||
@pytest.mark.parametrize("cls, i, j, v", DISOWN_CLS_I_J_V_LIST)
|
||||
@pytest.mark.parametrize(("cls", "i", "j", "v"), DISOWN_CLS_I_J_V_LIST)
|
||||
def test_disown_base1_first(cls, i, j, v):
|
||||
obj = cls(i, j)
|
||||
assert obj.foo() == i
|
||||
@ -216,7 +216,7 @@ def test_disown_base1_first(cls, i, j, v):
|
||||
|
||||
|
||||
@pytest.mark.xfail("env.PYPY", strict=False)
|
||||
@pytest.mark.parametrize("cls, i, j, v", DISOWN_CLS_I_J_V_LIST)
|
||||
@pytest.mark.parametrize(("cls", "i", "j", "v"), DISOWN_CLS_I_J_V_LIST)
|
||||
def test_disown_base2_first(cls, i, j, v):
|
||||
obj = cls(i, j)
|
||||
assert obj.bar() == j
|
||||
@ -231,7 +231,7 @@ def test_disown_base2_first(cls, i, j, v):
|
||||
|
||||
@pytest.mark.xfail("env.PYPY", strict=False)
|
||||
@pytest.mark.parametrize(
|
||||
"cls, j, v",
|
||||
("cls", "j", "v"),
|
||||
[
|
||||
(MI6, 12, 1),
|
||||
(MI7, 13, 4),
|
||||
|
@ -19,7 +19,7 @@ def test_atyp_factories():
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"init_args, expected",
|
||||
("init_args", "expected"),
|
||||
[
|
||||
((3,), 300),
|
||||
((5, 7), 570),
|
||||
@ -31,7 +31,7 @@ def test_with_alias_success(init_args, expected):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"num_init_args, smart_ptr",
|
||||
("num_init_args", "smart_ptr"),
|
||||
[
|
||||
(4, "std::unique_ptr"),
|
||||
(5, "std::shared_ptr"),
|
||||
|
@ -60,7 +60,7 @@ def test_shp(m_attr):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"field_type, num_default, outer_type",
|
||||
("field_type", "num_default", "outer_type"),
|
||||
[
|
||||
(m.ClassicField, -88, m.ClassicOuter),
|
||||
(m.Field, -99, m.Outer),
|
||||
@ -113,7 +113,7 @@ def test_uqp(m_attr_readwrite, msg):
|
||||
# an attribute of the member. After the attribute was accessed, the Python object
|
||||
# is disowned back to the C++ member unique_ptr.
|
||||
# Productizing this POC is left for a future separate PR, as needed.
|
||||
class unique_ptr_field_proxy_poc: # noqa: N801
|
||||
class unique_ptr_field_proxy_poc:
|
||||
def __init__(self, obj, field_name):
|
||||
object.__setattr__(self, "__obj", obj)
|
||||
object.__setattr__(self, "__field_name", field_name)
|
||||
|
@ -7,7 +7,7 @@ class PyDrvd0(m.Abase0):
|
||||
def __init__(self, val):
|
||||
super().__init__(val)
|
||||
|
||||
def Add(self, other_val): # noqa: N802
|
||||
def Add(self, other_val):
|
||||
return self.Get() * 100 + other_val
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ class PyDrvd1(m.Abase1):
|
||||
def __init__(self, val):
|
||||
super().__init__(val)
|
||||
|
||||
def Add(self, other_val): # noqa: N802
|
||||
def Add(self, other_val):
|
||||
return self.Get() * 200 + other_val
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ def test_m_big5():
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"action_id, expected_history",
|
||||
("action_id", "expected_history"),
|
||||
[
|
||||
(0, "Seed_CpCtor"),
|
||||
(1, "Seed_MvCtor"),
|
||||
|
@ -20,7 +20,7 @@ class PyCppDerived(m.CppDerived):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ctor, expected",
|
||||
("ctor", "expected"),
|
||||
[
|
||||
(m.Base, 101),
|
||||
(PyBase, 323),
|
||||
@ -35,7 +35,7 @@ def test_base_get(ctor, expected):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ctor, expected",
|
||||
("ctor", "expected"),
|
||||
[
|
||||
(m.Base, 4101),
|
||||
(PyBase, 4323),
|
||||
@ -50,7 +50,7 @@ def test_get_from_cpp_plainc_ptr(ctor, expected):
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ctor, expected",
|
||||
("ctor", "expected"),
|
||||
[
|
||||
(m.Base, 5101),
|
||||
(PyBase, 5323),
|
||||
|
@ -7,7 +7,7 @@ class Valid:
|
||||
def __init__(self):
|
||||
self.capsule_generated = False
|
||||
|
||||
def as_pybind11_tests_class_sh_void_ptr_capsule_Valid(self): # noqa: N802
|
||||
def as_pybind11_tests_class_sh_void_ptr_capsule_Valid(self):
|
||||
self.capsule_generated = True
|
||||
return m.create_test_void_ptr_capsule()
|
||||
|
||||
@ -21,7 +21,7 @@ class NoCapsuleReturned:
|
||||
def __init__(self):
|
||||
self.capsule_generated = False
|
||||
|
||||
def as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned( # noqa: N802
|
||||
def as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned(
|
||||
self,
|
||||
):
|
||||
pass
|
||||
@ -31,13 +31,13 @@ class AsAnotherObject:
|
||||
def __init__(self):
|
||||
self.capsule_generated = False
|
||||
|
||||
def as_pybind11_tests_class_sh_void_ptr_capsule_Valid(self): # noqa: N802
|
||||
def as_pybind11_tests_class_sh_void_ptr_capsule_Valid(self):
|
||||
self.capsule_generated = True
|
||||
return m.create_test_void_ptr_capsule()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ctor, caller, expected, capsule_generated",
|
||||
("ctor", "caller", "expected", "capsule_generated"),
|
||||
[
|
||||
(Valid, m.get_from_valid_capsule, 1, True),
|
||||
(AsAnotherObject, m.get_from_valid_capsule, 1, True),
|
||||
@ -50,7 +50,7 @@ def test_valid_as_void_ptr_capsule_function(ctor, caller, expected, capsule_gene
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ctor, caller, expected, capsule_generated",
|
||||
("ctor", "caller", "expected", "capsule_generated"),
|
||||
[
|
||||
(NoConversion, m.get_from_no_conversion_capsule, 2, False),
|
||||
(NoCapsuleReturned, m.get_from_no_capsule_returned, 3, False),
|
||||
@ -66,7 +66,7 @@ def test_invalid_as_void_ptr_capsule_function(
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ctor, caller, pointer_type, capsule_generated",
|
||||
("ctor", "caller", "pointer_type", "capsule_generated"),
|
||||
[
|
||||
(AsAnotherObject, m.get_from_shared_ptr_valid_capsule, "shared_ptr", True),
|
||||
(AsAnotherObject, m.get_from_unique_ptr_valid_capsule, "unique_ptr", True),
|
||||
|
@ -41,7 +41,7 @@ else:
|
||||
|
||||
|
||||
@pytest.mark.skipif(m.block_descr_offset is None, reason="Not enabled.")
|
||||
@pytest.mark.parametrize("block_name, expected_text_line", block_parametrize)
|
||||
@pytest.mark.parametrize(("block_name", "expected_text_line"), block_parametrize)
|
||||
def test_block(block_name, expected_text_line):
|
||||
offset = getattr(m, f"{block_name}_offset")
|
||||
for ix, (expected_text, expected_line) in enumerate(expected_text_line):
|
||||
|
@ -18,7 +18,7 @@ def test_return_pointer():
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"func, expected",
|
||||
("func", "expected"),
|
||||
[
|
||||
(m.return_value, "value(_MvCtor)*_MvCtor"),
|
||||
(m.return_pointer, "pointer"),
|
||||
|
Loading…
Reference in New Issue
Block a user