Skip to content

Commit 7861dcf

Browse files
committed
fix: Render py::object as Any
1 parent d8b91c6 commit 7861dcf

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

include/pybind11/cast.h

+4
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,10 @@ struct handle_type_name<function> {
906906
static constexpr auto name = const_name("Callable");
907907
};
908908
template <>
909+
struct handle_type_name<object> {
910+
static constexpr auto name = const_name("Any");
911+
};
912+
template <>
909913
struct handle_type_name<handle> {
910914
static constexpr auto name = handle_type_name<object>::name;
911915
};

tests/test_callbacks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,5 @@ def test_custom_func2():
221221
def test_callback_docstring():
222222
assert (
223223
m.test_tuple_unpacking.__doc__.strip()
224-
== "test_tuple_unpacking(arg0: Callable) -> object"
224+
== "test_tuple_unpacking(arg0: Callable) -> Any"
225225
)

tests/test_factory_constructors.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_init_factory_signature(msg):
7777
1. m.factory_constructors.TestFactory1(arg0: m.factory_constructors.tag.unique_ptr_tag, arg1: int)
7878
2. m.factory_constructors.TestFactory1(arg0: str)
7979
3. m.factory_constructors.TestFactory1(arg0: m.factory_constructors.tag.pointer_tag)
80-
4. m.factory_constructors.TestFactory1(arg0: object, arg1: int, arg2: object)
80+
4. m.factory_constructors.TestFactory1(arg0: Any, arg1: int, arg2: Any)
8181
8282
Invoked with: 'invalid', 'constructor', 'arguments'
8383
"""
@@ -95,7 +95,7 @@ def test_init_factory_signature(msg):
9595
9696
3. __init__(self: m.factory_constructors.TestFactory1, arg0: m.factory_constructors.tag.pointer_tag) -> None
9797
98-
4. __init__(self: m.factory_constructors.TestFactory1, arg0: object, arg1: int, arg2: object) -> None
98+
4. __init__(self: m.factory_constructors.TestFactory1, arg0: Any, arg1: int, arg2: Any) -> None
9999
"""
100100
)
101101

tests/test_numpy_vectorize.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def test_docs(doc):
148148
assert (
149149
doc(m.vectorized_func)
150150
== """
151-
vectorized_func(arg0: numpy.ndarray[numpy.int32], arg1: numpy.ndarray[numpy.float32], arg2: numpy.ndarray[numpy.float64]) -> object
151+
vectorized_func(arg0: numpy.ndarray[numpy.int32], arg1: numpy.ndarray[numpy.float32], arg2: numpy.ndarray[numpy.float64]) -> Any
152152
"""
153153
)
154154

@@ -218,7 +218,7 @@ def test_passthrough_arguments(doc):
218218
"arg6: numpy.ndarray[numpy.float64]",
219219
]
220220
)
221-
+ ") -> object"
221+
+ ") -> Any"
222222
)
223223

224224
b = np.array([[10, 20, 30]], dtype="float64")

0 commit comments

Comments
 (0)