mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-21 20:55:11 +00:00
Use annotated for array (#4679)
* use Annotated for std::array docstring * add tests * fix test * style: pre-commit fixes * fix valarray annotation * style: pre-commit fixes * refix test * add FixedSize * style: pre-commit fixes * Update test_stl.py * style: pre-commit fixes --------- Co-authored-by: Taiju Yamada <taiju.yamada@mujin.co.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
8e1f9d5c40
commit
d0232b119f
@ -273,11 +273,11 @@ public:
|
||||
}
|
||||
|
||||
PYBIND11_TYPE_CASTER(ArrayType,
|
||||
const_name("List[") + value_conv::name
|
||||
const_name<Resizable>(const_name(""), const_name("Annotated["))
|
||||
+ const_name("List[") + value_conv::name + const_name("]")
|
||||
+ const_name<Resizable>(const_name(""),
|
||||
const_name("[") + const_name<Size>()
|
||||
+ const_name("]"))
|
||||
+ const_name("]"));
|
||||
const_name(", FixedSize(")
|
||||
+ const_name<Size>() + const_name(")]")));
|
||||
};
|
||||
|
||||
template <typename Type, size_t Size>
|
||||
|
@ -39,8 +39,11 @@ def test_array(doc):
|
||||
assert m.load_array(lst)
|
||||
assert m.load_array(tuple(lst))
|
||||
|
||||
assert doc(m.cast_array) == "cast_array() -> List[int[2]]"
|
||||
assert doc(m.load_array) == "load_array(arg0: List[int[2]]) -> bool"
|
||||
assert doc(m.cast_array) == "cast_array() -> Annotated[List[int], FixedSize(2)]"
|
||||
assert (
|
||||
doc(m.load_array)
|
||||
== "load_array(arg0: Annotated[List[int], FixedSize(2)]) -> bool"
|
||||
)
|
||||
|
||||
|
||||
def test_valarray(doc):
|
||||
|
Loading…
Reference in New Issue
Block a user