From 147658e95bfed19277163316abea293e445c8f86 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 9 Jan 2025 14:31:57 -0800 Subject: [PATCH 1/6] Test: Inheritance Sort Issue This modifies the inheritance unit test to demonstrate the sorting issue. --- tests/demo-lib/include/demo/Inheritance.h | 20 ++++++++++--------- .../py-demo/bindings/src/modules/classes.cpp | 8 ++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/demo-lib/include/demo/Inheritance.h b/tests/demo-lib/include/demo/Inheritance.h index 1b577cbe..f99ffa4a 100644 --- a/tests/demo-lib/include/demo/Inheritance.h +++ b/tests/demo-lib/include/demo/Inheritance.h @@ -1,15 +1,17 @@ #pragma once #include -namespace demo{ +namespace demo +{ + // note: class stubs must not be sorted + // https://github.com/sizmailov/pybind11-stubgen/issues/231 -struct Base { - struct Inner{}; - std::string name; -}; - -struct Derived : Base { - int count; -}; + struct MyBase { + struct Inner{}; + std::string name; + }; + struct Derived : MyBase { + int count; + }; } diff --git a/tests/py-demo/bindings/src/modules/classes.cpp b/tests/py-demo/bindings/src/modules/classes.cpp index 347d9c11..f6689d10 100644 --- a/tests/py-demo/bindings/src/modules/classes.cpp +++ b/tests/py-demo/bindings/src/modules/classes.cpp @@ -19,13 +19,13 @@ void bind_classes_module(py::module&&m) { } { - py::class_ pyBase(m, "Base"); + py::class_ pyMyBase(m, "MyBase"); - pyBase.def_readwrite("name", &demo::Base::name); + pyMyBase.def_readwrite("name", &demo::MyBase::name); - py::class_(pyBase, "Inner"); + py::class_(pyMyBase, "Inner"); - py::class_(m, "Derived") + py::class_(m, "Derived") .def_readwrite("count", &demo::Derived::count); } From d017897245913f25a88c3b51a219863dfc50610c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20J=C3=BClg?= Date: Fri, 7 Nov 2025 15:12:33 +0100 Subject: [PATCH 2/6] Fix class sorting in case of inheritance Replaces alphabetical sorting with topological sorting to avoid wrong class order in case of inheritance. --- pybind11_stubgen/printer.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/pybind11_stubgen/printer.py b/pybind11_stubgen/printer.py index 8ef4af20..c692eee5 100644 --- a/pybind11_stubgen/printer.py +++ b/pybind11_stubgen/printer.py @@ -2,6 +2,7 @@ import dataclasses import sys +from collections import defaultdict from pybind11_stubgen.structs import ( Alias, @@ -33,6 +34,36 @@ class Printer: def __init__(self, invalid_expr_as_ellipses: bool): self.invalid_expr_as_ellipses = invalid_expr_as_ellipses + def _toposort_classes(self, classes: list[Class]) -> list[Class]: + in_degree = {c.name: 0 for c in classes} + graph = defaultdict(list) + class_map = {c.name: c for c in classes} + + for c in classes: + for base in c.bases: + base_name = base[-1] + if base_name in class_map: + graph[base_name].append(c.name) + in_degree[c.name] += 1 + + queue = sorted([name for name, degree in in_degree.items() if degree == 0]) + + sorted_classes = [] + while queue: + name = queue.pop(0) + sorted_classes.append(class_map[name]) + for neighbor in sorted(graph[name]): + in_degree[neighbor] -= 1 + if in_degree[neighbor] == 0: + queue.append(neighbor) + + if len(sorted_classes) == len(classes): + return sorted_classes + else: + # Cycle detected, fallback to alphabetical sort + remaining = [c for c in classes if c not in sorted_classes] + return sorted_classes + sorted(remaining, key=lambda c: c.name) + def print_alias(self, alias: Alias) -> list[str]: return [f"{alias.name} = {alias.origin}"] @@ -90,7 +121,7 @@ def print_class_body(self, class_: Class) -> list[str]: if class_.doc is not None: result.extend(self.print_docstring(class_.doc)) - for sub_class in sorted(class_.classes, key=lambda c: c.name): + for sub_class in self._toposort_classes(class_.classes): result.extend(self.print_class(sub_class)) modifier_order: dict[Modifier, int] = { @@ -225,7 +256,7 @@ def print_module(self, module: Module) -> list[str]: for type_var in sorted(module.type_vars, key=lambda t: t.name): result.extend(self.print_type_var(type_var)) - for class_ in sorted(module.classes, key=lambda c: c.name): + for class_ in self._toposort_classes(module.classes): result.extend(self.print_class(class_)) for func in sorted(module.functions, key=lambda f: f.name): From 7f6afa59cfb8a485d3e53311be62214fefd96d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20J=C3=BClg?= Date: Tue, 11 Nov 2025 21:19:05 +0100 Subject: [PATCH 3/6] feat: Add flexible class sorting strategies This commit introduces a new `--sort-by` CLI option to control the order of classes in the generated stub files, addressing feedback from PR #275 and providing a more robust solution for complex projects. The available sorting strategies are: - `definition` (default): Classes are ordered as they are defined in the pybind11 module. This is achieved by iterating over `module.__dict__` instead of `inspect.getmembers`, which sorts alphabetically. This should resolve ordering issues for most standard use cases. - `topological`: Uses a topological sort based on the class inheritance hierarchy. This is useful for projects with complex inheritance structures where base classes must be defined before derived classes. Additionally, this commit adds a warning when cycles in the inheritance graph is detected, to highlight the fallback to alphabetical sorting. --- pybind11_stubgen/__init__.py | 14 +++++++++++++- pybind11_stubgen/parser/mixins/parse.py | 2 +- pybind11_stubgen/printer.py | 23 ++++++++++++++++++++--- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/pybind11_stubgen/__init__.py b/pybind11_stubgen/__init__.py index 89f7a9c9..06207820 100644 --- a/pybind11_stubgen/__init__.py +++ b/pybind11_stubgen/__init__.py @@ -77,6 +77,7 @@ class CLIArgs(Namespace): exit_code: bool dry_run: bool stub_extension: str + sort_by: str module_name: str @@ -216,6 +217,14 @@ def regex_colon_path(regex_path: str) -> tuple[re.Pattern, str]: "Must be 'pyi' (default) or 'py'", ) + parser.add_argument( + "--sort-by", + type=str, + default="definition", + choices=["definition", "topological"], + help="Sort classes by 'definition' order (default) or 'topological' order.", + ) + parser.add_argument( "module_name", metavar="MODULE_NAME", @@ -309,7 +318,10 @@ def main(argv: Sequence[str] | None = None) -> None: args = arg_parser().parse_args(argv, namespace=CLIArgs()) parser = stub_parser_from_args(args) - printer = Printer(invalid_expr_as_ellipses=not args.print_invalid_expressions_as_is) + printer = Printer( + invalid_expr_as_ellipses=not args.print_invalid_expressions_as_is, + sort_by=args.sort_by, + ) out_dir, sub_dir = to_output_and_subdir( output_dir=args.output_dir, diff --git a/pybind11_stubgen/parser/mixins/parse.py b/pybind11_stubgen/parser/mixins/parse.py index f8867603..c83a1850 100644 --- a/pybind11_stubgen/parser/mixins/parse.py +++ b/pybind11_stubgen/parser/mixins/parse.py @@ -86,7 +86,7 @@ def handle_module( self, path: QualifiedName, module: types.ModuleType ) -> Module | None: result = Module(name=path[-1]) - for name, member in inspect.getmembers(module): + for name, member in module.__dict__.items(): obj = self.handle_module_member( QualifiedName([*path, Identifier(name)]), module, member ) diff --git a/pybind11_stubgen/printer.py b/pybind11_stubgen/printer.py index c692eee5..d6eb72a6 100644 --- a/pybind11_stubgen/printer.py +++ b/pybind11_stubgen/printer.py @@ -1,9 +1,12 @@ from __future__ import annotations import dataclasses +import logging import sys from collections import defaultdict +log = logging.getLogger("pybind11_stubgen") + from pybind11_stubgen.structs import ( Alias, Annotation, @@ -31,8 +34,9 @@ def indent_lines(lines: list[str], by=4) -> list[str]: class Printer: - def __init__(self, invalid_expr_as_ellipses: bool): + def __init__(self, invalid_expr_as_ellipses: bool, sort_by: str = "definition"): self.invalid_expr_as_ellipses = invalid_expr_as_ellipses + self.sort_by = sort_by def _toposort_classes(self, classes: list[Class]) -> list[Class]: in_degree = {c.name: 0 for c in classes} @@ -62,6 +66,11 @@ def _toposort_classes(self, classes: list[Class]) -> list[Class]: else: # Cycle detected, fallback to alphabetical sort remaining = [c for c in classes if c not in sorted_classes] + log.warning( + "Cycle detected in class inheritance involving: %s. " + "Falling back to alphabetical sort for these classes.", + [c.name for c in remaining], + ) return sorted_classes + sorted(remaining, key=lambda c: c.name) def print_alias(self, alias: Alias) -> list[str]: @@ -121,7 +130,11 @@ def print_class_body(self, class_: Class) -> list[str]: if class_.doc is not None: result.extend(self.print_docstring(class_.doc)) - for sub_class in self._toposort_classes(class_.classes): + classes_to_print = class_.classes + if self.sort_by == "topological": + classes_to_print = self._toposort_classes(class_.classes) + + for sub_class in classes_to_print: result.extend(self.print_class(sub_class)) modifier_order: dict[Modifier, int] = { @@ -256,7 +269,11 @@ def print_module(self, module: Module) -> list[str]: for type_var in sorted(module.type_vars, key=lambda t: t.name): result.extend(self.print_type_var(type_var)) - for class_ in self._toposort_classes(module.classes): + classes_to_print = module.classes + if self.sort_by == "topological": + classes_to_print = self._toposort_classes(module.classes) + + for class_ in classes_to_print: result.extend(self.print_class(class_)) for func in sorted(module.functions, key=lambda f: f.name): From 4fb61d384bfaa3e0d1cbdd42c5b42481cb213b85 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 22 Jan 2026 15:09:25 -0800 Subject: [PATCH 4/6] fix flake8 ``` flake8 --max-line-length=88 --extend-ignore=E203 --extend-exclude=venv/,.pytest_cache/,.ipynb_checkpoints/,tests/,tmp/,build/ ``` --- pybind11_stubgen/printer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pybind11_stubgen/printer.py b/pybind11_stubgen/printer.py index ae14480a..55854550 100644 --- a/pybind11_stubgen/printer.py +++ b/pybind11_stubgen/printer.py @@ -5,8 +5,6 @@ import sys from collections import defaultdict -log = logging.getLogger("pybind11_stubgen") - from pybind11_stubgen.structs import ( Alias, Annotation, @@ -28,6 +26,8 @@ Value, ) +log = logging.getLogger("pybind11_stubgen") + def indent_lines(lines: list[str], by=4) -> list[str]: return [" " * by + line for line in lines] @@ -51,7 +51,7 @@ def _toposort_classes(self, classes: list[Class]) -> list[Class]: in_degree[c.name] += 1 queue = sorted([name for name, degree in in_degree.items() if degree == 0]) - + sorted_classes = [] while queue: name = queue.pop(0) From c57778a5593c73ba7f74bacbb74df4370252a6d6 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 22 Jan 2026 14:51:57 -0800 Subject: [PATCH 5/6] Update silver files --- .../demo/_bindings/aliases/__init__.pyi | 8 +- .../demo/_bindings/classes.pyi | 40 +++++----- .../demo/_bindings/flawed_bindings.pyi | 4 +- .../demo/_bindings/functions.pyi | 2 - .../demo/_bindings/properties.pyi | 78 +++++++++---------- .../demo/_bindings/stl.pyi | 6 +- .../demo/_bindings/stl_bind.pyi | 46 +++++------ .../demo/_bindings/aliases/__init__.pyi | 8 +- .../demo/_bindings/classes.pyi | 40 +++++----- .../demo/_bindings/flawed_bindings.pyi | 4 +- .../demo/_bindings/functions.pyi | 4 - .../demo/_bindings/properties.pyi | 78 +++++++++---------- .../demo/_bindings/stl.pyi | 6 +- .../demo/_bindings/stl_bind.pyi | 48 ++++++------ .../demo/_bindings/aliases/__init__.pyi | 8 +- .../demo/_bindings/classes.pyi | 40 +++++----- .../demo/_bindings/flawed_bindings.pyi | 4 +- .../demo/_bindings/functions.pyi | 4 - .../demo/_bindings/properties.pyi | 78 +++++++++---------- .../demo/_bindings/stl.pyi | 6 +- .../demo/_bindings/stl_bind.pyi | 48 ++++++------ .../demo/_bindings/aliases/__init__.pyi | 8 +- .../demo/_bindings/classes.pyi | 40 +++++----- .../demo/_bindings/flawed_bindings.pyi | 4 +- .../demo/_bindings/properties.pyi | 78 +++++++++---------- .../demo/_bindings/stl_bind.pyi | 46 +++++------ .../demo/_bindings/aliases/__init__.pyi | 8 +- .../demo/_bindings/classes.pyi | 40 +++++----- .../demo/_bindings/flawed_bindings.pyi | 4 +- .../demo/_bindings/properties.pyi | 78 +++++++++---------- .../demo/_bindings/stl_bind.pyi | 46 +++++------ .../demo/_bindings/aliases/__init__.pyi | 8 +- .../demo/_bindings/classes.pyi | 40 +++++----- .../demo/_bindings/eigen.pyi | 41 +++++----- .../demo/_bindings/flawed_bindings.pyi | 4 +- .../demo/_bindings/functions.pyi | 4 - .../demo/_bindings/numpy.pyi | 13 +--- .../demo/_bindings/properties.pyi | 78 +++++++++---------- .../demo/_bindings/stl.pyi | 11 +-- .../demo/_bindings/stl_bind.pyi | 48 ++++++------ .../demo/pure_python/__init__.pyi | 10 ++- .../demo/pure_python/functions.pyi | 2 + .../demo/pure_python/functions_3_9_plus.pyi | 5 ++ 43 files changed, 575 insertions(+), 601 deletions(-) create mode 100644 tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_9_plus.pyi diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi index 93963f4b..87eebc4f 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi @@ -38,16 +38,16 @@ __all__: list[str] = [ "random", ] -class Color: - pass - class Dummy: linalg = numpy.linalg +class Color: + pass + 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 +local_func_alias = func diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index ea36dda6..1f432976 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,26 +2,7 @@ from __future__ import annotations import typing -__all__: list[str] = ["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: ... +__all__: list[str] = ["CppException", "Derived", "Foo", "MyBase", "Outer"] class Outer: class Inner: @@ -55,3 +36,22 @@ class Outer: def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner + +class MyBase: + class Inner: + pass + name: str + +class Derived(MyBase): + count: int + +class Foo: + class FooChild: + def __init__(self) -> None: ... + def g(self) -> None: ... + + def __init__(self) -> None: ... + def f(self) -> None: ... + +class CppException(Exception): + pass diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index 4f3886ea..96774842 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -10,10 +10,10 @@ __all__: list[str] = [ "get_unbound_type", ] -class Enum: +class Unbound: pass -class Unbound: +class Enum: pass def accept_unbound_enum(arg0: ...) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi index 316386c8..2f467b68 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi @@ -5,7 +5,6 @@ import typing __all__: list[str] = [ "Foo", "accept_callable", - "accept_frozenset", "accept_py_handle", "accept_py_object", "accept_set", @@ -28,7 +27,6 @@ class Foo: def __init__(self, arg0: int) -> None: ... def accept_callable(arg0: typing.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: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi index 9d81595c..f19453b4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi @@ -9,32 +9,23 @@ __all__: list[str] = [ "WithoutDoc", ] -class WithGetterSetterDoc: +class WithoutDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls + 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(self) -> int: - """ - getter doc token - """ - @def_property.setter - def def_property(self, arg1: int) -> None: - """ - setter doc token - """ + def def_property_readonly(self) -> int: ... @property - def def_property_readonly(self) -> int: - """ - getter doc token - """ + def def_readonly(self) -> int: ... -class WithPropAndGetterSetterDoc: +class WithPropDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls + User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 @@ -51,10 +42,22 @@ class WithPropAndGetterSetterDoc: """ 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 WithPropDoc: +class WithGetterSetterDoc: """ - User docstring provided only to `def_` calls + 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 @@ -62,38 +65,35 @@ class WithPropDoc: @property def def_property(self) -> int: """ - prop doc token + getter 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: + def def_property(self, arg1: int) -> None: """ - prop doc token + setter doc token """ @property - def def_readwrite(self) -> int: + def def_property_readonly(self) -> int: """ - prop doc token + getter doc token """ - @def_readwrite.setter - def def_readwrite(self, arg0: int) -> None: ... -class WithoutDoc: +class WithPropAndGetterSetterDoc: """ - No user docstring provided + 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 - def_property: int - def_readwrite: int @property - def def_property_readonly(self) -> int: ... + def def_property(self) -> int: + """ + prop doc token + """ + @def_property.setter + def def_property(self, arg1: int) -> None: ... @property - def def_readonly(self) -> int: ... + def def_property_readonly(self) -> int: + """ + prop doc token + """ diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi index bd5bb496..5df5cea8 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__: list[str] = [ "std_array", "std_map", @@ -12,9 +10,7 @@ __all__: list[str] = [ "std_vector", ] -def std_array( - arg0: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] -) -> typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)]: ... +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: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi index 3547ce70..8e14cfd9 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi @@ -9,29 +9,6 @@ __all__: list[str] = [ "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[str, complex]: ... - def keys(self) -> typing.KeysView[str]: ... - def values(self) -> typing.ValuesView[complex]: ... - class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: @@ -120,5 +97,28 @@ class VectorPairStringDouble: 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) -> 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]: ... + def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi index 93963f4b..87eebc4f 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi @@ -38,16 +38,16 @@ __all__: list[str] = [ "random", ] -class Color: - pass - class Dummy: linalg = numpy.linalg +class Color: + pass + 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 +local_func_alias = func diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index ea36dda6..1f432976 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,26 +2,7 @@ from __future__ import annotations import typing -__all__: list[str] = ["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: ... +__all__: list[str] = ["CppException", "Derived", "Foo", "MyBase", "Outer"] class Outer: class Inner: @@ -55,3 +36,22 @@ class Outer: def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner + +class MyBase: + class Inner: + pass + name: str + +class Derived(MyBase): + count: int + +class Foo: + class FooChild: + def __init__(self) -> None: ... + def g(self) -> None: ... + + def __init__(self) -> None: ... + def f(self) -> None: ... + +class CppException(Exception): + pass diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index 4f3886ea..96774842 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -10,10 +10,10 @@ __all__: list[str] = [ "get_unbound_type", ] -class Enum: +class Unbound: pass -class Unbound: +class Enum: pass def accept_unbound_enum(arg0: ...) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi index 72ab6498..2f467b68 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi @@ -4,9 +4,7 @@ import typing __all__: list[str] = [ "Foo", - "accept_annotated_callable", "accept_callable", - "accept_frozenset", "accept_py_handle", "accept_py_object", "accept_set", @@ -28,9 +26,7 @@ __all__: list[str] = [ class Foo: def __init__(self, arg0: int) -> None: ... -def accept_annotated_callable(arg0: typing.Callable[[int, int], int]) -> typing.Any: ... def accept_callable(arg0: typing.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: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi index 9d81595c..f19453b4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi @@ -9,32 +9,23 @@ __all__: list[str] = [ "WithoutDoc", ] -class WithGetterSetterDoc: +class WithoutDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls + 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(self) -> int: - """ - getter doc token - """ - @def_property.setter - def def_property(self, arg1: int) -> None: - """ - setter doc token - """ + def def_property_readonly(self) -> int: ... @property - def def_property_readonly(self) -> int: - """ - getter doc token - """ + def def_readonly(self) -> int: ... -class WithPropAndGetterSetterDoc: +class WithPropDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls + User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 @@ -51,10 +42,22 @@ class WithPropAndGetterSetterDoc: """ 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 WithPropDoc: +class WithGetterSetterDoc: """ - User docstring provided only to `def_` calls + 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 @@ -62,38 +65,35 @@ class WithPropDoc: @property def def_property(self) -> int: """ - prop doc token + getter 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: + def def_property(self, arg1: int) -> None: """ - prop doc token + setter doc token """ @property - def def_readwrite(self) -> int: + def def_property_readonly(self) -> int: """ - prop doc token + getter doc token """ - @def_readwrite.setter - def def_readwrite(self, arg0: int) -> None: ... -class WithoutDoc: +class WithPropAndGetterSetterDoc: """ - No user docstring provided + 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 - def_property: int - def_readwrite: int @property - def def_property_readonly(self) -> int: ... + def def_property(self) -> int: + """ + prop doc token + """ + @def_property.setter + def def_property(self, arg1: int) -> None: ... @property - def def_readonly(self) -> int: ... + def def_property_readonly(self) -> int: + """ + prop doc token + """ diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi index bd5bb496..5df5cea8 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__: list[str] = [ "std_array", "std_map", @@ -12,9 +10,7 @@ __all__: list[str] = [ "std_vector", ] -def std_array( - arg0: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] -) -> typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)]: ... +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: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi index 6f1f9b67..8e14cfd9 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi @@ -9,29 +9,6 @@ __all__: list[str] = [ "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[str]: ... - 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: ... - def keys(self) -> typing.KeysView: ... - def values(self) -> typing.ValuesView: ... - class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: @@ -69,7 +46,7 @@ class VectorPairStringDouble: """ @typing.overload def __init__(self, arg0: typing.Iterable) -> None: ... - def __iter__(self) -> typing.Iterator[tuple[str, float]]: ... + def __iter__(self) -> typing.Iterator: ... def __len__(self) -> int: ... def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload @@ -120,5 +97,28 @@ class VectorPairStringDouble: 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) -> 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]: ... + def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliases/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliases/__init__.pyi index 93963f4b..87eebc4f 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliases/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliases/__init__.pyi @@ -38,16 +38,16 @@ __all__: list[str] = [ "random", ] -class Color: - pass - class Dummy: linalg = numpy.linalg +class Color: + pass + 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 +local_func_alias = func diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/classes.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/classes.pyi index ea36dda6..1f432976 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/classes.pyi @@ -2,26 +2,7 @@ from __future__ import annotations import typing -__all__: list[str] = ["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: ... +__all__: list[str] = ["CppException", "Derived", "Foo", "MyBase", "Outer"] class Outer: class Inner: @@ -55,3 +36,22 @@ class Outer: def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner + +class MyBase: + class Inner: + pass + name: str + +class Derived(MyBase): + count: int + +class Foo: + class FooChild: + def __init__(self) -> None: ... + def g(self) -> None: ... + + def __init__(self) -> None: ... + def f(self) -> None: ... + +class CppException(Exception): + pass diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi index 4f3886ea..96774842 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi @@ -10,10 +10,10 @@ __all__: list[str] = [ "get_unbound_type", ] -class Enum: +class Unbound: pass -class Unbound: +class Enum: pass def accept_unbound_enum(arg0: ...) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/functions.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/functions.pyi index 72ab6498..2f467b68 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/functions.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/functions.pyi @@ -4,9 +4,7 @@ import typing __all__: list[str] = [ "Foo", - "accept_annotated_callable", "accept_callable", - "accept_frozenset", "accept_py_handle", "accept_py_object", "accept_set", @@ -28,9 +26,7 @@ __all__: list[str] = [ class Foo: def __init__(self, arg0: int) -> None: ... -def accept_annotated_callable(arg0: typing.Callable[[int, int], int]) -> typing.Any: ... def accept_callable(arg0: typing.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: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/properties.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/properties.pyi index 9d81595c..f19453b4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/properties.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/properties.pyi @@ -9,32 +9,23 @@ __all__: list[str] = [ "WithoutDoc", ] -class WithGetterSetterDoc: +class WithoutDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls + 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(self) -> int: - """ - getter doc token - """ - @def_property.setter - def def_property(self, arg1: int) -> None: - """ - setter doc token - """ + def def_property_readonly(self) -> int: ... @property - def def_property_readonly(self) -> int: - """ - getter doc token - """ + def def_readonly(self) -> int: ... -class WithPropAndGetterSetterDoc: +class WithPropDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls + User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 @@ -51,10 +42,22 @@ class WithPropAndGetterSetterDoc: """ 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 WithPropDoc: +class WithGetterSetterDoc: """ - User docstring provided only to `def_` calls + 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 @@ -62,38 +65,35 @@ class WithPropDoc: @property def def_property(self) -> int: """ - prop doc token + getter 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: + def def_property(self, arg1: int) -> None: """ - prop doc token + setter doc token """ @property - def def_readwrite(self) -> int: + def def_property_readonly(self) -> int: """ - prop doc token + getter doc token """ - @def_readwrite.setter - def def_readwrite(self, arg0: int) -> None: ... -class WithoutDoc: +class WithPropAndGetterSetterDoc: """ - No user docstring provided + 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 - def_property: int - def_readwrite: int @property - def def_property_readonly(self) -> int: ... + def def_property(self) -> int: + """ + prop doc token + """ + @def_property.setter + def def_property(self, arg1: int) -> None: ... @property - def def_readonly(self) -> int: ... + def def_property_readonly(self) -> int: + """ + prop doc token + """ diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/stl.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/stl.pyi index bd5bb496..5df5cea8 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/stl.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/stl.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__: list[str] = [ "std_array", "std_map", @@ -12,9 +10,7 @@ __all__: list[str] = [ "std_vector", ] -def std_array( - arg0: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] -) -> typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)]: ... +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: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/stl_bind.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/stl_bind.pyi index 6f1f9b67..8e14cfd9 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/stl_bind.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/stl_bind.pyi @@ -9,29 +9,6 @@ __all__: list[str] = [ "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[str]: ... - 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: ... - def keys(self) -> typing.KeysView: ... - def values(self) -> typing.ValuesView: ... - class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: @@ -69,7 +46,7 @@ class VectorPairStringDouble: """ @typing.overload def __init__(self, arg0: typing.Iterable) -> None: ... - def __iter__(self) -> typing.Iterator[tuple[str, float]]: ... + def __iter__(self) -> typing.Iterator: ... def __len__(self) -> int: ... def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload @@ -120,5 +97,28 @@ class VectorPairStringDouble: 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) -> 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]: ... + def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi index 93963f4b..87eebc4f 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi @@ -38,16 +38,16 @@ __all__: list[str] = [ "random", ] -class Color: - pass - class Dummy: linalg = numpy.linalg +class Color: + pass + 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 +local_func_alias = func diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index ea36dda6..1f432976 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,26 +2,7 @@ from __future__ import annotations import typing -__all__: list[str] = ["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: ... +__all__: list[str] = ["CppException", "Derived", "Foo", "MyBase", "Outer"] class Outer: class Inner: @@ -55,3 +36,22 @@ class Outer: def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner + +class MyBase: + class Inner: + pass + name: str + +class Derived(MyBase): + count: int + +class Foo: + class FooChild: + def __init__(self) -> None: ... + def g(self) -> None: ... + + def __init__(self) -> None: ... + def f(self) -> None: ... + +class CppException(Exception): + pass diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index 4f3886ea..96774842 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -10,10 +10,10 @@ __all__: list[str] = [ "get_unbound_type", ] -class Enum: +class Unbound: pass -class Unbound: +class Enum: pass def accept_unbound_enum(arg0: ...) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi index 9d81595c..f19453b4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi @@ -9,32 +9,23 @@ __all__: list[str] = [ "WithoutDoc", ] -class WithGetterSetterDoc: +class WithoutDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls + 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(self) -> int: - """ - getter doc token - """ - @def_property.setter - def def_property(self, arg1: int) -> None: - """ - setter doc token - """ + def def_property_readonly(self) -> int: ... @property - def def_property_readonly(self) -> int: - """ - getter doc token - """ + def def_readonly(self) -> int: ... -class WithPropAndGetterSetterDoc: +class WithPropDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls + User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 @@ -51,10 +42,22 @@ class WithPropAndGetterSetterDoc: """ 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 WithPropDoc: +class WithGetterSetterDoc: """ - User docstring provided only to `def_` calls + 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 @@ -62,38 +65,35 @@ class WithPropDoc: @property def def_property(self) -> int: """ - prop doc token + getter 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: + def def_property(self, arg1: int) -> None: """ - prop doc token + setter doc token """ @property - def def_readwrite(self) -> int: + def def_property_readonly(self) -> int: """ - prop doc token + getter doc token """ - @def_readwrite.setter - def def_readwrite(self, arg0: int) -> None: ... -class WithoutDoc: +class WithPropAndGetterSetterDoc: """ - No user docstring provided + 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 - def_property: int - def_readwrite: int @property - def def_property_readonly(self) -> int: ... + def def_property(self) -> int: + """ + prop doc token + """ + @def_property.setter + def def_property(self, arg1: int) -> None: ... @property - def def_readonly(self) -> int: ... + def def_property_readonly(self) -> int: + """ + prop doc token + """ diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi index 6f1f9b67..2cac91aa 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi @@ -9,29 +9,6 @@ __all__: list[str] = [ "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[str]: ... - 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: ... - def keys(self) -> typing.KeysView: ... - def values(self) -> typing.ValuesView: ... - class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: @@ -120,5 +97,28 @@ class VectorPairStringDouble: 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) -> typing.Iterator[str]: ... + 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: ... + 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.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi index 93963f4b..87eebc4f 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi @@ -38,16 +38,16 @@ __all__: list[str] = [ "random", ] -class Color: - pass - class Dummy: linalg = numpy.linalg +class Color: + pass + 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 +local_func_alias = func diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index ea36dda6..1f432976 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,26 +2,7 @@ from __future__ import annotations import typing -__all__: list[str] = ["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: ... +__all__: list[str] = ["CppException", "Derived", "Foo", "MyBase", "Outer"] class Outer: class Inner: @@ -55,3 +36,22 @@ class Outer: def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner + +class MyBase: + class Inner: + pass + name: str + +class Derived(MyBase): + count: int + +class Foo: + class FooChild: + def __init__(self) -> None: ... + def g(self) -> None: ... + + def __init__(self) -> None: ... + def f(self) -> None: ... + +class CppException(Exception): + pass diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index 4f3886ea..96774842 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -10,10 +10,10 @@ __all__: list[str] = [ "get_unbound_type", ] -class Enum: +class Unbound: pass -class Unbound: +class Enum: pass def accept_unbound_enum(arg0: ...) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi index 9d81595c..f19453b4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi @@ -9,32 +9,23 @@ __all__: list[str] = [ "WithoutDoc", ] -class WithGetterSetterDoc: +class WithoutDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls + 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(self) -> int: - """ - getter doc token - """ - @def_property.setter - def def_property(self, arg1: int) -> None: - """ - setter doc token - """ + def def_property_readonly(self) -> int: ... @property - def def_property_readonly(self) -> int: - """ - getter doc token - """ + def def_readonly(self) -> int: ... -class WithPropAndGetterSetterDoc: +class WithPropDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls + User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 @@ -51,10 +42,22 @@ class WithPropAndGetterSetterDoc: """ 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 WithPropDoc: +class WithGetterSetterDoc: """ - User docstring provided only to `def_` calls + 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 @@ -62,38 +65,35 @@ class WithPropDoc: @property def def_property(self) -> int: """ - prop doc token + getter 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: + def def_property(self, arg1: int) -> None: """ - prop doc token + setter doc token """ @property - def def_readwrite(self) -> int: + def def_property_readonly(self) -> int: """ - prop doc token + getter doc token """ - @def_readwrite.setter - def def_readwrite(self, arg0: int) -> None: ... -class WithoutDoc: +class WithPropAndGetterSetterDoc: """ - No user docstring provided + 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 - def_property: int - def_readwrite: int @property - def def_property_readonly(self) -> int: ... + def def_property(self) -> int: + """ + prop doc token + """ + @def_property.setter + def def_property(self, arg1: int) -> None: ... @property - def def_readonly(self) -> int: ... + def def_property_readonly(self) -> int: + """ + prop doc token + """ diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi index 7133e4cc..8e14cfd9 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi @@ -9,29 +9,6 @@ __all__: list[str] = [ "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: @@ -120,5 +97,28 @@ class VectorPairStringDouble: 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) -> 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]: ... + def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi index 93963f4b..87eebc4f 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliases/__init__.pyi @@ -38,16 +38,16 @@ __all__: list[str] = [ "random", ] -class Color: - pass - class Dummy: linalg = numpy.linalg +class Color: + pass + 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 +local_func_alias = func diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index ea36dda6..1f432976 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,26 +2,7 @@ from __future__ import annotations import typing -__all__: list[str] = ["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: ... +__all__: list[str] = ["CppException", "Derived", "Foo", "MyBase", "Outer"] class Outer: class Inner: @@ -55,3 +36,22 @@ class Outer: def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner + +class MyBase: + class Inner: + pass + name: str + +class Derived(MyBase): + count: int + +class Foo: + class FooChild: + def __init__(self) -> None: ... + def g(self) -> None: ... + + def __init__(self) -> None: ... + def f(self) -> None: ... + +class CppException(Exception): + pass diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/eigen.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/eigen.pyi index a75e8c15..8e453374 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/eigen.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/eigen.pyi @@ -1,9 +1,10 @@ from __future__ import annotations +import typing + import numpy import pybind11_stubgen.typing_ext import scipy.sparse -import typing_extensions __all__: list[str] = [ "accept_matrix_int", @@ -22,31 +23,31 @@ __all__: list[str] = [ ] def accept_matrix_int( - arg0: typing_extensions.Annotated[ + arg0: typing.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ] ) -> None: ... def accept_vector_float64( - arg0: typing_extensions.Annotated[ + arg0: typing.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ] ) -> None: ... def dense_matrix_c( - arg0: typing_extensions.Annotated[ + arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] -) -> typing_extensions.Annotated[ +) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def dense_matrix_r( - arg0: typing_extensions.Annotated[ + arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] -) -> typing_extensions.Annotated[ +) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def fixed_mutator_a( - arg0: typing_extensions.Annotated[ + arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), @@ -54,7 +55,7 @@ def fixed_mutator_a( ] ) -> None: ... def fixed_mutator_c( - arg0: typing_extensions.Annotated[ + arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), @@ -63,7 +64,7 @@ def fixed_mutator_c( ] ) -> None: ... def fixed_mutator_r( - arg0: typing_extensions.Annotated[ + arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), @@ -72,28 +73,28 @@ def fixed_mutator_r( ] ) -> None: ... def four_col_matrix_r( - arg0: typing_extensions.Annotated[ + arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ] -) -> typing_extensions.Annotated[ +) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ]: ... def four_row_matrix_r( - arg0: typing_extensions.Annotated[ + arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ] -) -> typing_extensions.Annotated[ +) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ]: ... -def get_matrix_int() -> typing_extensions.Annotated[ +def get_matrix_int() -> typing.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ]: ... -def get_vector_float64() -> typing_extensions.Annotated[ +def get_vector_float64() -> typing.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ]: ... def sparse_matrix_c( - arg0: typing_extensions.Annotated[scipy.sparse.csc_matrix, numpy.float32] -) -> typing_extensions.Annotated[scipy.sparse.csc_matrix, numpy.float32]: ... + arg0: typing.Annotated[scipy.sparse.csc_matrix, numpy.float32] +) -> typing.Annotated[scipy.sparse.csc_matrix, numpy.float32]: ... def sparse_matrix_r( - arg0: typing_extensions.Annotated[scipy.sparse.csr_matrix, numpy.float32] -) -> typing_extensions.Annotated[scipy.sparse.csr_matrix, numpy.float32]: ... + arg0: typing.Annotated[scipy.sparse.csr_matrix, numpy.float32] +) -> typing.Annotated[scipy.sparse.csr_matrix, numpy.float32]: ... diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index 4f3886ea..96774842 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -10,10 +10,10 @@ __all__: list[str] = [ "get_unbound_type", ] -class Enum: +class Unbound: pass -class Unbound: +class Enum: pass def accept_unbound_enum(arg0: ...) -> int: ... diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi index 72ab6498..2f467b68 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/functions.pyi @@ -4,9 +4,7 @@ import typing __all__: list[str] = [ "Foo", - "accept_annotated_callable", "accept_callable", - "accept_frozenset", "accept_py_handle", "accept_py_object", "accept_set", @@ -28,9 +26,7 @@ __all__: list[str] = [ class Foo: def __init__(self, arg0: int) -> None: ... -def accept_annotated_callable(arg0: typing.Callable[[int, int], int]) -> typing.Any: ... def accept_callable(arg0: typing.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: ... diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/numpy.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/numpy.pyi index d1fe4668..e211caaf 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/numpy.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/numpy.pyi @@ -3,7 +3,6 @@ from __future__ import annotations import typing import numpy -import typing_extensions __all__: list[str] = [ "accept_ndarray_float64", @@ -14,13 +13,9 @@ __all__: list[str] = [ ] def accept_ndarray_float64( - arg0: typing_extensions.Annotated[numpy.ndarray, numpy.float64] + arg0: typing.Annotated[numpy.ndarray, numpy.float64] ) -> None: ... -def accept_ndarray_int( - arg0: typing_extensions.Annotated[numpy.ndarray, numpy.int32] -) -> None: ... -def get_ndarray_float64() -> typing_extensions.Annotated[ - numpy.ndarray, numpy.float64 -]: ... -def get_ndarray_int() -> typing_extensions.Annotated[numpy.ndarray, numpy.int32]: ... +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]: ... def return_dtype() -> numpy.dtype[typing.Any]: ... diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi index 9d81595c..f19453b4 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/properties.pyi @@ -9,32 +9,23 @@ __all__: list[str] = [ "WithoutDoc", ] -class WithGetterSetterDoc: +class WithoutDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls + 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(self) -> int: - """ - getter doc token - """ - @def_property.setter - def def_property(self, arg1: int) -> None: - """ - setter doc token - """ + def def_property_readonly(self) -> int: ... @property - def def_property_readonly(self) -> int: - """ - getter doc token - """ + def def_readonly(self) -> int: ... -class WithPropAndGetterSetterDoc: +class WithPropDoc: """ - User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls + User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 @@ -51,10 +42,22 @@ class WithPropAndGetterSetterDoc: """ 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 WithPropDoc: +class WithGetterSetterDoc: """ - User docstring provided only to `def_` calls + 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 @@ -62,38 +65,35 @@ class WithPropDoc: @property def def_property(self) -> int: """ - prop doc token + getter 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: + def def_property(self, arg1: int) -> None: """ - prop doc token + setter doc token """ @property - def def_readwrite(self) -> int: + def def_property_readonly(self) -> int: """ - prop doc token + getter doc token """ - @def_readwrite.setter - def def_readwrite(self, arg0: int) -> None: ... -class WithoutDoc: +class WithPropAndGetterSetterDoc: """ - No user docstring provided + 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 - def_property: int - def_readwrite: int @property - def def_property_readonly(self) -> int: ... + def def_property(self) -> int: + """ + prop doc token + """ + @def_property.setter + def def_property(self, arg1: int) -> None: ... @property - def def_readonly(self) -> int: ... + def def_property_readonly(self) -> int: + """ + prop doc token + """ diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi index 906037e7..5df5cea8 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl.pyi @@ -2,9 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext -import typing_extensions - __all__: list[str] = [ "std_array", "std_map", @@ -13,13 +10,7 @@ __all__: list[str] = [ "std_vector", ] -def std_array( - arg0: typing_extensions.Annotated[ - list[int], pybind11_stubgen.typing_ext.FixedSize(3) - ] -) -> typing_extensions.Annotated[ - list[int], pybind11_stubgen.typing_ext.FixedSize(3) -]: ... +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: ... diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi index 6f1f9b67..8e14cfd9 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/stl_bind.pyi @@ -9,29 +9,6 @@ __all__: list[str] = [ "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[str]: ... - 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: ... - def keys(self) -> typing.KeysView: ... - def values(self) -> typing.ValuesView: ... - class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: @@ -69,7 +46,7 @@ class VectorPairStringDouble: """ @typing.overload def __init__(self, arg0: typing.Iterable) -> None: ... - def __iter__(self) -> typing.Iterator[tuple[str, float]]: ... + def __iter__(self) -> typing.Iterator: ... def __len__(self) -> int: ... def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload @@ -120,5 +97,28 @@ class VectorPairStringDouble: 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) -> 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]: ... + def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_python/__init__.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_python/__init__.pyi index c0243fb7..10d343e0 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_python/__init__.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_python/__init__.pyi @@ -1,5 +1,11 @@ from __future__ import annotations -from . import classes, functions, functions_3_8_plus, values +from . import classes, functions, functions_3_8_plus, functions_3_9_plus, values -__all__: list[str] = ["classes", "functions", "functions_3_8_plus", "values"] +__all__: list[str] = [ + "classes", + "functions", + "functions_3_8_plus", + "functions_3_9_plus", + "values", +] diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi index 13f2855c..5ed9ef3c 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi @@ -4,12 +4,14 @@ 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", diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_9_plus.pyi b/tests/stubs/python-3.8/pybind11-v2.13/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.8/pybind11-v2.13/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]: ... From 4dbe096d26ac0b3abc73705f901f53cdb9e15d2d Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 22 Jan 2026 15:00:39 -0800 Subject: [PATCH 6/6] Run: `./tests/check-demo-errors-generation.sh` --- tests/demo.errors.stderr.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/demo.errors.stderr.txt b/tests/demo.errors.stderr.txt index f8fd843d..fb4dbc47 100644 --- a/tests/demo.errors.stderr.txt +++ b/tests/demo.errors.stderr.txt @@ -1,16 +1,16 @@ -pybind11_stubgen - [ ERROR] In demo._bindings.aliases.foreign_enum_default : Invalid expression '' -pybind11_stubgen - [ ERROR] In demo._bindings.eigen.dense_matrix_c : Can't find/import 'm' -pybind11_stubgen - [ ERROR] In demo._bindings.eigen.dense_matrix_c : Can't find/import 'n' pybind11_stubgen - [ ERROR] In demo._bindings.eigen.dense_matrix_r : Can't find/import 'm' pybind11_stubgen - [ ERROR] In demo._bindings.eigen.dense_matrix_r : Can't find/import 'n' -pybind11_stubgen - [ ERROR] In demo._bindings.eigen.four_col_matrix_r : Can't find/import 'm' +pybind11_stubgen - [ ERROR] In demo._bindings.eigen.dense_matrix_c : Can't find/import 'm' +pybind11_stubgen - [ ERROR] In demo._bindings.eigen.dense_matrix_c : Can't find/import 'n' pybind11_stubgen - [ ERROR] In demo._bindings.eigen.four_row_matrix_r : Can't find/import 'n' +pybind11_stubgen - [ ERROR] In demo._bindings.eigen.four_col_matrix_r : Can't find/import 'm' pybind11_stubgen - [ ERROR] In demo._bindings.enum.accept_defaulted_enum : Invalid expression '' -pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.accept_unbound_enum : Invalid expression '(anonymous namespace)::Enum' -pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.accept_unbound_enum_defaulted : Invalid expression '' +pybind11_stubgen - [ ERROR] In demo._bindings.aliases.foreign_enum_default : Invalid expression '' +pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.get_unbound_type : Invalid expression '(anonymous namespace)::Unbound' pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.accept_unbound_type : Invalid expression '(anonymous namespace)::Unbound' +pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.accept_unbound_enum : Invalid expression '(anonymous namespace)::Enum' pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.accept_unbound_type_defaulted : Invalid expression '' -pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.get_unbound_type : Invalid expression '(anonymous namespace)::Unbound' +pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.accept_unbound_enum_defaulted : Invalid expression '' pybind11_stubgen - [WARNING] Enum-like str representations were found with no matching mapping to the enum class location. Use `--enum-class-locations` to specify full path to the following enum(s): - ConsoleForegroundColor