From 30d54b2a1d79c1ce2029f41a607c77b5b000c16e Mon Sep 17 00:00:00 2001 From: Skarn Date: Sat, 17 Jan 2026 23:36:36 +0300 Subject: [PATCH 01/13] Better handling of hidden builtins Added a generalized algorithm to handle builtins exposed via the `types` module, but reporting `builtins` at introspection. --- pybind11_stubgen/parser/mixins/fix.py | 36 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/pybind11_stubgen/parser/mixins/fix.py b/pybind11_stubgen/parser/mixins/fix.py index 87898906..e0ccacb9 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -265,20 +265,42 @@ def handle_module( class FixBuiltinTypes(IParser): _any_type = QualifiedName.from_str("typing.Any") + _hidden_builtins = { + getattr(types, name).__qualname__: name for name in dir(types) if isinstance( + getattr(types, name), type) + and getattr(getattr(types, name), '__module__', None) == 'builtins' + and not hasattr(builtins, name) + } + _hidden_builtins_overrides = { + "function": "typing.Callable", + "builtin_function_or_method": "typing.Callable", + } def handle_type(self, type_: type) -> QualifiedName: if type_.__qualname__ == "PyCapsule" and type_.__module__ == "builtins": return self._any_type - + result = super().handle_type(type_) if result[0] == "builtins": - if result[1] == "NoneType": - return QualifiedName((Identifier("None"),)) - if result[1] in ("function", "builtin_function_or_method"): - callable_t = self.parse_annotation_str("typing.Callable") - assert isinstance(callable_t, ResolvedType) - return callable_t.name + + typename = result[1] + + if typename == "NoneType": + return QualifiedName((Identifier("None"),)) + + hidden_builtin = self._hidden_builtins.get(typename) + if hidden_builtin is not None: + hidden_builtin_override = self._hidden_builtins_overrides.get( + typename + ) + + annotation = hidden_builtin_override or 'types.%s' % hidden_builtin + + override_t = self.parse_annotation_str(annotation) + assert isinstance(override_t, ResolvedType) + return override_t.name + return QualifiedName(result[1:]) return result From 11459c32e8e1b14e1d86b1eda9b9bf0a7ce91589 Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 22 Jan 2026 21:13:56 +0300 Subject: [PATCH 02/13] add descriptive comments --- pybind11_stubgen/parser/mixins/fix.py | 37 +++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/pybind11_stubgen/parser/mixins/fix.py b/pybind11_stubgen/parser/mixins/fix.py index e0ccacb9..e0f674dd 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -265,43 +265,54 @@ def handle_module( class FixBuiltinTypes(IParser): _any_type = QualifiedName.from_str("typing.Any") + _hidden_builtins = { - getattr(types, name).__qualname__: name for name in dir(types) if isinstance( - getattr(types, name), type) - and getattr(getattr(types, name), '__module__', None) == 'builtins' - and not hasattr(builtins, name) + getattr(types, name).__qualname__: name + for name in dir(types) + if isinstance(getattr(types, name), type) + and getattr(getattr(types, name), "__module__", None) + == "builtins" # defined in types, but reports `builtins` + and not hasattr(builtins, name) # not actually available in `builtins` } + """Types by their real name that are available in the `types` module, but report `builtins` at runtime.""" + _hidden_builtins_overrides = { "function": "typing.Callable", "builtin_function_or_method": "typing.Callable", } + """Manual overrides for builtin types.""" def handle_type(self, type_: type) -> QualifiedName: if type_.__qualname__ == "PyCapsule" and type_.__module__ == "builtins": return self._any_type - + result = super().handle_type(type_) if result[0] == "builtins": - + typename = result[1] if typename == "NoneType": - return QualifiedName((Identifier("None"),)) + return QualifiedName( + (Identifier("None"),) + ) # just print None instead of types.NoneType + # some types (e.g. `types.MappingProxyType`) report a wrong qualname at runtime, and module == `builtins` + # we collect these upfront and translate their "builtin" name to the importable one hidden_builtin = self._hidden_builtins.get(typename) if hidden_builtin is not None: - hidden_builtin_override = self._hidden_builtins_overrides.get( - typename - ) - annotation = hidden_builtin_override or 'types.%s' % hidden_builtin + # some of these types are better described via the `typing` special forms + # e.g. types.FunctionType -> typing.Callable, so we use the override name + hidden_builtin_override = self._hidden_builtins_overrides.get(typename) + + annotation = hidden_builtin_override or "types.%s" % hidden_builtin override_t = self.parse_annotation_str(annotation) assert isinstance(override_t, ResolvedType) - return override_t.name + return override_t.name - return QualifiedName(result[1:]) + return QualifiedName(result[1:]) return result From 91edb5635e97aa1a0a9a3e752a6919761a2867ff Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 22 Jan 2026 21:34:18 +0300 Subject: [PATCH 03/13] add generation of mapping proxy test case --- tests/py-demo/bindings/src/main.cpp | 29 +++++++-------- tests/py-demo/bindings/src/modules.h | 35 ++++++++++--------- .../bindings/src/modules/hidden_builtins.cpp | 10 ++++++ 3 files changed, 44 insertions(+), 30 deletions(-) create mode 100644 tests/py-demo/bindings/src/modules/hidden_builtins.cpp diff --git a/tests/py-demo/bindings/src/main.cpp b/tests/py-demo/bindings/src/main.cpp index e94d24c9..51215334 100644 --- a/tests/py-demo/bindings/src/main.cpp +++ b/tests/py-demo/bindings/src/main.cpp @@ -1,18 +1,19 @@ #include "modules.h" PYBIND11_MODULE(_bindings, m) { - bind_classes_module(m.def_submodule("classes")); - bind_eigen_module(m.def_submodule("eigen")); - bind_enum_module(m.def_submodule("enum")); - bind_aliases_module(m.def_submodule("aliases")); - bind_flawed_bindings_module(m.def_submodule("flawed_bindings")); - bind_functions_module(m.def_submodule("functions")); - bind_issues_module(m.def_submodule("issues")); - bind_methods_module(m.def_submodule("methods")); - bind_numpy_module(m.def_submodule("numpy")); - bind_properties_module(m.def_submodule("properties")); - bind_stl_module(m.def_submodule("stl")); - bind_stl_bind_module(m.def_submodule("stl_bind")); - bind_typing_module(m.def_submodule("typing")); - bind_values_module(m.def_submodule("values")); + bind_classes_module(m.def_submodule("classes")); + bind_eigen_module(m.def_submodule("eigen")); + bind_enum_module(m.def_submodule("enum")); + bind_aliases_module(m.def_submodule("aliases")); + bind_flawed_bindings_module(m.def_submodule("flawed_bindings")); + bind_functions_module(m.def_submodule("functions")); + bind_issues_module(m.def_submodule("issues")); + bind_methods_module(m.def_submodule("methods")); + bind_numpy_module(m.def_submodule("numpy")); + bind_properties_module(m.def_submodule("properties")); + bind_stl_module(m.def_submodule("stl")); + bind_stl_bind_module(m.def_submodule("stl_bind")); + bind_typing_module(m.def_submodule("typing")); + bind_values_module(m.def_submodule("values")); + bind_hidden_builtins_module(m.def_submodule("hidden_builtins")); } diff --git a/tests/py-demo/bindings/src/modules.h b/tests/py-demo/bindings/src/modules.h index 2380621e..bd5ed3b3 100644 --- a/tests/py-demo/bindings/src/modules.h +++ b/tests/py-demo/bindings/src/modules.h @@ -1,22 +1,25 @@ #pragma once -#include #include "opaque_types.h" +#include -#define PYBIND11_VERSION_AT_LEAST(x,y) (PYBIND11_VERSION_MAJOR>x || ( PYBIND11_VERSION_MAJOR>=x && PYBIND11_VERSION_MINOR>=y )) +#define PYBIND11_VERSION_AT_LEAST(x, y) \ + (PYBIND11_VERSION_MAJOR > x || \ + (PYBIND11_VERSION_MAJOR >= x && PYBIND11_VERSION_MINOR >= y)) namespace py = pybind11; -void bind_aliases_module(py::module&& m); -void bind_classes_module(py::module&& m); -void bind_eigen_module(py::module&& m); -void bind_enum_module(py::module&& m); -void bind_flawed_bindings_module(py::module&& m); -void bind_functions_module(py::module&& m); -void bind_issues_module(py::module&& m); -void bind_methods_module(py::module&& m); -void bind_numpy_module(py::module&& m); -void bind_properties_module(py::module&& m); -void bind_stl_module(py::module&& m); -void bind_stl_bind_module(py::module&& m); -void bind_typing_module(py::module&& m); -void bind_values_module(py::module&& m); +void bind_aliases_module(py::module &&m); +void bind_classes_module(py::module &&m); +void bind_eigen_module(py::module &&m); +void bind_enum_module(py::module &&m); +void bind_flawed_bindings_module(py::module &&m); +void bind_functions_module(py::module &&m); +void bind_issues_module(py::module &&m); +void bind_methods_module(py::module &&m); +void bind_numpy_module(py::module &&m); +void bind_properties_module(py::module &&m); +void bind_stl_module(py::module &&m); +void bind_stl_bind_module(py::module &&m); +void bind_typing_module(py::module &&m); +void bind_values_module(py::module &&m); +void bind_hidden_builtins_module(py::module &&m); diff --git a/tests/py-demo/bindings/src/modules/hidden_builtins.cpp b/tests/py-demo/bindings/src/modules/hidden_builtins.cpp new file mode 100644 index 00000000..97a895ea --- /dev/null +++ b/tests/py-demo/bindings/src/modules/hidden_builtins.cpp @@ -0,0 +1,10 @@ +#include "modules.h" + +void bind_hidden_builtins_module(py::module &&m) { + py::dict readonly_dict{}; + + auto mappingproxy_t = py::object types = + py::module::import("types").attr("MappingProxyType"); + + m.attr("mapping_proxy") = mappingproxy_t(readonly_dict); +} From c6102b24ebd5872835f1c3bd35734ee701f6a54e Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 22 Jan 2026 21:45:04 +0300 Subject: [PATCH 04/13] add pytypes include --- tests/py-demo/bindings/src/modules/hidden_builtins.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/py-demo/bindings/src/modules/hidden_builtins.cpp b/tests/py-demo/bindings/src/modules/hidden_builtins.cpp index 97a895ea..ed159122 100644 --- a/tests/py-demo/bindings/src/modules/hidden_builtins.cpp +++ b/tests/py-demo/bindings/src/modules/hidden_builtins.cpp @@ -1,5 +1,7 @@ #include "modules.h" +#include + void bind_hidden_builtins_module(py::module &&m) { py::dict readonly_dict{}; From a8bbfdc99b8768738fb747bd815712816a6bcfe0 Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 22 Jan 2026 21:45:34 +0300 Subject: [PATCH 05/13] fix spelling error --- tests/py-demo/bindings/src/modules/hidden_builtins.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/py-demo/bindings/src/modules/hidden_builtins.cpp b/tests/py-demo/bindings/src/modules/hidden_builtins.cpp index ed159122..0e5b07eb 100644 --- a/tests/py-demo/bindings/src/modules/hidden_builtins.cpp +++ b/tests/py-demo/bindings/src/modules/hidden_builtins.cpp @@ -5,8 +5,7 @@ void bind_hidden_builtins_module(py::module &&m) { py::dict readonly_dict{}; - auto mappingproxy_t = py::object types = - py::module::import("types").attr("MappingProxyType"); + auto mappingproxy_t = py::module::import("types").attr("MappingProxyType"); m.attr("mapping_proxy") = mappingproxy_t(readonly_dict); } From da1aa5d5eec95db77769a1427639c00560e62cf1 Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 22 Jan 2026 22:00:50 +0300 Subject: [PATCH 06/13] revert clang-format changes --- tests/py-demo/bindings/src/main.cpp | 32 +++++++++++++------------- tests/py-demo/bindings/src/modules.h | 34 +++++++++++++--------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/tests/py-demo/bindings/src/main.cpp b/tests/py-demo/bindings/src/main.cpp index 51215334..95f9463b 100644 --- a/tests/py-demo/bindings/src/main.cpp +++ b/tests/py-demo/bindings/src/main.cpp @@ -1,19 +1,19 @@ #include "modules.h" PYBIND11_MODULE(_bindings, m) { - bind_classes_module(m.def_submodule("classes")); - bind_eigen_module(m.def_submodule("eigen")); - bind_enum_module(m.def_submodule("enum")); - bind_aliases_module(m.def_submodule("aliases")); - bind_flawed_bindings_module(m.def_submodule("flawed_bindings")); - bind_functions_module(m.def_submodule("functions")); - bind_issues_module(m.def_submodule("issues")); - bind_methods_module(m.def_submodule("methods")); - bind_numpy_module(m.def_submodule("numpy")); - bind_properties_module(m.def_submodule("properties")); - bind_stl_module(m.def_submodule("stl")); - bind_stl_bind_module(m.def_submodule("stl_bind")); - bind_typing_module(m.def_submodule("typing")); - bind_values_module(m.def_submodule("values")); - bind_hidden_builtins_module(m.def_submodule("hidden_builtins")); -} + bind_classes_module(m.def_submodule("classes")); + bind_eigen_module(m.def_submodule("eigen")); + bind_enum_module(m.def_submodule("enum")); + bind_aliases_module(m.def_submodule("aliases")); + bind_flawed_bindings_module(m.def_submodule("flawed_bindings")); + bind_functions_module(m.def_submodule("functions")); + bind_issues_module(m.def_submodule("issues")); + bind_methods_module(m.def_submodule("methods")); + bind_numpy_module(m.def_submodule("numpy")); + bind_properties_module(m.def_submodule("properties")); + bind_stl_module(m.def_submodule("stl")); + bind_stl_bind_module(m.def_submodule("stl_bind")); + bind_typing_module(m.def_submodule("typing")); + bind_values_module(m.def_submodule("values")); + bind_hidden_builtins_module(m.def_submodule("hidden_builtins")); +} \ No newline at end of file diff --git a/tests/py-demo/bindings/src/modules.h b/tests/py-demo/bindings/src/modules.h index bd5ed3b3..7dceadd9 100644 --- a/tests/py-demo/bindings/src/modules.h +++ b/tests/py-demo/bindings/src/modules.h @@ -1,25 +1,23 @@ #pragma once -#include "opaque_types.h" #include +#include "opaque_types.h" -#define PYBIND11_VERSION_AT_LEAST(x, y) \ - (PYBIND11_VERSION_MAJOR > x || \ - (PYBIND11_VERSION_MAJOR >= x && PYBIND11_VERSION_MINOR >= y)) +#define PYBIND11_VERSION_AT_LEAST(x,y) (PYBIND11_VERSION_MAJOR>x || ( PYBIND11_VERSION_MAJOR>=x && PYBIND11_VERSION_MINOR>=y )) namespace py = pybind11; -void bind_aliases_module(py::module &&m); -void bind_classes_module(py::module &&m); -void bind_eigen_module(py::module &&m); -void bind_enum_module(py::module &&m); -void bind_flawed_bindings_module(py::module &&m); -void bind_functions_module(py::module &&m); -void bind_issues_module(py::module &&m); -void bind_methods_module(py::module &&m); -void bind_numpy_module(py::module &&m); -void bind_properties_module(py::module &&m); -void bind_stl_module(py::module &&m); -void bind_stl_bind_module(py::module &&m); -void bind_typing_module(py::module &&m); -void bind_values_module(py::module &&m); +void bind_aliases_module(py::module&& m); +void bind_classes_module(py::module&& m); +void bind_eigen_module(py::module&& m); +void bind_enum_module(py::module&& m); +void bind_flawed_bindings_module(py::module&& m); +void bind_functions_module(py::module&& m); +void bind_issues_module(py::module&& m); +void bind_methods_module(py::module&& m); +void bind_numpy_module(py::module&& m); +void bind_properties_module(py::module&& m); +void bind_stl_module(py::module&& m); +void bind_stl_bind_module(py::module&& m); +void bind_typing_module(py::module&& m); +void bind_values_module(py::module&& m); void bind_hidden_builtins_module(py::module &&m); From 16c13158cf13a170cfa4203ddda737136d137e13 Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 22 Jan 2026 22:07:01 +0300 Subject: [PATCH 07/13] fix python formatting --- pybind11_stubgen/parser/mixins/fix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pybind11_stubgen/parser/mixins/fix.py b/pybind11_stubgen/parser/mixins/fix.py index e0f674dd..89808845 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -312,7 +312,7 @@ def handle_type(self, type_: type) -> QualifiedName: assert isinstance(override_t, ResolvedType) return override_t.name - return QualifiedName(result[1:]) + return QualifiedName(result[1:]) return result From 8236432ec9fa0086c3a5a5e3388ebc63662d1c31 Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 22 Jan 2026 22:53:09 +0300 Subject: [PATCH 08/13] add 3.8 stubs & reference syntax fix --- tests/py-demo/bindings/src/modules.h | 2 +- tests/py-demo/bindings/src/modules/hidden_builtins.cpp | 2 +- .../demo/_bindings/__init__.pyi | 2 ++ .../demo/_bindings/hidden_builtins.pyi | 6 ++++++ 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi diff --git a/tests/py-demo/bindings/src/modules.h b/tests/py-demo/bindings/src/modules.h index 7dceadd9..ca921b10 100644 --- a/tests/py-demo/bindings/src/modules.h +++ b/tests/py-demo/bindings/src/modules.h @@ -20,4 +20,4 @@ void bind_stl_module(py::module&& m); void bind_stl_bind_module(py::module&& m); void bind_typing_module(py::module&& m); void bind_values_module(py::module&& m); -void bind_hidden_builtins_module(py::module &&m); +void bind_hidden_builtins_module(py::module&& m); diff --git a/tests/py-demo/bindings/src/modules/hidden_builtins.cpp b/tests/py-demo/bindings/src/modules/hidden_builtins.cpp index 0e5b07eb..892fde57 100644 --- a/tests/py-demo/bindings/src/modules/hidden_builtins.cpp +++ b/tests/py-demo/bindings/src/modules/hidden_builtins.cpp @@ -2,7 +2,7 @@ #include -void bind_hidden_builtins_module(py::module &&m) { +void bind_hidden_builtins_module(py::module&& m) { py::dict readonly_dict{}; auto mappingproxy_t = py::module::import("types").attr("MappingProxyType"); diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi index c263078f..9ea9beb4 100644 --- a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi @@ -7,6 +7,7 @@ from . import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi new file mode 100644 index 00000000..a2b74bf6 --- /dev/null +++ b/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi @@ -0,0 +1,6 @@ +from __future__ import annotations + +import types + +__all__: list[str] = ["mapping_proxy"] +mapping_proxy: types.MappingProxyType # value = mappingproxy({}) \ No newline at end of file From d0f5fdee0e74f484439e87fc38517d19dfc995b6 Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 29 Jan 2026 09:48:34 +0300 Subject: [PATCH 09/13] merge --- .github/workflows/ci.yml | 442 ++++++++++++++++++++------------------- 1 file changed, 232 insertions(+), 210 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e338e5c..8d53ea9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,215 +1,237 @@ name: CI on: - workflow_dispatch: - pull_request: - push: - branches: - - master - tags: - - 'v*' + workflow_dispatch: + pull_request: + push: + branches: + - master + tags: + - "v*" jobs: - build: - name: Build wheel - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - uses: actions/setup-python@v5 - with: - python-version: "3.13" - - - name: Install build - run: python -m pip --disable-pip-version-check install build - - - name: Build sdist + wheel - run: python -m build - - - name: Upload build artifacts - uses: actions/upload-artifact@v6 - with: - name: dist - path: dist - - format: - name: Format code - runs-on: ubuntu-latest - steps: - - name: Setup Python 3.13 - uses: actions/setup-python@v5 - with: - python-version: "3.13" - - name: Checkout - uses: actions/checkout@v5 - - name: Install requirements - run: pip install -r requirements-dev.txt - - name: Run isort - run: isort --check --profile=black --diff ./pybind11_stubgen - if: ${{ failure() || success() }} - - name: Run black - run: black --diff ./pybind11_stubgen - if: ${{ failure() || success() }} - - name: Run flake8 - run: | - flake8 \ - --max-line-length=88 \ - --extend-ignore=E203 \ - --extend-exclude=venv/,.pytest_cache/,.ipynb_checkpoints/,tests/,tmp/,build/ - if: ${{ failure() || success() }} - - tests: - name: "Test 🐍 ${{ matrix.python }} • pybind-${{ matrix.pybind11-branch }} • ${{ matrix.numpy-format }}" - runs-on: ubuntu-latest - needs: [build] - strategy: - fail-fast: false - matrix: - pybind11-branch: - - "v2.13" - python: - - "3.13" - - "3.12" - - "3.11" - - "3.10" - - "3.9" - - "3.8" - numpy-format: - - "numpy-array-wrap-with-annotated" - include: - - python: "3.13" - pybind11-branch: "v2.9" - numpy-format: "numpy-array-wrap-with-annotated" - - python: "3.13" - pybind11-branch: "v2.11" - numpy-format: "numpy-array-wrap-with-annotated" - - python: "3.13" - pybind11-branch: "v2.12" - numpy-format: "numpy-array-wrap-with-annotated" - - python: "3.13" - pybind11-branch: "v2.13" - numpy-format: "numpy-array-use-type-var" -# # TODO: uncomment -# - python: "3.13" -# pybind11-branch: "master" - steps: - - uses: actions/checkout@v5 - - - name: Download build artifacts - uses: actions/download-artifact@v6 - with: - name: dist - path: dist - - - name: Setup Python ${{ matrix.python }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - - name: Update CMake - uses: jwlawson/actions-setup-cmake@v2 - with: - # https://github.com/pybind/pybind11/blob/914c06fb252b6cc3727d0eedab6736e88a3fcb01/CMakeLists.txt#L13C34-L13C38 - cmake-version: '3.22.x' - - - name: Setup annotations on Linux - if: runner.os == 'Linux' - run: python -m pip install pytest-github-actions-annotate-failures - - - name: Install requirements - run: pip install -r "./tests/stubs/python-${{ matrix.python }}/requirements.txt" - - - name: Install - shell: bash - working-directory: dist - run: python -m pip --disable-pip-version-check install *.whl - - - name: Install demo module - shell: bash - run: ./tests/install-demo-module.sh --pybind11-branch "${{ matrix.pybind11-branch }}" - - - name: Check stubs generation - shell: bash - run: ./tests/check-demo-stubs-generation.sh --stubs-sub-dir "stubs/python-${{ matrix.python }}/pybind11-${{ matrix.pybind11-branch }}/${{ matrix.numpy-format }}" --${{ matrix.numpy-format }} - - - name: Archive patch - uses: actions/upload-artifact@v6 - if: failure() - with: - name: "python-${{ matrix.python }}-pybind-${{ matrix.pybind11-branch }}-${{ matrix.numpy-format }}.patch" - path: "./tests/stubs/python-${{ matrix.python }}/pybind11-${{ matrix.pybind11-branch }}/${{ matrix.numpy-format }}.patch" - retention-days: 30 - if-no-files-found: ignore - - - name: Check error generation - shell: bash - run: ./tests/check-demo-errors-generation.sh - - test-cli-options: - name: "Runs on 🐍 ${{ matrix.python }} • ${{ matrix.test-package }}" - runs-on: ubuntu-latest - needs: [build] - strategy: - fail-fast: false - matrix: - test-package: [ "gemmi" ] - python: - - "3.13" - - "3.12" - - "3.11" - - "3.10" - - "3.9" - - "3.8" - steps: - - uses: actions/checkout@v5 - - - name: Setup Python ${{ matrix.python }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - - name: Download build artifacts - uses: actions/download-artifact@v6 - with: - name: dist - path: dist - - - name: Setup annotations on Linux - if: runner.os == 'Linux' - run: python -m pip install pytest-github-actions-annotate-failures - - - name: Install - shell: bash - working-directory: dist - run: python -m pip --disable-pip-version-check install *.whl - - - name: "Install ${{ matrix.test-package }}" - shell: bash - run: pip install "${{ matrix.test-package }}" - - - name: Generate stubs - shell: bash - run: | - pybind11-stubgen "${{ matrix.test-package }}" -o flavour-1 --numpy-array-wrap-with-annotated - pybind11-stubgen "${{ matrix.test-package }}" -o flavour-2 --numpy-array-remove-parameters - pybind11-stubgen "${{ matrix.test-package }}" -o flavour-3 --print-invalid-expressions-as-is - pybind11-stubgen "${{ matrix.test-package }}" -o flavour-4 --numpy-array-use-type-var - pybind11-stubgen "${{ matrix.test-package }}" --dry-run - - publish: - name: Publish distribution - needs : [build, format, tests, test-cli-options] - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - runs-on: ubuntu-latest - permissions: - # IMPORTANT: this permission is mandatory for Trusted Publishing - id-token: write - - steps: - - name: Download build artifacts - uses: actions/download-artifact@v6 - with: - name: dist - path: dist - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + build: + name: Build wheel + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install build + run: python -m pip --disable-pip-version-check install build + + - name: Build sdist + wheel + run: python -m build + + - name: Upload build artifacts + uses: actions/upload-artifact@v6 + with: + name: dist + path: dist + + format: + name: Format code + runs-on: ubuntu-latest + steps: + - name: Setup Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: Checkout + uses: actions/checkout@v5 + - name: Install requirements + run: pip install -r requirements-dev.txt + - name: Run isort + run: isort --check --profile=black --diff ./pybind11_stubgen + if: ${{ failure() || success() }} + - name: Run black + run: black --diff ./pybind11_stubgen + if: ${{ failure() || success() }} + - name: Run flake8 + run: | + flake8 \ + --max-line-length=88 \ + --extend-ignore=E203 \ + --extend-exclude=venv/,.pytest_cache/,.ipynb_checkpoints/,tests/,tmp/,build/ + if: ${{ failure() || success() }} + + tests: + name: "Test 🐍 ${{ matrix.config.python }} • pybind-${{ matrix.config.pybind11-branch }} • ${{ matrix.config.numpy-format }}" + runs-on: ubuntu-latest + needs: [build] + strategy: + fail-fast: false + matrix: + config: + [ + { + pybind11-branch: "v2.13", + python: "3.13", + numpy-format: "numpy-array-use-type-var", + cmake-version: "4.2.x", + }, + { + pybind11-branch: "v2.13", + python: "3.13", + numpy-format: "numpy-array-wrap-with-annotated", + cmake-version: "4.2.x", + }, + { + pybind11-branch: "v2.13", + python: "3.12", + numpy-format: "numpy-array-wrap-with-annotated", + cmake-version: "4.2.x", + }, + { + pybind11-branch: "v2.13", + python: "3.11", + numpy-format: "numpy-array-wrap-with-annotated", + cmake-version: "4.2.x", + }, + { + pybind11-branch: "v2.13", + python: "3.10", + numpy-format: "numpy-array-wrap-with-annotated", + cmake-version: "4.2.x", + }, + { + pybind11-branch: "v2.12", + python: "3.13", + numpy-format: "numpy-array-wrap-with-annotated", + cmake-version: "3.28.3", + }, + { + pybind11-branch: "v2.11", + python: "3.13", + numpy-format: "numpy-array-wrap-with-annotated", + cmake-version: "3.28.3", + }, + { + pybind11-branch: "v2.9", + python: "3.13", + numpy-format: "numpy-array-wrap-with-annotated", + cmake-version: "3.28.3", + }, + ] + steps: + - uses: actions/checkout@v5 + + - name: Download build artifacts + uses: actions/download-artifact@v6 + with: + name: dist + path: dist + + - name: Setup Python ${{ matrix.config.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.config.python }} + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v2 + with: + # https://github.com/pybind/pybind11/blob/914c06fb252b6cc3727d0eedab6736e88a3fcb01/CMakeLists.txt#L13C34-L13C38 + cmake-version: ${{ matrix.config.cmake-version }} + + - name: Setup annotations on Linux + if: runner.os == 'Linux' + run: python -m pip install pytest-github-actions-annotate-failures + + - name: Install requirements + run: pip install -r "./tests/stubs/python-${{ matrix.config.python }}/requirements.txt" + + - name: Install + shell: bash + working-directory: dist + run: python -m pip --disable-pip-version-check install *.whl + + - name: Install demo module + shell: bash + run: ./tests/install-demo-module.sh --pybind11-branch "${{ matrix.config.pybind11-branch }}" + + - name: Check stubs generation + shell: bash + run: ./tests/check-demo-stubs-generation.sh --stubs-sub-dir "stubs/python-${{ matrix.config.python }}/pybind11-${{ matrix.config.pybind11-branch }}/${{ matrix.config.numpy-format }}" --${{ matrix.config.numpy-format }} + + - name: Archive patch + uses: actions/upload-artifact@v6 + if: failure() + with: + name: "python-${{ matrix.config.python }}-pybind-${{ matrix.config.pybind11-branch }}-${{ matrix.config.numpy-format }}.patch" + path: "./tests/stubs/python-${{ matrix.config.python }}/pybind11-${{ matrix.config.pybind11-branch }}/${{ matrix.config.numpy-format }}.patch" + retention-days: 30 + if-no-files-found: ignore + + - name: Check error generation + shell: bash + run: ./tests/check-demo-errors-generation.sh + + test-cli-options: + name: "Runs on 🐍 ${{ matrix.python }} • ${{ matrix.test-package }}" + runs-on: ubuntu-latest + needs: [build] + strategy: + fail-fast: false + matrix: + test-package: ["gemmi"] + python: + - "3.13" + - "3.12" + - "3.11" + - "3.10" + steps: + - uses: actions/checkout@v5 + + - name: Setup Python ${{ matrix.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + + - name: Download build artifacts + uses: actions/download-artifact@v6 + with: + name: dist + path: dist + + - name: Setup annotations on Linux + if: runner.os == 'Linux' + run: python -m pip install pytest-github-actions-annotate-failures + + - name: Install + shell: bash + working-directory: dist + run: python -m pip --disable-pip-version-check install *.whl + + - name: "Install ${{ matrix.test-package }}" + shell: bash + run: pip install "${{ matrix.test-package }}" + + - name: Generate stubs + shell: bash + run: | + pybind11-stubgen "${{ matrix.test-package }}" -o flavour-1 --numpy-array-wrap-with-annotated + pybind11-stubgen "${{ matrix.test-package }}" -o flavour-2 --numpy-array-remove-parameters + pybind11-stubgen "${{ matrix.test-package }}" -o flavour-3 --print-invalid-expressions-as-is + pybind11-stubgen "${{ matrix.test-package }}" -o flavour-4 --numpy-array-use-type-var + pybind11-stubgen "${{ matrix.test-package }}" --dry-run + + publish: + name: Publish distribution + needs: [build, format, tests, test-cli-options] + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + runs-on: ubuntu-latest + permissions: + # IMPORTANT: this permission is mandatory for Trusted Publishing + id-token: write + + steps: + - name: Download build artifacts + uses: actions/download-artifact@v6 + with: + name: dist + path: dist + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 From b655e461bcc199d4e8e61e26b0fc97a20c53ef83 Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 29 Jan 2026 09:54:53 +0300 Subject: [PATCH 10/13] regenerate reference stubs --- .../numpy-array-wrap-with-annotated/demo/__init__.pyi | 2 ++ .../demo/_bindings/__init__.pyi | 2 ++ .../demo/_bindings/hidden_builtins.pyi | 6 ++++++ .../numpy-array-wrap-with-annotated/demo/core.pyi | 2 ++ .../numpy-array-wrap-with-annotated/demo/__init__.pyi | 2 ++ .../demo/_bindings/__init__.pyi | 2 ++ .../demo/_bindings/hidden_builtins.pyi | 6 ++++++ .../numpy-array-wrap-with-annotated/demo/core.pyi | 2 ++ .../numpy-array-use-type-var/demo/__init__.pyi | 2 ++ .../numpy-array-use-type-var/demo/_bindings/__init__.pyi | 2 ++ .../demo/_bindings/hidden_builtins.pyi | 6 ++++++ .../pybind11-v2.13/numpy-array-use-type-var/demo/core.pyi | 2 ++ .../numpy-array-wrap-with-annotated/demo/__init__.pyi | 2 ++ .../demo/_bindings/__init__.pyi | 2 ++ .../demo/_bindings/hidden_builtins.pyi | 6 ++++++ .../numpy-array-wrap-with-annotated/demo/core.pyi | 2 ++ .../numpy-array-wrap-with-annotated/demo/__init__.pyi | 2 ++ .../demo/_bindings/__init__.pyi | 2 ++ .../demo/_bindings/hidden_builtins.pyi | 6 ++++++ .../numpy-array-wrap-with-annotated/demo/core.pyi | 2 ++ 20 files changed, 60 insertions(+) create mode 100644 tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi create mode 100644 tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi create mode 100644 tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi create mode 100644 tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi create mode 100644 tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/__init__.pyi index 86fb6b84..9f27c427 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/__init__.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -27,6 +28,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi index c263078f..9ea9beb4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi @@ -7,6 +7,7 @@ from . import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi new file mode 100644 index 00000000..ffc6c84f --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi @@ -0,0 +1,6 @@ +from __future__ import annotations + +import types + +__all__: list[str] = ["mapping_proxy"] +mapping_proxy: types.MappingProxyType # value = mappingproxy({}) diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/core.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/core.pyi index 95c16467..95cb8455 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/core.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/core.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/__init__.pyi index 86fb6b84..9f27c427 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/__init__.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -27,6 +28,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi index c263078f..9ea9beb4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi @@ -7,6 +7,7 @@ from . import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi new file mode 100644 index 00000000..ffc6c84f --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi @@ -0,0 +1,6 @@ +from __future__ import annotations + +import types + +__all__: list[str] = ["mapping_proxy"] +mapping_proxy: types.MappingProxyType # value = mappingproxy({}) diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/core.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/core.pyi index 95c16467..95cb8455 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/core.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/core.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/__init__.pyi index 86fb6b84..9f27c427 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/__init__.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -27,6 +28,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/__init__.pyi index c263078f..9ea9beb4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/__init__.pyi @@ -7,6 +7,7 @@ from . import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi new file mode 100644 index 00000000..ffc6c84f --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi @@ -0,0 +1,6 @@ +from __future__ import annotations + +import types + +__all__: list[str] = ["mapping_proxy"] +mapping_proxy: types.MappingProxyType # value = mappingproxy({}) diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/core.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/core.pyi index 95c16467..95cb8455 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/core.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/core.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/__init__.pyi index 86fb6b84..9f27c427 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/__init__.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -27,6 +28,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi index c263078f..9ea9beb4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi @@ -7,6 +7,7 @@ from . import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi new file mode 100644 index 00000000..ffc6c84f --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi @@ -0,0 +1,6 @@ +from __future__ import annotations + +import types + +__all__: list[str] = ["mapping_proxy"] +mapping_proxy: types.MappingProxyType # value = mappingproxy({}) diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/core.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/core.pyi index 95c16467..95cb8455 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/core.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/core.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/__init__.pyi index 86fb6b84..9f27c427 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/__init__.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -27,6 +28,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi index c263078f..9ea9beb4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi @@ -7,6 +7,7 @@ from . import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi new file mode 100644 index 00000000..ffc6c84f --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi @@ -0,0 +1,6 @@ +from __future__ import annotations + +import types + +__all__: list[str] = ["mapping_proxy"] +mapping_proxy: types.MappingProxyType # value = mappingproxy({}) diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/core.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/core.pyi index 95c16467..95cb8455 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/core.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/core.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", From a65112a3d33f9048870f93e574c92f32ae0aa4a1 Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 29 Jan 2026 10:19:38 +0300 Subject: [PATCH 11/13] fix flake8 --- pybind11_stubgen/parser/mixins/fix.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pybind11_stubgen/parser/mixins/fix.py b/pybind11_stubgen/parser/mixins/fix.py index 89808845..9da43914 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -40,7 +40,6 @@ class RemoveSelfAnnotation(IParser): - __any_t_name = QualifiedName.from_str("Any") __typing_any_t_name = QualifiedName.from_str("typing.Any") @@ -274,7 +273,8 @@ class FixBuiltinTypes(IParser): == "builtins" # defined in types, but reports `builtins` and not hasattr(builtins, name) # not actually available in `builtins` } - """Types by their real name that are available in the `types` module, but report `builtins` at runtime.""" + """Types by their real name that are available in the `types` module, + but report `builtins` at runtime.""" _hidden_builtins_overrides = { "function": "typing.Callable", @@ -289,7 +289,6 @@ def handle_type(self, type_: type) -> QualifiedName: result = super().handle_type(type_) if result[0] == "builtins": - typename = result[1] if typename == "NoneType": @@ -297,13 +296,15 @@ def handle_type(self, type_: type) -> QualifiedName: (Identifier("None"),) ) # just print None instead of types.NoneType - # some types (e.g. `types.MappingProxyType`) report a wrong qualname at runtime, and module == `builtins` - # we collect these upfront and translate their "builtin" name to the importable one + # some types (e.g. `types.MappingProxyType`) report a wrong qualname + # at runtime, and module == `builtins` + # we collect these upfront and translate their "builtin" name to the + # importable one hidden_builtin = self._hidden_builtins.get(typename) if hidden_builtin is not None: - - # some of these types are better described via the `typing` special forms - # e.g. types.FunctionType -> typing.Callable, so we use the override name + # some of these types are better described via the `typing` + # special forms e.g. types.FunctionType -> typing.Callable, + # so we use the override name hidden_builtin_override = self._hidden_builtins_overrides.get(typename) annotation = hidden_builtin_override or "types.%s" % hidden_builtin From a2df17279ed24ae5b4501cc8db2644db2dfc7d11 Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 29 Jan 2026 12:37:50 +0300 Subject: [PATCH 12/13] add test case for None --- tests/py-demo/bindings/src/modules/hidden_builtins.cpp | 9 ++++++++- .../demo/_bindings/hidden_builtins.pyi | 3 ++- .../demo/_bindings/hidden_builtins.pyi | 3 ++- .../demo/_bindings/hidden_builtins.pyi | 3 ++- .../demo/_bindings/hidden_builtins.pyi | 3 ++- .../demo/_bindings/hidden_builtins.pyi | 3 ++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/py-demo/bindings/src/modules/hidden_builtins.cpp b/tests/py-demo/bindings/src/modules/hidden_builtins.cpp index 892fde57..2623d315 100644 --- a/tests/py-demo/bindings/src/modules/hidden_builtins.cpp +++ b/tests/py-demo/bindings/src/modules/hidden_builtins.cpp @@ -2,10 +2,17 @@ #include +namespace hidden_builtins_detail { + +}; + void bind_hidden_builtins_module(py::module&& m) { py::dict readonly_dict{}; - auto mappingproxy_t = py::module::import("types").attr("MappingProxyType"); + auto types_m = py::module::import("types"); + auto mappingproxy_t = types_m.attr("MappingProxyType"); + auto none_t = types_m.attr("NoneType"); m.attr("mapping_proxy") = mappingproxy_t(readonly_dict); + m.attr("none") = none_t(); } diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi index ffc6c84f..52c09281 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi @@ -2,5 +2,6 @@ from __future__ import annotations import types -__all__: list[str] = ["mapping_proxy"] +__all__: list[str] = ["mapping_proxy", "none"] mapping_proxy: types.MappingProxyType # value = mappingproxy({}) +none = None diff --git a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi index ffc6c84f..52c09281 100644 --- a/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi @@ -2,5 +2,6 @@ from __future__ import annotations import types -__all__: list[str] = ["mapping_proxy"] +__all__: list[str] = ["mapping_proxy", "none"] mapping_proxy: types.MappingProxyType # value = mappingproxy({}) +none = None diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi index ffc6c84f..52c09281 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi @@ -2,5 +2,6 @@ from __future__ import annotations import types -__all__: list[str] = ["mapping_proxy"] +__all__: list[str] = ["mapping_proxy", "none"] mapping_proxy: types.MappingProxyType # value = mappingproxy({}) +none = None diff --git a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi index ffc6c84f..52c09281 100644 --- a/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi @@ -2,5 +2,6 @@ from __future__ import annotations import types -__all__: list[str] = ["mapping_proxy"] +__all__: list[str] = ["mapping_proxy", "none"] mapping_proxy: types.MappingProxyType # value = mappingproxy({}) +none = None diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi index ffc6c84f..52c09281 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi @@ -2,5 +2,6 @@ from __future__ import annotations import types -__all__: list[str] = ["mapping_proxy"] +__all__: list[str] = ["mapping_proxy", "none"] mapping_proxy: types.MappingProxyType # value = mappingproxy({}) +none = None From 956d6c9e1c62a1c234f7acf9b86751e53ce775f5 Mon Sep 17 00:00:00 2001 From: skarndev Date: Thu, 29 Jan 2026 17:31:36 +0300 Subject: [PATCH 13/13] update stubs --- .../numpy-array-wrap-with-annotated/demo/__init__.pyi | 2 ++ .../demo/_bindings/__init__.pyi | 2 ++ .../demo/_bindings/hidden_builtins.pyi | 7 +++++++ .../numpy-array-wrap-with-annotated/demo/core.pyi | 2 ++ .../numpy-array-wrap-with-annotated/demo/__init__.pyi | 2 ++ .../demo/_bindings/__init__.pyi | 2 ++ .../demo/_bindings/hidden_builtins.pyi | 7 +++++++ .../numpy-array-wrap-with-annotated/demo/core.pyi | 2 ++ .../numpy-array-use-type-var/demo/__init__.pyi | 2 ++ .../numpy-array-use-type-var/demo/_bindings/__init__.pyi | 2 ++ .../demo/_bindings/hidden_builtins.pyi | 7 +++++++ .../pybind11-v3.0/numpy-array-use-type-var/demo/core.pyi | 2 ++ .../numpy-array-wrap-with-annotated/demo/__init__.pyi | 2 ++ .../demo/_bindings/__init__.pyi | 2 ++ .../demo/_bindings/hidden_builtins.pyi | 7 +++++++ .../numpy-array-wrap-with-annotated/demo/core.pyi | 2 ++ 16 files changed, 52 insertions(+) create mode 100644 tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi create mode 100644 tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi create mode 100644 tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi create mode 100644 tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi diff --git a/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/__init__.pyi b/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/__init__.pyi index 86fb6b84..9f27c427 100644 --- a/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/__init__.pyi +++ b/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/__init__.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -27,6 +28,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi b/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi index c263078f..9ea9beb4 100644 --- a/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi +++ b/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi @@ -7,6 +7,7 @@ from . import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi new file mode 100644 index 00000000..52c09281 --- /dev/null +++ b/tests/stubs/python-3.11/pybind11-v2.13/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.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/core.pyi b/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/core.pyi index 95c16467..95cb8455 100644 --- a/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/core.pyi +++ b/tests/stubs/python-3.11/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/core.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi b/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi index 86fb6b84..9f27c427 100644 --- a/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi +++ b/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -27,6 +28,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi b/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi index c263078f..9ea9beb4 100644 --- a/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi +++ b/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi @@ -7,6 +7,7 @@ from . import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.11/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.11/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.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi b/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi index 95c16467..95cb8455 100644 --- a/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi +++ b/tests/stubs/python-3.11/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/__init__.pyi b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/__init__.pyi index 86fb6b84..9f27c427 100644 --- a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/__init__.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -27,6 +28,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/__init__.pyi b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/__init__.pyi index c263078f..9ea9beb4 100644 --- a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/__init__.pyi @@ -7,6 +7,7 @@ from . import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/_bindings/hidden_builtins.pyi new file mode 100644 index 00000000..52c09281 --- /dev/null +++ b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/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.12/pybind11-v3.0/numpy-array-use-type-var/demo/core.pyi b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/core.pyi index 95c16467..95cb8455 100644 --- a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/core.pyi +++ b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-use-type-var/demo/core.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi index 86fb6b84..9f27c427 100644 --- a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/__init__.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -27,6 +28,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi index c263078f..9ea9beb4 100644 --- a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi +++ b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/__init__.pyi @@ -7,6 +7,7 @@ from . import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy", diff --git a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/_bindings/hidden_builtins.pyi b/tests/stubs/python-3.12/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.12/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.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi index 95c16467..95cb8455 100644 --- a/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi +++ b/tests/stubs/python-3.12/pybind11-v3.0/numpy-array-wrap-with-annotated/demo/core.pyi @@ -7,6 +7,7 @@ from demo._bindings import ( enum, flawed_bindings, functions, + hidden_builtins, issues, methods, numpy, @@ -24,6 +25,7 @@ __all__: list[str] = [ "enum", "flawed_bindings", "functions", + "hidden_builtins", "issues", "methods", "numpy",