From c91ec4cbf185a118c6b3828fd320e53e2e6675ee Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sun, 19 Apr 2026 23:17:06 -0700 Subject: [PATCH 1/3] Test: Enum Internals Reproducer --- tests/py-demo/bindings/src/modules/enum.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/py-demo/bindings/src/modules/enum.cpp b/tests/py-demo/bindings/src/modules/enum.cpp index a3532c5f..9e353ffa 100644 --- a/tests/py-demo/bindings/src/modules/enum.cpp +++ b/tests/py-demo/bindings/src/modules/enum.cpp @@ -2,6 +2,19 @@ #include +#if PYBIND11_VERSION_AT_LEAST(3,0) +# include +#endif + +#if PYBIND11_VERSION_AT_LEAST(3,0) +namespace { +enum class NativeColor : int { + Red = 1, + Blue = 2, +}; +} // namespace +#endif + void bind_enum_module(py::module&&m) { py::enum_(m, "ConsoleForegroundColor") @@ -16,4 +29,11 @@ void bind_enum_module(py::module&&m) { "accept_defaulted_enum", [](const demo::sublibA::ConsoleForegroundColor &color) {}, py::arg("color") = demo::sublibA::ConsoleForegroundColor::None_); + +#if PYBIND11_VERSION_AT_LEAST(3,0) + py::native_enum(m, "NativeColor", "enum.IntEnum") + .value("Red", NativeColor::Red) + .value("Blue", NativeColor::Blue) + .finalize(); +#endif } From 044450ed52029b4639daadbf06d97b4f26a39803 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sun, 19 Apr 2026 23:17:20 -0700 Subject: [PATCH 2/3] Fix: Filter Internals of Native Enum --- pybind11_stubgen/__init__.py | 2 ++ pybind11_stubgen/parser/mixins/filter.py | 32 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/pybind11_stubgen/__init__.py b/pybind11_stubgen/__init__.py index 444c8357..2e96becd 100644 --- a/pybind11_stubgen/__init__.py +++ b/pybind11_stubgen/__init__.py @@ -21,6 +21,7 @@ from pybind11_stubgen.parser.mixins.filter import ( FilterClassMembers, FilterInvalidIdentifiers, + FilterPybind11NativeEnumMembers, FilterPybind11ViewClasses, FilterPybindInternals, FilterTypingModuleAttributes, @@ -284,6 +285,7 @@ class Parser( FixValueReprRandomAddress, FixRedundantBuiltinsAnnotation, FilterPybindInternals, + FilterPybind11NativeEnumMembers, FilterPybind11ViewClasses, FixRedundantMethodsFromBuiltinObject, RemoveSelfAnnotation, diff --git a/pybind11_stubgen/parser/mixins/filter.py b/pybind11_stubgen/parser/mixins/filter.py index aee10488..e2166cf8 100644 --- a/pybind11_stubgen/parser/mixins/filter.py +++ b/pybind11_stubgen/parser/mixins/filter.py @@ -148,3 +148,35 @@ def handle_module_member( return None return result + + +class FilterPybind11NativeEnumMembers(IParser): + @staticmethod + def _is_sunder(name: str) -> bool: + """Match CPython Enum's reserved ``_sunder_`` names. + + Keep this in sync with CPython's ``enum._is_sunder``: + https://github.com/python/cpython/blob/3.14/Lib/enum.py#L57-L66 + + These names are rejected by ``EnumDict.__setitem__`` unless explicitly + allowlisted by ``enum`` itself: + https://github.com/python/cpython/blob/3.14/Lib/enum.py#L342-L367 + """ + return ( + len(name) > 2 + and name[0] == name[-1] == "_" + and name[1] != "_" + and name[-2] != "_" + ) + + def handle_class_member( + self, path: QualifiedName, class_: type, obj: Any + ) -> Docstring | Alias | Class | list[Method] | Field | Property | None: + name = str(path[-1]) + # py::native_enum exposes Enum internals via __dict__, but emitting them + # into a stub that later gets executed as Python can fail at import time. + if hasattr(class_, "__pybind11_native_enum__") and ( + name == "__pybind11_native_enum__" or self._is_sunder(name) + ): + return None + return super().handle_class_member(path, class_, obj) From 5dd34971ecd215ecf081f05dab82ad893b4c88cc Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 20 Apr 2026 00:06:54 -0700 Subject: [PATCH 3/3] Update Stubs --- tests/stubs/python-3.10 | 1 - tests/stubs/python-3.10/pybind11-v2.11 | 1 + tests/stubs/python-3.10/pybind11-v2.12 | 1 + tests/stubs/python-3.10/pybind11-v2.13 | 1 + .../pybind11-v3.0/numpy-array-use-type-var | 1 + .../demo/__init__.pyi | 43 +++++ .../demo/_bindings/__init__.pyi | 37 ++++ .../demo/_bindings/aliases/__init__.pyi | 53 ++++++ .../demo/_bindings/aliases/foreign_arg.pyi | 7 + .../demo/_bindings/aliases/foreign_attr.pyi | 6 + .../aliases/foreign_class_member.pyi | 12 ++ .../_bindings/aliases/foreign_method_arg.pyi | 8 + .../aliases/foreign_method_return.pyi | 9 + .../demo/_bindings/aliases/foreign_return.pyi | 7 + .../_bindings/aliases/missing_self_arg.pyi | 8 + .../demo/_bindings/classes.pyi | 94 ++++++++++ .../demo/_bindings/eigen.pyi | 75 ++++++++ .../demo/_bindings/enum.pyi | 85 +++++++++ .../demo/_bindings/flawed_bindings.pyi | 27 +++ .../demo/_bindings/functions.pyi | 127 ++++++++++++++ .../demo/_bindings/hidden_builtins.pyi | 7 + .../demo/_bindings/issues.pyi | 46 +++++ .../demo/_bindings/methods.pyi | 12 ++ .../demo/_bindings/numpy.pyi | 24 +++ .../demo/_bindings/properties.pyi | 116 +++++++++++++ .../demo/_bindings/stl.pyi | 34 ++++ .../demo/_bindings/stl_bind.pyi | 162 ++++++++++++++++++ .../demo/_bindings/typing.pyi | 10 ++ .../demo/_bindings/values.pyi | 36 ++++ .../demo/core.pyi | 37 ++++ .../demo/pure_python/__init__.pyi | 11 ++ .../demo/pure_python/classes.pyi | 21 +++ .../demo/pure_python/functions.pyi | 31 ++++ .../demo/pure_python/functions_3_8_plus.pyi | 30 ++++ .../demo/pure_python/functions_3_9_plus.pyi | 5 + .../demo/pure_python/values.pyi | 4 + tests/stubs/python-3.10/requirements.txt | 1 + .../demo/_bindings/enum.pyi | 9 + .../demo/_bindings/enum.pyi | 12 ++ .../demo/_bindings/enum.pyi | 12 ++ 40 files changed, 1222 insertions(+), 1 deletion(-) delete mode 120000 tests/stubs/python-3.10 create mode 120000 tests/stubs/python-3.10/pybind11-v2.11 create mode 120000 tests/stubs/python-3.10/pybind11-v2.12 create mode 120000 tests/stubs/python-3.10/pybind11-v2.13 create mode 120000 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-use-type-var create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_arg.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_method_arg.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_method_return.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_return.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/missing_self_arg.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/eigen.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/methods.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/numpy.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/typing.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/__init__.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/classes.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_9_plus.pyi create mode 100644 tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/values.pyi create mode 120000 tests/stubs/python-3.10/requirements.txt diff --git a/tests/stubs/python-3.10 b/tests/stubs/python-3.10 deleted file mode 120000 index 08f31189..00000000 --- a/tests/stubs/python-3.10 +++ /dev/null @@ -1 +0,0 @@ -python-3.11 \ No newline at end of file diff --git a/tests/stubs/python-3.10/pybind11-v2.11 b/tests/stubs/python-3.10/pybind11-v2.11 new file mode 120000 index 00000000..03f1084f --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v2.11 @@ -0,0 +1 @@ +../python-3.11/pybind11-v2.11 \ No newline at end of file diff --git a/tests/stubs/python-3.10/pybind11-v2.12 b/tests/stubs/python-3.10/pybind11-v2.12 new file mode 120000 index 00000000..89e32d30 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v2.12 @@ -0,0 +1 @@ +../python-3.11/pybind11-v2.12 \ No newline at end of file diff --git a/tests/stubs/python-3.10/pybind11-v2.13 b/tests/stubs/python-3.10/pybind11-v2.13 new file mode 120000 index 00000000..0d64df17 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v2.13 @@ -0,0 +1 @@ +../python-3.11/pybind11-v2.13 \ No newline at end of file diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-use-type-var b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-use-type-var new file mode 120000 index 00000000..da8c572d --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-use-type-var @@ -0,0 +1 @@ +../../python-3.11/pybind11-v3.0/numpy-array-use-type-var \ No newline at end of file diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi new file mode 100644 index 00000000..9f27c427 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi @@ -0,0 +1,43 @@ +from __future__ import annotations + +from demo._bindings import ( + aliases, + classes, + eigen, + enum, + flawed_bindings, + functions, + hidden_builtins, + issues, + methods, + numpy, + properties, + stl, + stl_bind, + typing, + values, +) + +from . import _bindings, core, pure_python + +__all__: list[str] = [ + "aliases", + "classes", + "core", + "eigen", + "enum", + "flawed_bindings", + "functions", + "hidden_builtins", + "issues", + "methods", + "numpy", + "properties", + "pure_python", + "stl", + "stl_bind", + "typing", + "values", + "version", +] +version: str = "0.0.0" diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi new file mode 100644 index 00000000..9ea9beb4 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi @@ -0,0 +1,37 @@ +from __future__ import annotations + +from . import ( + aliases, + classes, + eigen, + enum, + flawed_bindings, + functions, + hidden_builtins, + issues, + methods, + numpy, + properties, + stl, + stl_bind, + typing, + values, +) + +__all__: list[str] = [ + "aliases", + "classes", + "eigen", + "enum", + "flawed_bindings", + "functions", + "hidden_builtins", + "issues", + "methods", + "numpy", + "properties", + "stl", + "stl_bind", + "typing", + "values", +] diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi new file mode 100644 index 00000000..dcc348b7 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi @@ -0,0 +1,53 @@ +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, + missing_self_arg, +) + +__all__: list[str] = [ + "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", + "missing_self_arg", + "random", +] + +class Dummy: + linalg = numpy.linalg + +class Color: + pass + +def foreign_enum_default( + color: typing.Any = demo._bindings.enum.ConsoleForegroundColor.Blue, +) -> None: ... +def func(arg0: typing.SupportsInt | typing.SupportsIndex) -> int: ... + +local_type_alias = Color +local_func_alias = func diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_arg.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_arg.pyi new file mode 100644 index 00000000..de75e6fb --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_arg.pyi @@ -0,0 +1,7 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__: list[str] = ["set_foo"] + +def set_foo(arg0: demo._bindings.classes.Foo) -> int: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi new file mode 100644 index 00000000..10c4a712 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -0,0 +1,6 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__: list[str] = ["value"] +value: demo._bindings.classes.Foo # value = diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi new file mode 100644 index 00000000..497a4e2a --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -0,0 +1,12 @@ +from __future__ import annotations + +import typing + +import demo._bindings.classes + +__all__: list[str] = ["Bar1"] + +class Bar1: + foo: typing.ClassVar[ + demo._bindings.classes.Foo + ] # value = diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_method_arg.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_method_arg.pyi new file mode 100644 index 00000000..8d4ed4ac --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_method_arg.pyi @@ -0,0 +1,8 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__: list[str] = ["Bar2"] + +class Bar2: + def set_foo(self, arg0: demo._bindings.classes.Foo) -> int: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_method_return.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_method_return.pyi new file mode 100644 index 00000000..95d218e1 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_method_return.pyi @@ -0,0 +1,9 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__: list[str] = ["Bar3"] + +class Bar3: + @staticmethod + def get_foo() -> demo._bindings.classes.Foo: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_return.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_return.pyi new file mode 100644 index 00000000..7b5b428f --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_return.pyi @@ -0,0 +1,7 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__: list[str] = ["get_foo"] + +def get_foo() -> demo._bindings.classes.Foo: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/missing_self_arg.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/missing_self_arg.pyi new file mode 100644 index 00000000..ee1a09ee --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/aliases/missing_self_arg.pyi @@ -0,0 +1,8 @@ +from __future__ import annotations + +import demo._bindings.classes + +__all__: list[str] = ["Bar4"] + +class Bar4: + def set_foo(self: demo._bindings.classes.Foo) -> int: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi new file mode 100644 index 00000000..d85d9249 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -0,0 +1,94 @@ +from __future__ import annotations + +import typing + +__all__: list[str] = [ + "CppException", + "Derived", + "Foo", + "MyBase", + "Outer", + "ParIter", + "ParIterBase", + "ParticleContainer", +] + +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: typing.SupportsInt | typing.SupportsIndex + ) -> None: ... + def __int__(self) -> int: ... + def __ne__(self, other: typing.Any) -> bool: ... + def __repr__(self) -> str: ... + def __setstate__( + self, state: typing.SupportsInt | typing.SupportsIndex + ) -> None: ... + def __str__(self) -> str: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + + value: Outer.Inner.NestedEnum + + inner: Outer.Inner + +class MyBase: + class Inner: + pass + + name: str + +class Derived(MyBase): + @property + def count(self) -> int: ... + @count.setter + def count(self, arg0: typing.SupportsInt | typing.SupportsIndex) -> None: ... + +class Foo: + class FooChild: + def __init__(self) -> None: ... + def g(self) -> None: ... + + def __init__(self) -> None: ... + def f(self) -> None: ... + +class ParIterBase: + @property + def level(self) -> int: ... + @level.setter + def level(self, arg0: typing.SupportsInt | typing.SupportsIndex) -> None: ... + +class ParIter(ParIterBase): + def __init__( + self, + particle_container: ParticleContainer, + level: typing.SupportsInt | typing.SupportsIndex, + ) -> None: ... + +class ParticleContainer: + name: str + Iterator = ParIter + def process(self, arg0: ParIter) -> None: ... + +class CppException(Exception): + pass diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/eigen.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/eigen.pyi new file mode 100644 index 00000000..afe7ccb3 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/eigen.pyi @@ -0,0 +1,75 @@ +from __future__ import annotations + +import typing + +import numpy +import numpy.typing +import scipy.sparse + +__all__: list[str] = [ + "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.typing.ArrayLike, numpy.int32, "[3, 3]"], +) -> None: ... +def accept_vector_float64( + arg0: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, "[3, 1]"], +) -> None: ... +def dense_matrix_c( + arg0: typing.Annotated[numpy.typing.ArrayLike, numpy.float32, "[m, n]"], +) -> typing.Annotated[numpy.typing.NDArray[numpy.float32], "[m, n]"]: ... +def dense_matrix_r( + arg0: typing.Annotated[numpy.typing.ArrayLike, numpy.float32, "[m, n]"], +) -> typing.Annotated[numpy.typing.NDArray[numpy.float32], "[m, n]"]: ... +def fixed_mutator_a( + arg0: typing.Annotated[ + numpy.typing.NDArray[numpy.float32], "[5, 6]", "flags.writeable" + ], +) -> None: ... +def fixed_mutator_c( + arg0: typing.Annotated[ + numpy.typing.NDArray[numpy.float32], + "[5, 6]", + "flags.writeable", + "flags.f_contiguous", + ], +) -> None: ... +def fixed_mutator_r( + arg0: typing.Annotated[ + numpy.typing.NDArray[numpy.float32], + "[5, 6]", + "flags.writeable", + "flags.c_contiguous", + ], +) -> None: ... +def four_col_matrix_r( + arg0: typing.Annotated[numpy.typing.ArrayLike, numpy.float32, "[m, 4]"], +) -> typing.Annotated[numpy.typing.NDArray[numpy.float32], "[m, 4]"]: ... +def four_row_matrix_r( + arg0: typing.Annotated[numpy.typing.ArrayLike, numpy.float32, "[4, n]"], +) -> typing.Annotated[numpy.typing.NDArray[numpy.float32], "[4, n]"]: ... +def get_matrix_int() -> ( + typing.Annotated[numpy.typing.NDArray[numpy.int32], "[3, 3]"] +): ... +def get_vector_float64() -> ( + typing.Annotated[numpy.typing.NDArray[numpy.float64], "[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.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi new file mode 100644 index 00000000..9b3da863 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -0,0 +1,85 @@ +from __future__ import annotations + +import enum +import typing + +__all__: list[str] = [ + "Blue", + "ConsoleForegroundColor", + "Green", + "Magenta", + "NativeColor", + "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: typing.SupportsInt | typing.SupportsIndex) -> None: ... + def __int__(self) -> int: ... + def __ne__(self, other: typing.Any) -> bool: ... + def __repr__(self) -> str: ... + def __setstate__( + self, state: typing.SupportsInt | typing.SupportsIndex + ) -> None: ... + def __str__(self) -> str: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class NativeColor(enum.IntEnum): + """ + An enumeration. + """ + + Blue: typing.ClassVar[NativeColor] # value = + Red: typing.ClassVar[NativeColor] # value = + @classmethod + def __new__(cls, value): ... + +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.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi new file mode 100644 index 00000000..f8c22db8 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -0,0 +1,27 @@ +from __future__ import annotations + +import typing + +__all__: list[str] = [ + "Enum", + "Unbound", + "accept_unbound_enum", + "accept_unbound_enum_defaulted", + "accept_unbound_type", + "accept_unbound_type_defaulted", + "get_unbound_type", +] + +class Unbound: + pass + +class Enum: + pass + +def accept_unbound_enum(arg0: ...) -> int: ... +def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... +def accept_unbound_type( + arg0: tuple[..., typing.SupportsInt | typing.SupportsIndex], +) -> int: ... +def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... +def get_unbound_type() -> ...: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi new file mode 100644 index 00000000..4bdd39a6 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi @@ -0,0 +1,127 @@ +from __future__ import annotations + +import collections.abc +import typing + +__all__: list[str] = [ + "Foo", + "U", + "accept_annotated_callable", + "accept_callable", + "accept_frozenset", + "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", + "nested_types", + "pass_callback", + "passthrough1", + "passthrough2", + "passthrough3", + "passthrough_backwards", + "pos_kw_only_mix", + "pos_kw_only_variadic_mix", +] + +class Foo: + def __init__(self, arg0: typing.SupportsInt | typing.SupportsIndex) -> None: ... + +def accept_annotated_callable( + arg0: collections.abc.Callable[ + [ + typing.SupportsInt | typing.SupportsIndex, + typing.SupportsInt | typing.SupportsIndex, + ], + int, + ], +) -> typing.Any: ... +def accept_callable(arg0: collections.abc.Callable) -> typing.Any: ... +def accept_frozenset(arg0: frozenset) -> None: ... +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: typing.SupportsInt | typing.SupportsIndex, + arg1: typing.SupportsInt | typing.SupportsIndex, +) -> int: ... +def default_custom_arg(foo: Foo = Foo(5)) -> None: ... +def default_int_arg(n: typing.SupportsInt | typing.SupportsIndex = 5) -> None: ... +def default_list_arg(l: list = [1, 2, 6, 18]) -> None: ... +def default_optional_arg( + n: typing.SupportsInt | typing.SupportsIndex | None = None, +) -> None: ... +def func_w_anon_args( + arg0: typing.SupportsInt | typing.SupportsIndex, + arg1: typing.SupportsInt | typing.SupportsIndex, + arg2: typing.SupportsInt | typing.SupportsIndex, +) -> None: ... +def func_w_named_pos_args( + x: typing.SupportsInt | typing.SupportsIndex, + y: typing.SupportsInt | typing.SupportsIndex, + z: typing.SupportsInt | typing.SupportsIndex, +) -> None: ... +def generic(*args, **kwargs) -> None: ... +@typing.overload +def mul( + x: typing.SupportsInt | typing.SupportsIndex, + y: typing.SupportsInt | typing.SupportsIndex, +) -> int: + """ + Multiply x and y (int) + """ + +@typing.overload +def mul( + p: typing.SupportsFloat | typing.SupportsIndex, + q: typing.SupportsFloat | typing.SupportsIndex, +) -> float: + """ + Multiply p and q (double) + """ + +def nested_types(arg0: collections.abc.Sequence[Foo] | Foo) -> list[Foo] | Foo: ... +def pass_callback(arg0: collections.abc.Callable[[Foo], Foo]) -> Foo: ... +def passthrough1(*args, **kwargs): + """ + passthrough1[T](obj: T) -> T + """ + +@typing.overload +def passthrough2() -> None: + """ + 2. passthrough2[T](obj: T) -> T + """ + +@typing.overload +def passthrough3() -> tuple[None, None]: + """ + 2. passthrough3[T](obj: T) -> tuple[T, None] + 3. passthrough3[T1, T2](obj1: T1, obj2: T2) -> tuple[T1, T2] + """ + +def passthrough_backwards(obj: U) -> U: ... +def pos_kw_only_mix( + i: typing.SupportsInt | typing.SupportsIndex, + /, + j: typing.SupportsInt | typing.SupportsIndex, + *, + k: typing.SupportsInt | typing.SupportsIndex, +) -> tuple[int, int, int]: ... +def pos_kw_only_variadic_mix( + i: typing.SupportsInt | typing.SupportsIndex, + /, + j: typing.SupportsInt | typing.SupportsIndex, + *args, + k: typing.SupportsInt | typing.SupportsIndex, + **kwargs, +) -> tuple[int, int, int]: ... + +U: typing.TypeVar # value = ~U diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi new file mode 100644 index 00000000..52c09281 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi @@ -0,0 +1,7 @@ +from __future__ import annotations + +import types + +__all__: list[str] = ["mapping_proxy", "none"] +mapping_proxy: types.MappingProxyType # value = mappingproxy({}) +none = None diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi new file mode 100644 index 00000000..61b1cda8 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -0,0 +1,46 @@ +from __future__ import annotations + +import typing + +__all__: list[str] = [ + "backslashes_should_be_escaped", + "issue_274_docstring_leading_newline", + "issue_51_catastrophic_regex", + "issue_73_utf8_doc_chars", +] + +def backslashes_should_be_escaped() -> None: + """ + \\brief A brief description of this function. + + A detailed description of this function. + + Here's some reStructuredText: :math:`x = [x, y, \\theta]^T` + """ + +def issue_274_docstring_leading_newline() -> None: + """ + This is a docstring + """ + +def issue_51_catastrophic_regex( + arg0: typing.SupportsInt | typing.SupportsIndex, + arg1: typing.SupportsInt | typing.SupportsIndex, +) -> 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.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/methods.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/methods.pyi new file mode 100644 index 00000000..0ac0df06 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/methods.pyi @@ -0,0 +1,12 @@ +from __future__ import annotations + +import typing + +__all__: list[str] = ["Dummy"] + +class Dummy: + @staticmethod + def static_method(arg0: typing.SupportsInt | typing.SupportsIndex) -> int: ... + def regular_method( + self, arg0: typing.SupportsInt | typing.SupportsIndex + ) -> int: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/numpy.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/numpy.pyi new file mode 100644 index 00000000..ca0a64b9 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/numpy.pyi @@ -0,0 +1,24 @@ +from __future__ import annotations + +import typing + +import numpy +import numpy.typing + +__all__: list[str] = [ + "accept_ndarray_float64", + "accept_ndarray_int", + "get_ndarray_float64", + "get_ndarray_int", + "return_dtype", +] + +def accept_ndarray_float64( + arg0: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], +) -> None: ... +def accept_ndarray_int( + arg0: typing.Annotated[numpy.typing.ArrayLike, numpy.int32], +) -> None: ... +def get_ndarray_float64() -> numpy.typing.NDArray[numpy.float64]: ... +def get_ndarray_int() -> numpy.typing.NDArray[numpy.int32]: ... +def return_dtype() -> numpy.dtype[typing.Any]: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi new file mode 100644 index 00000000..7ebd112b --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi @@ -0,0 +1,116 @@ +from __future__ import annotations + +import typing + +__all__: list[str] = [ + "WithGetterSetterDoc", + "WithPropAndGetterSetterDoc", + "WithPropDoc", + "WithoutDoc", +] + +class WithoutDoc: + """ + No user docstring provided + """ + + def_property_readonly_static: typing.ClassVar[int] = 0 + def_property_static: typing.ClassVar[int] = 0 + @property + def def_property(self) -> int: ... + @def_property.setter + def def_property(self, arg1: typing.SupportsInt | typing.SupportsIndex) -> None: ... + @property + def def_property_readonly(self) -> int: ... + @property + def def_readonly(self) -> int: ... + @property + def def_readwrite(self) -> int: ... + @def_readwrite.setter + def def_readwrite( + self, arg0: typing.SupportsInt | typing.SupportsIndex + ) -> None: ... + +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: typing.SupportsInt | typing.SupportsIndex) -> 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: typing.SupportsInt | typing.SupportsIndex + ) -> None: ... + +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: typing.SupportsInt | typing.SupportsIndex) -> 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: typing.SupportsInt | typing.SupportsIndex) -> None: ... + @property + def def_property_readonly(self) -> int: + """ + prop doc token + """ diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi new file mode 100644 index 00000000..58f6a5d2 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi @@ -0,0 +1,34 @@ +from __future__ import annotations + +import collections.abc +import typing + +__all__: list[str] = [ + "std_array", + "std_map", + "std_optional", + "std_variant", + "std_vector", +] + +def std_array( + arg0: typing.Annotated[ + collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], + "FixedSize(3)", + ], +) -> typing.Annotated[list[int], "FixedSize(3)"]: ... +def std_map() -> dict[int, complex]: ... +def std_optional(arg0: typing.SupportsInt | typing.SupportsIndex | None) -> None: ... +def std_variant( + arg0: ( + typing.SupportsInt + | typing.SupportsIndex + | typing.SupportsFloat + | typing.SupportsIndex + | tuple[ + typing.SupportsInt | typing.SupportsIndex, + typing.SupportsInt | typing.SupportsIndex, + ] + ), +) -> None: ... +def std_vector() -> list[tuple[int, float]]: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi new file mode 100644 index 00000000..efa43c51 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi @@ -0,0 +1,162 @@ +from __future__ import annotations + +import collections.abc +import typing + +__all__: list[str] = [ + "MapStringComplex", + "VectorPairStringDouble", + "get_complex_map", + "get_vector_of_pairs", +] + +class VectorPairStringDouble: + __hash__: typing.ClassVar[None] = None + def __bool__(self) -> bool: + """ + Check whether the list is nonempty + """ + + def __contains__( + self, x: tuple[str, typing.SupportsFloat | typing.SupportsIndex] + ) -> bool: + """ + Return true the container contains ``x`` + """ + + @typing.overload + def __delitem__(self, arg0: typing.SupportsInt | typing.SupportsIndex) -> 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: typing.SupportsInt | typing.SupportsIndex + ) -> 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: collections.abc.Iterable) -> None: ... + def __iter__(self) -> collections.abc.Iterator[tuple[str, float]]: ... + def __len__(self) -> int: ... + def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... + @typing.overload + def __setitem__( + self, + arg0: typing.SupportsInt | typing.SupportsIndex, + arg1: tuple[str, typing.SupportsFloat | typing.SupportsIndex], + ) -> None: ... + @typing.overload + def __setitem__(self, arg0: slice, arg1: VectorPairStringDouble) -> None: + """ + Assign list elements using a slice object + """ + + def append( + self, x: tuple[str, typing.SupportsFloat | typing.SupportsIndex] + ) -> None: + """ + Add an item to the end of the list + """ + + def clear(self) -> None: + """ + Clear the contents + """ + + def count(self, x: tuple[str, typing.SupportsFloat | typing.SupportsIndex]) -> 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: collections.abc.Iterable) -> None: + """ + Extend the list by appending all the items in the given list + """ + + def insert( + self, + i: typing.SupportsInt | typing.SupportsIndex, + x: tuple[str, typing.SupportsFloat | typing.SupportsIndex], + ) -> 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: typing.SupportsInt | typing.SupportsIndex) -> tuple[str, float]: + """ + Remove and return the item at index ``i`` + """ + + def remove( + self, x: tuple[str, typing.SupportsFloat | typing.SupportsIndex] + ) -> None: + """ + Remove the first item from the list whose value is x. It is an error if there is no such item. + """ + +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) -> collections.abc.Iterator[str]: ... + def __len__(self) -> int: ... + def __repr__(self) -> str: + """ + Return the canonical string representation of this map. + """ + + def __setitem__( + self, + arg0: str, + arg1: typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex, + ) -> None: ... + def items(self) -> typing.ItemsView: ... + def keys(self) -> typing.KeysView: ... + def values(self) -> typing.ValuesView: ... + +def get_complex_map() -> MapStringComplex: ... +def get_vector_of_pairs() -> VectorPairStringDouble: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/typing.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/typing.pyi new file mode 100644 index 00000000..dc505538 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/typing.pyi @@ -0,0 +1,10 @@ +from __future__ import annotations + +import collections.abc + +import typing_extensions + +__all__: list[str] = ["get_buffer", "get_sequence"] + +def get_buffer(arg0: typing_extensions.Buffer) -> typing_extensions.Buffer: ... +def get_sequence(arg0: collections.abc.Sequence) -> collections.abc.Sequence: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi new file mode 100644 index 00000000..7c36d3fd --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -0,0 +1,36 @@ +from __future__ import annotations + +import datetime + +import numpy +from numpy import random + +__all__: list[str] = [ + "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.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi new file mode 100644 index 00000000..95cb8455 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi @@ -0,0 +1,37 @@ +from __future__ import annotations + +from demo._bindings import ( + aliases, + classes, + eigen, + enum, + flawed_bindings, + functions, + hidden_builtins, + issues, + methods, + numpy, + properties, + stl, + stl_bind, + typing, + values, +) + +__all__: list[str] = [ + "aliases", + "classes", + "eigen", + "enum", + "flawed_bindings", + "functions", + "hidden_builtins", + "issues", + "methods", + "numpy", + "properties", + "stl", + "stl_bind", + "typing", + "values", +] diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/__init__.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/__init__.pyi new file mode 100644 index 00000000..10d343e0 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/__init__.pyi @@ -0,0 +1,11 @@ +from __future__ import annotations + +from . import classes, functions, functions_3_8_plus, functions_3_9_plus, values + +__all__: list[str] = [ + "classes", + "functions", + "functions_3_8_plus", + "functions_3_9_plus", + "values", +] diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/classes.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/classes.pyi new file mode 100644 index 00000000..32aa068b --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/classes.pyi @@ -0,0 +1,21 @@ +from __future__ import annotations + +__all__: list[str] = ["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.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi new file mode 100644 index 00000000..5ed9ef3c --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/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__: list[str] = [ + "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.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi new file mode 100644 index 00000000..c55aed1d --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi @@ -0,0 +1,30 @@ +from __future__ import annotations + +import typing as typing + +__all__: list[str] = [ + "Expression", + "Token", + "args_mix", + "nested_current_module_annotations", + "typing", +] + +class Token: + pass + +class Expression: + pass + +def args_mix( + a: int, + b: float = 0.5, + c: str = "", + *args: int, + x: int = 1, + y=int, + **kwargs: dict[int, str], +): ... +def nested_current_module_annotations( + tokens: list[Token], expr: Expression | None = None +) -> dict[str, Expression]: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_9_plus.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_9_plus.pyi new file mode 100644 index 00000000..59b9b80c --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_9_plus.pyi @@ -0,0 +1,5 @@ +from __future__ import annotations + +__all__: list[str] = ["generic_alias_annotation"] + +def generic_alias_annotation(a: list[tuple[int]], b: dict[int, str]) -> list[float]: ... diff --git a/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/values.pyi b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/values.pyi new file mode 100644 index 00000000..07913391 --- /dev/null +++ b/tests/stubs/python-3.10/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/pure_python/values.pyi @@ -0,0 +1,4 @@ +from __future__ import annotations + +__all__: list[str] = ["callables_dict"] +callables_dict: dict = {"len": len, "int": int} diff --git a/tests/stubs/python-3.10/requirements.txt b/tests/stubs/python-3.10/requirements.txt new file mode 120000 index 00000000..c3092b3c --- /dev/null +++ b/tests/stubs/python-3.10/requirements.txt @@ -0,0 +1 @@ +../python-3.11/requirements.txt \ No newline at end of file diff --git a/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index dcef00e7..b37957b6 100644 --- a/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -1,5 +1,6 @@ from __future__ import annotations +import enum import typing __all__: list[str] = [ @@ -7,6 +8,7 @@ __all__: list[str] = [ "ConsoleForegroundColor", "Green", "Magenta", + "NativeColor", "None_", "Yellow", "accept_defaulted_enum", @@ -62,6 +64,13 @@ class ConsoleForegroundColor: @property def value(self) -> int: ... +class NativeColor(enum.IntEnum): + Blue: typing.ClassVar[NativeColor] # value = + Red: typing.ClassVar[NativeColor] # value = + @classmethod + def __new__(cls, value): ... + def __format__(self, format_spec): ... + def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... diff --git a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/enum.pyi index dcef00e7..3c587312 100644 --- a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/enum.pyi @@ -1,5 +1,6 @@ from __future__ import annotations +import enum import typing __all__: list[str] = [ @@ -7,6 +8,7 @@ __all__: list[str] = [ "ConsoleForegroundColor", "Green", "Magenta", + "NativeColor", "None_", "Yellow", "accept_defaulted_enum", @@ -62,6 +64,16 @@ class ConsoleForegroundColor: @property def value(self) -> int: ... +class NativeColor(enum.IntEnum): + Blue: typing.ClassVar[NativeColor] # value = + Red: typing.ClassVar[NativeColor] # value = + @classmethod + def __new__(cls, value): ... + def __format__(self, format_spec): + """ + Convert to a string according to format_spec. + """ + def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... diff --git a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index dcef00e7..3c587312 100644 --- a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -1,5 +1,6 @@ from __future__ import annotations +import enum import typing __all__: list[str] = [ @@ -7,6 +8,7 @@ __all__: list[str] = [ "ConsoleForegroundColor", "Green", "Magenta", + "NativeColor", "None_", "Yellow", "accept_defaulted_enum", @@ -62,6 +64,16 @@ class ConsoleForegroundColor: @property def value(self) -> int: ... +class NativeColor(enum.IntEnum): + Blue: typing.ClassVar[NativeColor] # value = + Red: typing.ClassVar[NativeColor] # value = + @classmethod + def __new__(cls, value): ... + def __format__(self, format_spec): + """ + Convert to a string according to format_spec. + """ + def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ...