diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3544b82..f108f7c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,8 @@ jobs: strategy: fail-fast: false matrix: - pybind11-branch: [ "master" ] + pybind11-branch: + - "master" python: - "3.12" - "3.11" @@ -51,6 +52,9 @@ jobs: - "3.9" - "3.8" - "3.7" + include: + - pybind11-branch: "v2.9" + python: "3.12" steps: - uses: actions/checkout@v3 @@ -74,7 +78,7 @@ jobs: - name: Install demo module shell: bash - run: ./tests/install-demo-module.sh --pybind11-branch "${{ matrix.pybind11-branch }}" + run: ./tests/install-demo-module.sh --pybind11-branch "${{ matrix.pybind11-branch }}" --eigen-branch "master" - name: Check stubs generation shell: bash diff --git a/pybind11_stubgen/parser/mixins/fix.py b/pybind11_stubgen/parser/mixins/fix.py index acbd3d0..37b476f 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -355,6 +355,7 @@ class FixTypingTypeNames(IParser): map( Identifier, [ + "buffer", "Buffer", ], ) diff --git a/tests/install-demo-module.sh b/tests/install-demo-module.sh index 3b1f35d..a9c60c1 100755 --- a/tests/install-demo-module.sh +++ b/tests/install-demo-module.sh @@ -2,6 +2,8 @@ set -e +PYTHON_EXECUTABLE=$(python -c 'import sys; print(sys.executable)') + function parse_args() { CLEAR='\033[0m' @@ -13,17 +15,20 @@ function parse_args() { fi echo "Usage: $0 --pybind11-branch PYBIND11_BRANCH" echo " --pybind11-branch name of pybind11 branch" + echo " --eigen-branch name of eigen branch" exit 1 } # parse params while [[ "$#" > 0 ]]; do case $1 in --pybind11-branch) PYBIND11_BRANCH="$2"; shift;shift;; + --eigen-branch) EIGEN_BRANCH="$2"; shift;shift;; *) usage "Unknown parameter passed: $1"; shift; shift;; esac; done # verify params if [ -z "$PYBIND11_BRANCH" ]; then usage "PYBIND11_BRANCH is not set"; fi; + if [ -z "$EIGEN_BRANCH" ]; then usage "EIGEN_BRANCH is not set"; fi; TESTS_ROOT="$(readlink -m "$(dirname "$0")")" PROJECT_ROOT="${TESTS_ROOT}/.." @@ -39,7 +44,7 @@ clone_eigen() { if [ ! -d "${EXTERNAL_DIR}/eigen" ]; then git clone \ --depth 1 \ - --branch master \ + --branch "${EIGEN_BRANCH}" \ --single-branch \ https://gitlab.com/libeigen/eigen.git \ "${EXTERNAL_DIR}/eigen" @@ -65,7 +70,10 @@ install_eigen() { } install_pybind11() { - cmake -S "${EXTERNAL_DIR}/pybind11" -B "${BUILD_ROOT}/pybind11" + cmake \ + -S "${EXTERNAL_DIR}/pybind11" \ + -B "${BUILD_ROOT}/pybind11"\ + -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} cmake --install "${BUILD_ROOT}/pybind11" \ --prefix "${INSTALL_PREFIX}" } @@ -80,8 +88,8 @@ install_demo() { install_pydemo() { ( export CMAKE_PREFIX_PATH="$(readlink -m "${INSTALL_PREFIX}")"; - export CMAKE_ARGS="CMAKE_CXX_STANDARD=17"; - pip install "${TESTS_ROOT}/py-demo" + export CMAKE_ARGS="-DCMAKE_CXX_STANDARD=17"; + pip install --force-reinstall "${TESTS_ROOT}/py-demo" ) } diff --git a/tests/py-demo/bindings/src/modules.h b/tests/py-demo/bindings/src/modules.h index fc4a20b..2380621 100644 --- a/tests/py-demo/bindings/src/modules.h +++ b/tests/py-demo/bindings/src/modules.h @@ -2,19 +2,21 @@ #include #include "opaque_types.h" +#define PYBIND11_VERSION_AT_LEAST(x,y) (PYBIND11_VERSION_MAJOR>x || ( PYBIND11_VERSION_MAJOR>=x && PYBIND11_VERSION_MINOR>=y )) + namespace py = pybind11; -void bind_aliases_module(py::module_&& m); -void bind_classes_module(py::module_&& m); -void bind_eigen_module(py::module_&& m); -void bind_enum_module(py::module_&& m); -void bind_flawed_bindings_module(py::module_&& m); -void bind_functions_module(py::module_&& m); -void bind_issues_module(py::module_&& m); -void bind_methods_module(py::module_&& m); -void bind_numpy_module(py::module_&& m); -void bind_properties_module(py::module_&& m); -void bind_stl_module(py::module_&& m); -void bind_stl_bind_module(py::module_&& m); -void bind_typing_module(py::module_&& m); -void bind_values_module(py::module_&& m); +void bind_aliases_module(py::module&& m); +void bind_classes_module(py::module&& m); +void bind_eigen_module(py::module&& m); +void bind_enum_module(py::module&& m); +void bind_flawed_bindings_module(py::module&& m); +void bind_functions_module(py::module&& m); +void bind_issues_module(py::module&& m); +void bind_methods_module(py::module&& m); +void bind_numpy_module(py::module&& m); +void bind_properties_module(py::module&& m); +void bind_stl_module(py::module&& m); +void bind_stl_bind_module(py::module&& m); +void bind_typing_module(py::module&& m); +void bind_values_module(py::module&& m); diff --git a/tests/py-demo/bindings/src/modules/aliases.cpp b/tests/py-demo/bindings/src/modules/aliases.cpp index 8abafc5..36ff62c 100644 --- a/tests/py-demo/bindings/src/modules/aliases.cpp +++ b/tests/py-demo/bindings/src/modules/aliases.cpp @@ -18,7 +18,7 @@ namespace { }; } // namespace -void bind_aliases_module(py::module_ &&m) { +void bind_aliases_module(py::module &&m) { { // python module as value auto &&pyDummy = py::class_(m, "Dummy"); diff --git a/tests/py-demo/bindings/src/modules/classes.cpp b/tests/py-demo/bindings/src/modules/classes.cpp index e72231c..347d9c1 100644 --- a/tests/py-demo/bindings/src/modules/classes.cpp +++ b/tests/py-demo/bindings/src/modules/classes.cpp @@ -4,7 +4,7 @@ #include #include -void bind_classes_module(py::module_&&m) { +void bind_classes_module(py::module&&m) { { auto pyOuter = py::class_(m, "Outer"); diff --git a/tests/py-demo/bindings/src/modules/eigen.cpp b/tests/py-demo/bindings/src/modules/eigen.cpp index cf2e16b..cdc89a5 100644 --- a/tests/py-demo/bindings/src/modules/eigen.cpp +++ b/tests/py-demo/bindings/src/modules/eigen.cpp @@ -3,7 +3,7 @@ #include #include -void bind_eigen_module(py::module_ &&m) { +void bind_eigen_module(py::module &&m) { using DenseMatrixR = Eigen::Matrix; using DenseMatrixC = Eigen::Matrix; diff --git a/tests/py-demo/bindings/src/modules/enum.cpp b/tests/py-demo/bindings/src/modules/enum.cpp index 67769f9..a3532c5 100644 --- a/tests/py-demo/bindings/src/modules/enum.cpp +++ b/tests/py-demo/bindings/src/modules/enum.cpp @@ -2,7 +2,7 @@ #include -void bind_enum_module(py::module_&&m) { +void bind_enum_module(py::module&&m) { py::enum_(m, "ConsoleForegroundColor") .value("Green", demo::sublibA::ConsoleForegroundColor::Green) diff --git a/tests/py-demo/bindings/src/modules/flawed_bindings.cpp b/tests/py-demo/bindings/src/modules/flawed_bindings.cpp index 5464d0b..7abd863 100644 --- a/tests/py-demo/bindings/src/modules/flawed_bindings.cpp +++ b/tests/py-demo/bindings/src/modules/flawed_bindings.cpp @@ -8,7 +8,7 @@ enum Enum { ONE = 1, TWO = 2 }; } // namespace -void bind_flawed_bindings_module(py::module_&& m) { +void bind_flawed_bindings_module(py::module&& m) { // This submodule will have C++ signatures in python docstrings to emulate // common mistakes in using pybind11 m.def("get_unbound_type", [] { return Unbound{}; }); diff --git a/tests/py-demo/bindings/src/modules/functions.cpp b/tests/py-demo/bindings/src/modules/functions.cpp index 5c297f3..0acff77 100644 --- a/tests/py-demo/bindings/src/modules/functions.cpp +++ b/tests/py-demo/bindings/src/modules/functions.cpp @@ -1,7 +1,10 @@ +#include "modules.h" + +#if PYBIND11_VERSION_MAJOR == 2 && PYBIND11_VERSION_MINOR >= 11 #include -#include +#endif -#include "modules.h" +#include #include @@ -15,7 +18,7 @@ namespace { }; }; // namespace -void bind_functions_module(py::module_ &&m) { +void bind_functions_module(py::module &&m) { m.def("add", demo::sublibA::add); { @@ -35,6 +38,7 @@ void bind_functions_module(py::module_ &&m) { m.def("func_w_anon_args", [](int x, int y, int z) {}); +#if PYBIND11_VERSION_AT_LEAST(2, 6) m.def( "func_w_named_pos_args", [](int x, int y, int z) {}, @@ -61,15 +65,19 @@ void bind_functions_module(py::module_ &&m) { py::arg("j"), py::kw_only(), py::arg("k")); - +#endif m.def("accept_callable", [](py::function &callable) { return callable(); }); m.def("accept_py_object", [](py::object &object) { return py::str(object); }); m.def("accept_py_handle", [](py::handle &handle) { return py::str(handle); }); +#if PYBIND11_VERSION_AT_LEAST(2, 12) m.def("accept_annotated_callable", [](py::typing::Callable &callable) { return callable(13, 42); }); +#endif +#if PYBIND11_VERSION_AT_LEAST(2, 10) m.def("accept_frozenset", [](const py::frozenset &) {}); +#endif m.def("accept_set", [](const py::set &) {}); m.def("default_int_arg", [](int n) {}, py::arg("n") = 5); diff --git a/tests/py-demo/bindings/src/modules/issues.cpp b/tests/py-demo/bindings/src/modules/issues.cpp index 3c19581..3b56fbf 100644 --- a/tests/py-demo/bindings/src/modules/issues.cpp +++ b/tests/py-demo/bindings/src/modules/issues.cpp @@ -1,6 +1,6 @@ #include "modules.h" -void bind_issues_module(py::module_ &&m) { +void bind_issues_module(py::module &&m) { { // https://github.com/sizmailov/pybind11-stubgen/issues/51 m.def( diff --git a/tests/py-demo/bindings/src/modules/methods.cpp b/tests/py-demo/bindings/src/modules/methods.cpp index a5b67ce..27eaaa2 100644 --- a/tests/py-demo/bindings/src/modules/methods.cpp +++ b/tests/py-demo/bindings/src/modules/methods.cpp @@ -8,7 +8,7 @@ struct Dummy { } // namespace -void bind_methods_module(py::module_&& m) { +void bind_methods_module(py::module&& m) { auto &&pyDummy = py::class_(m, "Dummy"); pyDummy.def_static("def_static", &Dummy::static_method); diff --git a/tests/py-demo/bindings/src/modules/numpy.cpp b/tests/py-demo/bindings/src/modules/numpy.cpp index 64fac48..2b9d068 100644 --- a/tests/py-demo/bindings/src/modules/numpy.cpp +++ b/tests/py-demo/bindings/src/modules/numpy.cpp @@ -2,7 +2,7 @@ #include "modules.h" -void bind_numpy_module(py::module_&&m) { +void bind_numpy_module(py::module&&m) { { m.def("get_ndarray_int", [] { return py::array_t{}; }); m.def("get_ndarray_float64", [] { return py::array_t{}; }); diff --git a/tests/py-demo/bindings/src/modules/properties.cpp b/tests/py-demo/bindings/src/modules/properties.cpp index 5e83672..f8cef7d 100644 --- a/tests/py-demo/bindings/src/modules/properties.cpp +++ b/tests/py-demo/bindings/src/modules/properties.cpp @@ -28,7 +28,7 @@ int WithPropDoc::static_value = 0; int WithGetterSetterDoc::static_value = 0; int WithPropAndGetterSetterDoc::static_value = 0; -void bind_properties_module(py::module_ &&m) { +void bind_properties_module(py::module &&m) { { auto &&pyDummy = py::class_(m, "WithoutDoc", "No user docstring provided"); diff --git a/tests/py-demo/bindings/src/modules/stl.cpp b/tests/py-demo/bindings/src/modules/stl.cpp index 9790612..af33d10 100644 --- a/tests/py-demo/bindings/src/modules/stl.cpp +++ b/tests/py-demo/bindings/src/modules/stl.cpp @@ -7,7 +7,7 @@ #include #include -void bind_stl_module(py::module_ &&m) { +void bind_stl_module(py::module &&m) { m.def("std_map", [] { return std::map>{}; }); m.def("std_vector", [] { return std::vector>{}; }); m.def("std_array", [](const std::array &a) { return a; }); diff --git a/tests/py-demo/bindings/src/modules/stl_bind.cpp b/tests/py-demo/bindings/src/modules/stl_bind.cpp index e9ecf29..cdd5c1e 100644 --- a/tests/py-demo/bindings/src/modules/stl_bind.cpp +++ b/tests/py-demo/bindings/src/modules/stl_bind.cpp @@ -5,7 +5,7 @@ #include #include -void bind_stl_bind_module(py::module_&&m) { +void bind_stl_bind_module(py::module&&m) { py::bind_vector>>(m, "VectorPairStringDouble"); py::bind_map>>(m, "MapStringComplex"); diff --git a/tests/py-demo/bindings/src/modules/typing.cpp b/tests/py-demo/bindings/src/modules/typing.cpp index d957d65..7cd38c4 100644 --- a/tests/py-demo/bindings/src/modules/typing.cpp +++ b/tests/py-demo/bindings/src/modules/typing.cpp @@ -1,6 +1,6 @@ #include "modules.h" -void bind_typing_module(py::module_ &&m) { +void bind_typing_module(py::module &&m) { m.def("get_sequence", [](py::sequence &seq) { return seq; }); m.def("get_buffer", [](py::buffer &buffer) { return buffer; }); } diff --git a/tests/py-demo/bindings/src/modules/values.cpp b/tests/py-demo/bindings/src/modules/values.cpp index a088c20..98ae806 100644 --- a/tests/py-demo/bindings/src/modules/values.cpp +++ b/tests/py-demo/bindings/src/modules/values.cpp @@ -9,7 +9,7 @@ class Dummy {}; class Foo {}; } // namespace -void bind_values_module(py::module_ &&m) { +void bind_values_module(py::module &&m) { { // python module as value auto &&pyDummy = py::class_(m, "Dummy"); diff --git a/tests/py-demo/bindings/src/opaque_types.h b/tests/py-demo/bindings/src/opaque_types.h index 6901ef8..ca3a687 100644 --- a/tests/py-demo/bindings/src/opaque_types.h +++ b/tests/py-demo/bindings/src/opaque_types.h @@ -4,5 +4,7 @@ #include #include -PYBIND11_MAKE_OPAQUE(std::map>); -PYBIND11_MAKE_OPAQUE(std::vector>); +using MapStringComplex = std::map>; +using VectorPairStringDouble = std::vector>; +PYBIND11_MAKE_OPAQUE(MapStringComplex); +PYBIND11_MAKE_OPAQUE(VectorPairStringDouble); diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/__init__.pyi new file mode 100644 index 0000000..305256f --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/__init__.pyi @@ -0,0 +1,41 @@ +from __future__ import annotations + +from demo._bindings import ( + aliases, + classes, + eigen, + enum, + flawed_bindings, + functions, + issues, + methods, + numpy, + properties, + stl, + stl_bind, + typing, + values, +) + +from . import _bindings, core, pure_python + +__all__ = [ + "aliases", + "classes", + "core", + "eigen", + "enum", + "flawed_bindings", + "functions", + "issues", + "methods", + "numpy", + "properties", + "pure_python", + "stl", + "stl_bind", + "typing", + "values", + "version", +] +version: str = "0.0.0" diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/__init__.pyi new file mode 100644 index 0000000..3fc3fe3 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/__init__.pyi @@ -0,0 +1,35 @@ +from __future__ import annotations + +from . import ( + aliases, + classes, + eigen, + enum, + flawed_bindings, + functions, + issues, + methods, + numpy, + properties, + stl, + stl_bind, + typing, + values, +) + +__all__ = [ + "aliases", + "classes", + "eigen", + "enum", + "flawed_bindings", + "functions", + "issues", + "methods", + "numpy", + "properties", + "stl", + "stl_bind", + "typing", + "values", +] diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/__init__.pyi new file mode 100644 index 0000000..dd127b9 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/__init__.pyi @@ -0,0 +1,51 @@ +from __future__ import annotations + +import typing + +import numpy +from numpy import random + +import demo._bindings.enum +from demo._bindings.aliases.foreign_method_arg import Bar2 as foreign_type_alias +from demo._bindings.aliases.foreign_return import get_foo as foreign_class_alias + +from . import ( + foreign_arg, + foreign_attr, + foreign_class_member, + foreign_method_arg, + foreign_method_return, + foreign_return, +) + +__all__ = [ + "Color", + "Dummy", + "foreign_arg", + "foreign_attr", + "foreign_class_alias", + "foreign_class_member", + "foreign_enum_default", + "foreign_method_arg", + "foreign_method_return", + "foreign_return", + "foreign_type_alias", + "func", + "local_func_alias", + "local_type_alias", + "random", +] + +class Color: + pass + +class Dummy: + linalg = numpy.linalg + +def foreign_enum_default( + color: typing.Any = demo._bindings.enum.ConsoleForegroundColor.Blue, +) -> None: ... +def func(arg0: int) -> int: ... + +local_func_alias = func +local_type_alias = Color diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_arg.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_arg.pyi new file mode 100644 index 0000000..10e0d3a --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_arg.pyi @@ -0,0 +1,7 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__ = ["set_foo"] + +def set_foo(arg0: demo._bindings.classes.Foo) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_attr.pyi new file mode 100644 index 0000000..efb53a7 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_attr.pyi @@ -0,0 +1,6 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__ = ["value"] +value: demo._bindings.classes.Foo # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_class_member.pyi new file mode 100644 index 0000000..24968c9 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_class_member.pyi @@ -0,0 +1,12 @@ +from __future__ import annotations + +import typing + +import demo._bindings.classes + +__all__ = ["Bar1"] + +class Bar1: + foo: typing.ClassVar[ + demo._bindings.classes.Foo + ] # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_method_arg.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_method_arg.pyi new file mode 100644 index 0000000..5476b3e --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_method_arg.pyi @@ -0,0 +1,8 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__ = ["Bar2"] + +class Bar2: + def set_foo(self) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_method_return.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_method_return.pyi new file mode 100644 index 0000000..fe89d6d --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_method_return.pyi @@ -0,0 +1,9 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__ = ["Bar3"] + +class Bar3: + @staticmethod + def get_foo() -> demo._bindings.classes.Foo: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_return.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_return.pyi new file mode 100644 index 0000000..94f5fd3 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/aliases/foreign_return.pyi @@ -0,0 +1,7 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__ = ["get_foo"] + +def get_foo() -> demo._bindings.classes.Foo: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/classes.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/classes.pyi new file mode 100644 index 0000000..4a3b7bd --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/classes.pyi @@ -0,0 +1,57 @@ +from __future__ import annotations + +import typing + +__all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] + +class Base: + class Inner: + pass + name: str + +class CppException(Exception): + pass + +class Derived(Base): + count: int + +class Foo: + class FooChild: + def __init__(self) -> None: ... + def g(self) -> None: ... + + def __init__(self) -> None: ... + def f(self) -> None: ... + +class Outer: + class Inner: + class NestedEnum: + """ + Members: + + ONE + + TWO + """ + + ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = + TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = + __members__: typing.ClassVar[ + dict[str, Outer.Inner.NestedEnum] + ] # value = {'ONE': , 'TWO': } + def __eq__(self, other: typing.Any) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __init__(self, value: int) -> None: ... + def __int__(self) -> int: ... + def __ne__(self, other: typing.Any) -> bool: ... + def __repr__(self) -> str: ... + def __setstate__(self, state: int) -> None: ... + def __str__(self) -> str: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + value: Outer.Inner.NestedEnum + inner: Outer.Inner diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/eigen.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/eigen.pyi new file mode 100644 index 0000000..4ab61fe --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/eigen.pyi @@ -0,0 +1,100 @@ +from __future__ import annotations + +import typing + +import numpy +import pybind11_stubgen.typing_ext +import scipy.sparse + +__all__ = [ + "accept_matrix_int", + "accept_vector_float64", + "dense_matrix_c", + "dense_matrix_r", + "fixed_mutator_a", + "fixed_mutator_c", + "fixed_mutator_r", + "four_col_matrix_r", + "four_row_matrix_r", + "get_matrix_int", + "get_vector_float64", + "sparse_matrix_c", + "sparse_matrix_r", +] + +def accept_matrix_int( + arg0: typing.Annotated[ + numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) + ] +) -> None: ... +def accept_vector_float64( + arg0: typing.Annotated[ + numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) + ] +) -> None: ... +def dense_matrix_c( + arg0: typing.Annotated[ + numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") + ] +) -> typing.Annotated[ + numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") +]: ... +def dense_matrix_r( + arg0: typing.Annotated[ + numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") + ] +) -> typing.Annotated[ + numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") +]: ... +def fixed_mutator_a( + arg0: typing.Annotated[ + numpy.ndarray, + numpy.float32, + pybind11_stubgen.typing_ext.FixedSize(5, 6), + numpy.ndarray.flags.writeable, + ] +) -> None: ... +def fixed_mutator_c( + arg0: typing.Annotated[ + numpy.ndarray, + numpy.float32, + pybind11_stubgen.typing_ext.FixedSize(5, 6), + numpy.ndarray.flags.writeable, + numpy.ndarray.flags.f_contiguous, + ] +) -> None: ... +def fixed_mutator_r( + arg0: typing.Annotated[ + numpy.ndarray, + numpy.float32, + pybind11_stubgen.typing_ext.FixedSize(5, 6), + numpy.ndarray.flags.writeable, + numpy.ndarray.flags.c_contiguous, + ] +) -> None: ... +def four_col_matrix_r( + arg0: typing.Annotated[ + numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) + ] +) -> typing.Annotated[ + numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) +]: ... +def four_row_matrix_r( + arg0: typing.Annotated[ + numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") + ] +) -> typing.Annotated[ + numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") +]: ... +def get_matrix_int() -> typing.Annotated[ + numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) +]: ... +def get_vector_float64() -> typing.Annotated[ + numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) +]: ... +def sparse_matrix_c( + arg0: typing.Annotated[scipy.sparse.csc_matrix, numpy.float32] +) -> typing.Annotated[scipy.sparse.csc_matrix, numpy.float32]: ... +def sparse_matrix_r( + arg0: typing.Annotated[scipy.sparse.csr_matrix, numpy.float32] +) -> typing.Annotated[scipy.sparse.csr_matrix, numpy.float32]: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/enum.pyi new file mode 100644 index 0000000..e3f9e10 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/enum.pyi @@ -0,0 +1,71 @@ +from __future__ import annotations + +import typing + +__all__ = [ + "Blue", + "ConsoleForegroundColor", + "Green", + "Magenta", + "None_", + "Yellow", + "accept_defaulted_enum", +] + +class ConsoleForegroundColor: + """ + Members: + + Green + + Yellow + + Blue + + Magenta + + None_ + """ + + Blue: typing.ClassVar[ + ConsoleForegroundColor + ] # value = + Green: typing.ClassVar[ + ConsoleForegroundColor + ] # value = + Magenta: typing.ClassVar[ + ConsoleForegroundColor + ] # value = + None_: typing.ClassVar[ + ConsoleForegroundColor + ] # value = + Yellow: typing.ClassVar[ + ConsoleForegroundColor + ] # value = + __members__: typing.ClassVar[ + dict[str, ConsoleForegroundColor] + ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } + def __eq__(self, other: typing.Any) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __init__(self, value: int) -> None: ... + def __int__(self) -> int: ... + def __ne__(self, other: typing.Any) -> bool: ... + def __repr__(self) -> str: ... + def __setstate__(self, state: int) -> None: ... + def __str__(self) -> str: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +def accept_defaulted_enum( + color: ConsoleForegroundColor = ConsoleForegroundColor.None_, +) -> None: ... + +Blue: ConsoleForegroundColor # value = +Green: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor # value = +None_: ConsoleForegroundColor # value = +Yellow: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/flawed_bindings.pyi new file mode 100644 index 0000000..651a886 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/flawed_bindings.pyi @@ -0,0 +1,23 @@ +from __future__ import annotations + +__all__ = [ + "Enum", + "Unbound", + "accept_unbound_enum", + "accept_unbound_enum_defaulted", + "accept_unbound_type", + "accept_unbound_type_defaulted", + "get_unbound_type", +] + +class Enum: + pass + +class Unbound: + pass + +def accept_unbound_enum(arg0: ...) -> int: ... +def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... +def accept_unbound_type(arg0: tuple[..., int]) -> int: ... +def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... +def get_unbound_type() -> ...: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/functions.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/functions.pyi new file mode 100644 index 0000000..c748285 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/functions.pyi @@ -0,0 +1,52 @@ +from __future__ import annotations + +import typing + +__all__ = [ + "Foo", + "accept_callable", + "accept_py_handle", + "accept_py_object", + "accept_set", + "add", + "default_custom_arg", + "default_int_arg", + "default_list_arg", + "default_optional_arg", + "func_w_anon_args", + "func_w_named_pos_args", + "generic", + "mul", + "pos_kw_only_mix", + "pos_kw_only_variadic_mix", +] + +class Foo: + def __init__(self, arg0: int) -> None: ... + +def accept_callable(arg0: typing.Callable) -> typing.Any: ... +def accept_py_handle(arg0: typing.Any) -> str: ... +def accept_py_object(arg0: typing.Any) -> str: ... +def accept_set(arg0: set) -> None: ... +def add(arg0: int, arg1: int) -> int: ... +def default_custom_arg(foo: Foo = Foo(5)) -> None: ... +def default_int_arg(n: int = 5) -> None: ... +def default_list_arg(l: list = [1, 2, 6, 18]) -> None: ... +def default_optional_arg(n: int | None = None) -> None: ... +def func_w_anon_args(arg0: int, arg1: int, arg2: int) -> None: ... +def func_w_named_pos_args(x: int, y: int, z: int) -> None: ... +def generic(*args, **kwargs) -> None: ... +@typing.overload +def mul(x: int, y: int) -> int: + """ + Multiply x and y (int) + """ + +@typing.overload +def mul(p: float, q: float) -> float: + """ + Multiply p and q (double) + """ + +def pos_kw_only_mix(i: int, /, j: int, *, k: int) -> tuple: ... +def pos_kw_only_variadic_mix(i: int, /, j: int, *args, k: int, **kwargs) -> tuple: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/issues.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/issues.pyi new file mode 100644 index 0000000..09af4e4 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/issues.pyi @@ -0,0 +1,24 @@ +from __future__ import annotations + +import typing + +__all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] + +def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: + """ + Use-case: + issue_51(os.get_handle_inheritable, os.set_handle_inheritable) + """ + +def issue_73_utf8_doc_chars() -> None: + """ + Construct a Ramsete unicycle controller. + + Tuning parameter (b > 0 rad²/m²) for which larger values make + + convergence more aggressive like a proportional term. + Tuning parameter (0 rad⁻¹ < zeta < 1 rad⁻¹) for which larger + values provide more damping in response. + """ + +_cleanup: typing.Any # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/methods.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/methods.pyi new file mode 100644 index 0000000..7a1952d --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/methods.pyi @@ -0,0 +1,8 @@ +from __future__ import annotations + +__all__ = ["Dummy"] + +class Dummy: + @staticmethod + def def_static(arg0: int) -> int: ... + def def_(self, arg0: int) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/numpy.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/numpy.pyi new file mode 100644 index 0000000..ff707f5 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/numpy.pyi @@ -0,0 +1,19 @@ +from __future__ import annotations + +import typing + +import numpy + +__all__ = [ + "accept_ndarray_float64", + "accept_ndarray_int", + "get_ndarray_float64", + "get_ndarray_int", +] + +def accept_ndarray_float64( + arg0: typing.Annotated[numpy.ndarray, numpy.float64] +) -> None: ... +def accept_ndarray_int(arg0: typing.Annotated[numpy.ndarray, numpy.int32]) -> None: ... +def get_ndarray_float64() -> typing.Annotated[numpy.ndarray, numpy.float64]: ... +def get_ndarray_int() -> typing.Annotated[numpy.ndarray, numpy.int32]: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/properties.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/properties.pyi new file mode 100644 index 0000000..ae33c8e --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/properties.pyi @@ -0,0 +1,99 @@ +from __future__ import annotations + +import typing + +__all__ = [ + "WithGetterSetterDoc", + "WithPropAndGetterSetterDoc", + "WithPropDoc", + "WithoutDoc", +] + +class WithGetterSetterDoc: + """ + User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls + """ + + def_property_readonly_static: typing.ClassVar[int] = 0 + def_property_static: typing.ClassVar[int] = 0 + @property + def def_property(self) -> int: + """ + getter doc token + """ + @def_property.setter + def def_property(self, arg1: int) -> None: + """ + setter doc token + """ + @property + def def_property_readonly(self) -> int: + """ + getter doc token + """ + +class WithPropAndGetterSetterDoc: + """ + User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls + """ + + def_property_readonly_static: typing.ClassVar[int] = 0 + def_property_static: typing.ClassVar[int] = 0 + @property + def def_property(self) -> int: + """ + prop doc token + """ + @def_property.setter + def def_property(self, arg1: int) -> None: ... + @property + def def_property_readonly(self) -> int: + """ + prop doc token + """ + +class WithPropDoc: + """ + User docstring provided only to `def_` calls + """ + + def_property_readonly_static: typing.ClassVar[int] = 0 + def_property_static: typing.ClassVar[int] = 0 + @property + def def_property(self) -> int: + """ + prop doc token + """ + @def_property.setter + def def_property(self, arg1: int) -> None: ... + @property + def def_property_readonly(self) -> int: + """ + prop doc token + """ + @property + def def_readonly(self) -> int: + """ + prop doc token + """ + @property + def def_readwrite(self) -> int: + """ + prop doc token + """ + @def_readwrite.setter + def def_readwrite(self, arg0: int) -> None: ... + +class WithoutDoc: + """ + No user docstring provided + """ + + def_property_readonly_static: typing.ClassVar[int] = 0 + def_property_static: typing.ClassVar[int] = 0 + def_property: int + def_readwrite: int + @property + def def_property_readonly(self) -> int: ... + @property + def def_readonly(self) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/stl.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/stl.pyi new file mode 100644 index 0000000..dba6cff --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/stl.pyi @@ -0,0 +1,11 @@ +from __future__ import annotations + +import typing + +__all__ = ["std_array", "std_map", "std_optional", "std_variant", "std_vector"] + +def std_array(arg0: list[int[3]]) -> list[int[3]]: ... +def std_map() -> dict[int, complex]: ... +def std_optional(arg0: int | None) -> None: ... +def std_variant(arg0: int | float | tuple[int, int]) -> None: ... +def std_vector() -> list[tuple[int, float]]: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/stl_bind.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/stl_bind.pyi new file mode 100644 index 0000000..7abf41f --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/stl_bind.pyi @@ -0,0 +1,124 @@ +from __future__ import annotations + +import typing + +__all__ = [ + "MapStringComplex", + "VectorPairStringDouble", + "get_complex_map", + "get_vector_of_pairs", +] + +class MapStringComplex: + def __bool__(self) -> bool: + """ + Check whether the map is nonempty + """ + @typing.overload + def __contains__(self, arg0: str) -> bool: ... + @typing.overload + def __contains__(self, arg0: typing.Any) -> bool: ... + def __delitem__(self, arg0: str) -> None: ... + def __getitem__(self, arg0: str) -> complex: ... + def __init__(self) -> None: ... + def __iter__(self) -> typing.Iterator: ... + def __len__(self) -> int: ... + def __repr__(self) -> str: + """ + Return the canonical string representation of this map. + """ + def __setitem__(self, arg0: str, arg1: complex) -> None: ... + def items(self) -> typing.ItemsView[MapStringComplex]: ... + def keys(self) -> typing.KeysView[MapStringComplex]: ... + def values(self) -> typing.ValuesView[MapStringComplex]: ... + +class VectorPairStringDouble: + __hash__: typing.ClassVar[None] = None + def __bool__(self) -> bool: + """ + Check whether the list is nonempty + """ + def __contains__(self, x: tuple[str, float]) -> bool: + """ + Return true the container contains ``x`` + """ + @typing.overload + def __delitem__(self, arg0: int) -> None: + """ + Delete the list elements at index ``i`` + """ + @typing.overload + def __delitem__(self, arg0: slice) -> None: + """ + Delete list elements using a slice object + """ + def __eq__(self, arg0: VectorPairStringDouble) -> bool: ... + @typing.overload + def __getitem__(self, s: slice) -> VectorPairStringDouble: + """ + Retrieve list elements using a slice object + """ + @typing.overload + def __getitem__(self, arg0: int) -> tuple[str, float]: ... + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, arg0: VectorPairStringDouble) -> None: + """ + Copy constructor + """ + @typing.overload + def __init__(self, arg0: typing.Iterable) -> None: ... + def __iter__(self) -> typing.Iterator: ... + def __len__(self) -> int: ... + def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... + @typing.overload + def __setitem__(self, arg0: int, arg1: tuple[str, float]) -> None: ... + @typing.overload + def __setitem__(self, arg0: slice, arg1: VectorPairStringDouble) -> None: + """ + Assign list elements using a slice object + """ + def append(self, x: tuple[str, float]) -> None: + """ + Add an item to the end of the list + """ + def clear(self) -> None: + """ + Clear the contents + """ + def count(self, x: tuple[str, float]) -> int: + """ + Return the number of times ``x`` appears in the list + """ + @typing.overload + def extend(self, L: VectorPairStringDouble) -> None: + """ + Extend the list by appending all the items in the given list + """ + @typing.overload + def extend(self, L: typing.Iterable) -> None: + """ + Extend the list by appending all the items in the given list + """ + def insert(self, i: int, x: tuple[str, float]) -> None: + """ + Insert an item at a given position. + """ + @typing.overload + def pop(self) -> tuple[str, float]: + """ + Remove and return the last item + """ + @typing.overload + def pop(self, i: int) -> tuple[str, float]: + """ + Remove and return the item at index ``i`` + """ + def remove(self, x: tuple[str, float]) -> None: + """ + Remove the first item from the list whose value is x. It is an error if there is no such item. + """ + +def get_complex_map() -> MapStringComplex: ... +def get_vector_of_pairs() -> VectorPairStringDouble: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/typing.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/typing.pyi new file mode 100644 index 0000000..c85fc99 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/typing.pyi @@ -0,0 +1,10 @@ +from __future__ import annotations + +import typing + +import typing_extensions + +__all__ = ["get_buffer", "get_sequence"] + +def get_buffer(arg0: typing_extensions.Buffer) -> typing_extensions.Buffer: ... +def get_sequence(arg0: typing.Sequence) -> typing.Sequence: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/values.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/values.pyi new file mode 100644 index 0000000..eb4a85a --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/_bindings/values.pyi @@ -0,0 +1,36 @@ +from __future__ import annotations + +import datetime + +import numpy +from numpy import random + +__all__ = [ + "Dummy", + "Foo", + "add_day", + "foolist", + "foovar", + "list_with_none", + "none", + "random", + "t_10ms", + "t_20ns", + "t_30s", +] + +class Dummy: + linalg = numpy.linalg + +class Foo: + pass + +def add_day(arg0: datetime.datetime) -> datetime.datetime: ... + +foolist: list # value = [, ] +foovar: Foo # value = +list_with_none: list = [None, 2, {}] +none = None +t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) +t_20ns: datetime.timedelta # value = datetime.timedelta(0) +t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/core.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/core.pyi new file mode 100644 index 0000000..5b7af61 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/core.pyi @@ -0,0 +1,35 @@ +from __future__ import annotations + +from demo._bindings import ( + aliases, + classes, + eigen, + enum, + flawed_bindings, + functions, + issues, + methods, + numpy, + properties, + stl, + stl_bind, + typing, + values, +) + +__all__ = [ + "aliases", + "classes", + "eigen", + "enum", + "flawed_bindings", + "functions", + "issues", + "methods", + "numpy", + "properties", + "stl", + "stl_bind", + "typing", + "values", +] diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/__init__.pyi new file mode 100644 index 0000000..a0202c5 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/__init__.pyi @@ -0,0 +1,5 @@ +from __future__ import annotations + +from . import classes, functions, functions_3_8_plus, functions_3_9_plus, values + +__all__ = ["classes", "functions", "functions_3_8_plus", "functions_3_9_plus", "values"] diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/classes.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/classes.pyi new file mode 100644 index 0000000..01422a3 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/classes.pyi @@ -0,0 +1,21 @@ +from __future__ import annotations + +__all__ = ["A", "B", "C", "X"] + +class A: + """ + A + """ + +class B(A): + """ + B + """ + +class C(B): + """ + C + """ + +class X: + pass diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/functions.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/functions.pyi new file mode 100644 index 0000000..a6c7165 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/functions.pyi @@ -0,0 +1,31 @@ +from __future__ import annotations + +import sys as sys +import typing as typing + +from demo.pure_python.functions_3_8_plus import args_mix +from demo.pure_python.functions_3_9_plus import generic_alias_annotation + +__all__ = [ + "accept_frozenset", + "args_mix", + "builtin_function_as_default_arg", + "function_as_default_arg", + "generic_alias_annotation", + "lambda_as_default_arg", + "search", + "static_method_as_default_arg", + "sys", + "typing", +] + +class _Dummy: + @staticmethod + def foo(): ... + +def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... +def builtin_function_as_default_arg(func: type(len) = len): ... +def function_as_default_arg(func: type(search) = search): ... +def lambda_as_default_arg(callback=...): ... +def search(a: int, b: list[int]) -> int: ... +def static_method_as_default_arg(callback=_Dummy.foo): ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/functions_3_8_plus.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/functions_3_8_plus.pyi new file mode 100644 index 0000000..dd9ffdc --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/functions_3_8_plus.pyi @@ -0,0 +1,15 @@ +from __future__ import annotations + +import typing as typing + +__all__ = ["args_mix", "typing"] + +def args_mix( + a: int, + b: float = 0.5, + c: str = "", + *args: int, + x: int = 1, + y=int, + **kwargs: typing.Dict[int, str], +): ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/functions_3_9_plus.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/functions_3_9_plus.pyi new file mode 100644 index 0000000..afb3fd5 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/functions_3_9_plus.pyi @@ -0,0 +1,5 @@ +from __future__ import annotations + +__all__ = ["generic_alias_annotation"] + +def generic_alias_annotation(a: list[tuple[int]], b: dict[int, str]) -> list[float]: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/values.pyi b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/values.pyi new file mode 100644 index 0000000..b7e3496 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/demo/pure_python/values.pyi @@ -0,0 +1,4 @@ +from __future__ import annotations + +__all__ = ["callables_dict"] +callables_dict: dict = {"len": len, "int": int}