mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-27 15:42:01 +00:00
style: pre-commit fixes
This commit is contained in:
parent
8cf1cdbc96
commit
9d107d2f75
@ -1570,9 +1570,11 @@ class argument_loader {
|
|||||||
using indices = make_index_sequence<sizeof...(Args)>;
|
using indices = make_index_sequence<sizeof...(Args)>;
|
||||||
|
|
||||||
template <typename Arg>
|
template <typename Arg>
|
||||||
using argument_is_args = all_of<std::is_base_of<args, intrinsic_t<Arg>>, negation<std::is_pointer<Arg>>>;
|
using argument_is_args
|
||||||
|
= all_of<std::is_base_of<args, intrinsic_t<Arg>>, negation<std::is_pointer<Arg>>>;
|
||||||
template <typename Arg>
|
template <typename Arg>
|
||||||
using argument_is_kwargs = all_of<std::is_base_of<kwargs, intrinsic_t<Arg>>, negation<std::is_pointer<Arg>>>;
|
using argument_is_kwargs
|
||||||
|
= all_of<std::is_base_of<kwargs, intrinsic_t<Arg>>, negation<std::is_pointer<Arg>>>;
|
||||||
// Get kwargs argument position, or -1 if not present:
|
// Get kwargs argument position, or -1 if not present:
|
||||||
static constexpr auto kwargs_pos = constexpr_last<argument_is_kwargs, Args...>();
|
static constexpr auto kwargs_pos = constexpr_last<argument_is_kwargs, Args...>();
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ struct handle_type_name<KWArgsSubclass> {
|
|||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct type_caster<MoveOrCopyInt> {
|
struct type_caster<MoveOrCopyInt> {
|
||||||
PYBIND11_TYPE_CASTER(MoveOrCopyInt*, const_name("MoveOrCopyInt"));
|
PYBIND11_TYPE_CASTER(MoveOrCopyInt *, const_name("MoveOrCopyInt"));
|
||||||
bool load(handle src, bool) {
|
bool load(handle src, bool) {
|
||||||
auto as_class = MoveOrCopyInt(src.cast<int>());
|
auto as_class = MoveOrCopyInt(src.cast<int>());
|
||||||
value = &as_class;
|
value = &as_class;
|
||||||
@ -389,9 +389,10 @@ TEST_SUBMODULE(kwargs_and_defaults, m) {
|
|||||||
return py::make_tuple(args, kwargs);
|
return py::make_tuple(args, kwargs);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test that support for args and kwargs subclasses skips checking arguments passed in as pointers
|
// Test that support for args and kwargs subclasses skips checking arguments passed in as
|
||||||
|
// pointers
|
||||||
m.def("args_kwargs_subclass_function_with_pointer_arg",
|
m.def("args_kwargs_subclass_function_with_pointer_arg",
|
||||||
[](MoveOrCopyInt* pointer, const ArgsSubclass &args, const KWArgsSubclass &kwargs) {
|
[](MoveOrCopyInt *pointer, const ArgsSubclass &args, const KWArgsSubclass &kwargs) {
|
||||||
return py::make_tuple(pointer->value, args, kwargs);
|
return py::make_tuple(pointer->value, args, kwargs);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,11 @@ def test_arg_and_kwargs():
|
|||||||
kwargs = {"arg3": "a3", "arg4": 4}
|
kwargs = {"arg3": "a3", "arg4": 4}
|
||||||
assert m.args_kwargs_function(*args, **kwargs) == (args, kwargs)
|
assert m.args_kwargs_function(*args, **kwargs) == (args, kwargs)
|
||||||
assert m.args_kwargs_subclass_function(*args, **kwargs) == (args, kwargs)
|
assert m.args_kwargs_subclass_function(*args, **kwargs) == (args, kwargs)
|
||||||
assert m.args_kwargs_subclass_function_with_pointer_arg(10, *args, **kwargs) == (10, args, kwargs)
|
assert m.args_kwargs_subclass_function_with_pointer_arg(10, *args, **kwargs) == (
|
||||||
|
10,
|
||||||
|
args,
|
||||||
|
kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_mixed_args_and_kwargs(msg):
|
def test_mixed_args_and_kwargs(msg):
|
||||||
@ -429,7 +433,9 @@ def test_args_refcount():
|
|||||||
)
|
)
|
||||||
assert refcount(myval) == expected
|
assert refcount(myval) == expected
|
||||||
|
|
||||||
assert m.args_kwargs_subclass_function_with_pointer_arg(7, 8, myval, a=1, b=myval) == (
|
assert m.args_kwargs_subclass_function_with_pointer_arg(
|
||||||
|
7, 8, myval, a=1, b=myval
|
||||||
|
) == (
|
||||||
7,
|
7,
|
||||||
(8, myval),
|
(8, myval),
|
||||||
{"a": 1, "b": myval},
|
{"a": 1, "b": myval},
|
||||||
|
Loading…
Reference in New Issue
Block a user