mirror of
https://github.com/pybind/pybind11.git
synced 2024-12-04 10:57:11 +00:00
style: pre-commit fixes
This commit is contained in:
parent
445fee025c
commit
1ad0e6ebfa
@ -185,7 +185,6 @@ public:
|
|||||||
/// Get or set the object's type_params, i.e. ``obj.__type_params__``.
|
/// Get or set the object's type_params, i.e. ``obj.__type_params__``.
|
||||||
str_attr_accessor type_params() const;
|
str_attr_accessor type_params() const;
|
||||||
|
|
||||||
|
|
||||||
/// Return the object's current reference count
|
/// Return the object's current reference count
|
||||||
ssize_t ref_count() const {
|
ssize_t ref_count() const {
|
||||||
#ifdef PYPY_VERSION
|
#ifdef PYPY_VERSION
|
||||||
|
@ -124,13 +124,11 @@ class TypeVar : public object {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class TypeVarObject : public object {
|
class TypeVarObject : public object {
|
||||||
PYBIND11_OBJECT_DEFAULT(TypeVarObject, object, PyObject_Type)
|
PYBIND11_OBJECT_DEFAULT(TypeVarObject, object, PyObject_Type)
|
||||||
using object::object;
|
using object::object;
|
||||||
TypeVarObject(const char *name){
|
TypeVarObject(const char *name) {
|
||||||
attr("__name__") = name;
|
attr("__name__") = name;
|
||||||
attr("__bound__") = make_caster<T>;
|
attr("__bound__") = make_caster<T>;
|
||||||
attr("__constraints__") = pybind11::make_tuple();
|
attr("__constraints__") = pybind11::make_tuple();
|
||||||
@ -145,7 +143,7 @@ class TypeVarObject : public object {
|
|||||||
class ParamSpec : public object {
|
class ParamSpec : public object {
|
||||||
PYBIND11_OBJECT_DEFAULT(ParamSpec, object, PyObject_Type)
|
PYBIND11_OBJECT_DEFAULT(ParamSpec, object, PyObject_Type)
|
||||||
using object::object;
|
using object::object;
|
||||||
ParamSpec(const char *name){
|
ParamSpec(const char *name) {
|
||||||
attr("__name__") = name;
|
attr("__name__") = name;
|
||||||
attr("__bound__") = pybind11::none();
|
attr("__bound__") = pybind11::none();
|
||||||
}
|
}
|
||||||
@ -154,9 +152,7 @@ class ParamSpec : public object {
|
|||||||
class TypeVarTuple : public object {
|
class TypeVarTuple : public object {
|
||||||
PYBIND11_OBJECT_DEFAULT(TypeVarTuple, object, PyObject_Type)
|
PYBIND11_OBJECT_DEFAULT(TypeVarTuple, object, PyObject_Type)
|
||||||
using object::object;
|
using object::object;
|
||||||
TypeVarTuple(const char *name){
|
TypeVarTuple(const char *name) { attr("__name__") = name; }
|
||||||
attr("__name__") = name;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_END(typing)
|
PYBIND11_NAMESPACE_END(typing)
|
||||||
|
@ -925,14 +925,16 @@ TEST_SUBMODULE(pytypes, m) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct TypeVarObject {};
|
struct TypeVarObject {};
|
||||||
py::class_<TypeVarObject>(m, "TypeVarObject").type_params() = py::make_tuple(py::typing::TypeVarObject<int>("T"));
|
py::class_<TypeVarObject>(m, "TypeVarObject").type_params()
|
||||||
|
= py::make_tuple(py::typing::TypeVarObject<int>("T"));
|
||||||
|
|
||||||
struct ParamSpec {};
|
struct ParamSpec {};
|
||||||
py::class_<ParamSpec>(m, "ParamSpec").type_params() = py::make_tuple(py::typing::ParamSpec("P"));
|
py::class_<ParamSpec>(m, "ParamSpec").type_params()
|
||||||
|
= py::make_tuple(py::typing::ParamSpec("P"));
|
||||||
|
|
||||||
struct TypeVarTuple {};
|
struct TypeVarTuple {};
|
||||||
py::class_<TypeVarTuple>(m, "TypeVarTuple").type_params() = py::make_tuple(py::typing::TypeVarTuple("T"));
|
py::class_<TypeVarTuple>(m, "TypeVarTuple").type_params()
|
||||||
|
= py::make_tuple(py::typing::TypeVarTuple("T"));
|
||||||
|
|
||||||
struct NoTypeParams {};
|
struct NoTypeParams {};
|
||||||
struct TypeParams {};
|
struct TypeParams {};
|
||||||
|
@ -1049,6 +1049,7 @@ def test_typevar(doc):
|
|||||||
|
|
||||||
assert doc(m.annotate_object_to_T) == "annotate_object_to_T(arg0: object) -> T"
|
assert doc(m.annotate_object_to_T) == "annotate_object_to_T(arg0: object) -> T"
|
||||||
|
|
||||||
|
|
||||||
def test_typevar_object():
|
def test_typevar_object():
|
||||||
assert len(m.TypeVarObject.__type_params__) == 1
|
assert len(m.TypeVarObject.__type_params__) == 1
|
||||||
type_var = m.TypeVarObject.__type_params__[0]
|
type_var = m.TypeVarObject.__type_params__[0]
|
||||||
@ -1056,6 +1057,7 @@ def test_typevar_object():
|
|||||||
assert type_var.__bound__ == int
|
assert type_var.__bound__ == int
|
||||||
assert type_var.__constraints__ == ()
|
assert type_var.__constraints__ == ()
|
||||||
|
|
||||||
|
|
||||||
def test_param_spec():
|
def test_param_spec():
|
||||||
assert len(m.ParamSpec.__type_params__) == 1
|
assert len(m.ParamSpec.__type_params__) == 1
|
||||||
param_spec = m.ParamSpec.__type_params__[0]
|
param_spec = m.ParamSpec.__type_params__[0]
|
||||||
@ -1063,6 +1065,7 @@ def test_param_spec():
|
|||||||
assert param_spec.__name__ == "P"
|
assert param_spec.__name__ == "P"
|
||||||
assert param_spec.__bound__ == None
|
assert param_spec.__bound__ == None
|
||||||
|
|
||||||
|
|
||||||
def test_type_var_tuple():
|
def test_type_var_tuple():
|
||||||
assert len(m.TypeVarTuple.__type_params__) == 1
|
assert len(m.TypeVarTuple.__type_params__) == 1
|
||||||
type_var_tuple = m.TypeVarTuple.__type_params__[0]
|
type_var_tuple = m.TypeVarTuple.__type_params__[0]
|
||||||
@ -1071,6 +1074,7 @@ def test_type_var_tuple():
|
|||||||
with pytest.raises(AttributeError):
|
with pytest.raises(AttributeError):
|
||||||
param_spec.__bound__
|
param_spec.__bound__
|
||||||
|
|
||||||
|
|
||||||
def test_type_params():
|
def test_type_params():
|
||||||
assert m.NoTypeParams.__type_params__ == ()
|
assert m.NoTypeParams.__type_params__ == ()
|
||||||
assert m.TypeParams.__type_params__ == ("foo", 3, None)
|
assert m.TypeParams.__type_params__ == ("foo", 3, None)
|
||||||
|
Loading…
Reference in New Issue
Block a user