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