From 67930635c4547caa6e9279da18fd825955eb2eac Mon Sep 17 00:00:00 2001 From: Taiju Yamada Date: Mon, 22 May 2023 17:43:00 +0900 Subject: [PATCH 01/11] use Annotated for std::array docstring --- include/pybind11/stl.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 84c5171081..9e3f14c4c0 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -273,11 +273,10 @@ struct array_caster { } PYBIND11_TYPE_CASTER(ArrayType, - const_name("List[") + value_conv::name + const_name("Annotated[List[") + value_conv::name + const_name(const_name(""), - const_name("[") + const_name() - + const_name("]")) - + const_name("]")); + const_name("], ") + const_name() + + const_name("]"))); }; template From 40b206c37893fa436d26fbe3e31172c1d48b7326 Mon Sep 17 00:00:00 2001 From: Taiju Yamada Date: Mon, 22 May 2023 17:46:05 +0900 Subject: [PATCH 02/11] add tests --- tests/test_stl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_stl.py b/tests/test_stl.py index 2d9dcc89f1..123858ff62 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -39,8 +39,8 @@ 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, 2]" + assert doc(m.load_array) == "load_array(arg0: Annotated[List, 2]) -> bool" def test_valarray(doc): From 40a6af2ecb0f2190bad3bece1f90d999b13d631d Mon Sep 17 00:00:00 2001 From: Taiju Yamada Date: Mon, 22 May 2023 23:50:30 +0900 Subject: [PATCH 03/11] fix test --- tests/test_stl.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_stl.py b/tests/test_stl.py index 123858ff62..04bc91db53 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -39,8 +39,8 @@ def test_array(doc): assert m.load_array(lst) assert m.load_array(tuple(lst)) - assert doc(m.cast_array) == "cast_array() -> Annotated[List, 2]" - assert doc(m.load_array) == "load_array(arg0: Annotated[List, 2]) -> bool" + assert doc(m.cast_array) == "cast_array() -> Annotated[List[int], 2]" + assert doc(m.load_array) == "load_array(arg0: Annotated[List[int], 2]) -> bool" def test_valarray(doc): @@ -50,8 +50,8 @@ def test_valarray(doc): assert m.load_valarray(lst) assert m.load_valarray(tuple(lst)) - assert doc(m.cast_valarray) == "cast_valarray() -> List[int]" - assert doc(m.load_valarray) == "load_valarray(arg0: List[int]) -> bool" + assert doc(m.cast_valarray) == "cast_valarray() -> Annotated[List[int], 3]" + assert doc(m.load_valarray) == "load_valarray(arg0: Annotated[List[int], 3]) -> bool" def test_map(doc): From d2c778606d392d6df99fbf4f31df1f60b73e245f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 May 2023 14:51:13 +0000 Subject: [PATCH 04/11] style: pre-commit fixes --- tests/test_stl.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_stl.py b/tests/test_stl.py index 04bc91db53..7b5052c64b 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -51,7 +51,9 @@ def test_valarray(doc): assert m.load_valarray(tuple(lst)) assert doc(m.cast_valarray) == "cast_valarray() -> Annotated[List[int], 3]" - assert doc(m.load_valarray) == "load_valarray(arg0: Annotated[List[int], 3]) -> bool" + assert ( + doc(m.load_valarray) == "load_valarray(arg0: Annotated[List[int], 3]) -> bool" + ) def test_map(doc): From afbfa1963279b481f0fe21bd0b802a83a6ee8ada Mon Sep 17 00:00:00 2001 From: Taiju Yamada Date: Tue, 23 May 2023 00:54:21 +0900 Subject: [PATCH 05/11] fix valarray annotation --- include/pybind11/stl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 9e3f14c4c0..99719e9901 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -273,10 +273,10 @@ struct array_caster { } PYBIND11_TYPE_CASTER(ArrayType, - const_name("Annotated[List[") + value_conv::name + const_name(const_name(""), const_name("Annotated[")) + + const_name("List[") + value_conv::name + const_name("]") + const_name(const_name(""), - const_name("], ") + const_name() - + const_name("]"))); + const_name(", ") + const_name() + const_name("]"))); }; template From b2108834d71159912318525f953bfc8d8e92b7be Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 May 2023 15:54:58 +0000 Subject: [PATCH 06/11] style: pre-commit fixes --- include/pybind11/stl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 99719e9901..96fdfc455a 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -276,7 +276,8 @@ struct array_caster { const_name(const_name(""), const_name("Annotated[")) + const_name("List[") + value_conv::name + const_name("]") + const_name(const_name(""), - const_name(", ") + const_name() + const_name("]"))); + const_name(", ") + const_name() + + const_name("]"))); }; template From 4c1918cebd054ece871de1101b190f1ffc2f1ad8 Mon Sep 17 00:00:00 2001 From: Taiju Yamada Date: Tue, 23 May 2023 00:57:28 +0900 Subject: [PATCH 07/11] refix test --- tests/test_stl.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/test_stl.py b/tests/test_stl.py index 7b5052c64b..71f7e5a38e 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -50,10 +50,8 @@ def test_valarray(doc): assert m.load_valarray(lst) assert m.load_valarray(tuple(lst)) - assert doc(m.cast_valarray) == "cast_valarray() -> Annotated[List[int], 3]" - assert ( - doc(m.load_valarray) == "load_valarray(arg0: Annotated[List[int], 3]) -> bool" - ) + assert doc(m.cast_valarray) == "cast_valarray() -> List[int]" + assert doc(m.load_valarray) == "load_valarray(arg0: List[int]) -> bool" def test_map(doc): From dfde1442e2d35c2ee230cef22892be351eda5ccb Mon Sep 17 00:00:00 2001 From: Taiju Yamada Date: Tue, 23 May 2023 08:28:27 +0900 Subject: [PATCH 08/11] add FixedSize --- include/pybind11/stl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 96fdfc455a..8285ef5a4b 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -276,8 +276,8 @@ struct array_caster { const_name(const_name(""), const_name("Annotated[")) + const_name("List[") + value_conv::name + const_name("]") + const_name(const_name(""), - const_name(", ") + const_name() - + const_name("]"))); + const_name(", FixedSize(") + const_name() + + const_name(")]"))); }; template From 3fc47aa08c9f3e219da3a6601fb492bd3eaa5216 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 May 2023 23:29:11 +0000 Subject: [PATCH 09/11] style: pre-commit fixes --- include/pybind11/stl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 8285ef5a4b..f39f44f7c9 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -276,8 +276,8 @@ struct array_caster { const_name(const_name(""), const_name("Annotated[")) + const_name("List[") + value_conv::name + const_name("]") + const_name(const_name(""), - const_name(", FixedSize(") + const_name() - + const_name(")]"))); + const_name(", FixedSize(") + + const_name() + const_name(")]"))); }; template From 4ca4b3b1b37aef2d0d51d96a8db05870be1811c7 Mon Sep 17 00:00:00 2001 From: "T.Yamada" Date: Wed, 24 May 2023 07:56:39 +0900 Subject: [PATCH 10/11] Update test_stl.py --- tests/test_stl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_stl.py b/tests/test_stl.py index 71f7e5a38e..45d4a423e3 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -39,8 +39,8 @@ def test_array(doc): assert m.load_array(lst) assert m.load_array(tuple(lst)) - assert doc(m.cast_array) == "cast_array() -> Annotated[List[int], 2]" - assert doc(m.load_array) == "load_array(arg0: Annotated[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): From 591927120d799ebfa6ae3a022e54e0ad6f7dbec3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 May 2023 22:57:05 +0000 Subject: [PATCH 11/11] style: pre-commit fixes --- tests/test_stl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_stl.py b/tests/test_stl.py index 45d4a423e3..8a614f8b87 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -40,7 +40,10 @@ def test_array(doc): assert m.load_array(tuple(lst)) 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" + assert ( + doc(m.load_array) + == "load_array(arg0: Annotated[List[int], FixedSize(2)]) -> bool" + ) def test_valarray(doc):