From a7b916ed0264413781eb444aa749df8b8301b19e Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sat, 25 Nov 2023 22:01:59 +0900 Subject: [PATCH 01/15] feat: Wrap invalid expressions as `Annotated[Any, InvalidExpr("")]` --- pybind11_stubgen/__init__.py | 2 ++ pybind11_stubgen/parser/mixins/fix.py | 24 ++++++++++++++++- pybind11_stubgen/typing_ext.py | 12 +++++++++ .../demo/_bindings/flawed_bindings.pyi | 26 ++++++++++++++++--- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/pybind11_stubgen/__init__.py b/pybind11_stubgen/__init__.py index 2de7f21..cdb5d1f 100644 --- a/pybind11_stubgen/__init__.py +++ b/pybind11_stubgen/__init__.py @@ -48,6 +48,7 @@ RemoveSelfAnnotation, ReplaceReadWritePropertyWithField, RewritePybind11EnumValueRepr, + WrapInvalidExpressionInAnnotated, ) from pybind11_stubgen.parser.mixins.parse import ( BaseParser, @@ -262,6 +263,7 @@ class Parser( FixMissingEnumMembersAnnotation, OverridePrintSafeValues, *numpy_fixes, # type: ignore[misc] + WrapInvalidExpressionInAnnotated, FixNumpyDtype, FixNumpyArrayFlags, FixCurrentModulePrefixInTypeNames, diff --git a/pybind11_stubgen/parser/mixins/fix.py b/pybind11_stubgen/parser/mixins/fix.py index 4360dab..bb26b39 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -36,7 +36,7 @@ TypeVar_, Value, ) -from pybind11_stubgen.typing_ext import DynamicSize, FixedSize +from pybind11_stubgen.typing_ext import DynamicSize, FixedSize, InvalidExpr logger = getLogger("pybind11_stubgen") @@ -867,6 +867,28 @@ def handle_class_member( return result +class WrapInvalidExpressionInAnnotated(IParser): + def parse_annotation_str( + self, annotation_str: str + ) -> ResolvedType | InvalidExpression | Value: + result = super().parse_annotation_str(annotation_str) + if not isinstance(result, InvalidExpression): + return result + + self.handle_type(InvalidExpr) + substitute_t = ResolvedType(self.handle_type(Any)) + return ResolvedType( + QualifiedName.from_str("typing.Annotated"), + parameters=[ + substitute_t, + Value( + repr=repr(InvalidExpr(expr=annotation_str.strip())), + is_print_safe=True, + ), + ], + ) + + class FixMissingFixedSizeImport(IParser): def parse_annotation_str( self, annotation_str: str diff --git a/pybind11_stubgen/typing_ext.py b/pybind11_stubgen/typing_ext.py index 72c7414..a41e7f6 100644 --- a/pybind11_stubgen/typing_ext.py +++ b/pybind11_stubgen/typing_ext.py @@ -23,3 +23,15 @@ def __repr__(self): f"{self.__class__.__qualname__}" f"({', '.join(repr(d) for d in self.dim)})" ) + + +class InvalidExpr: + def __init__(self, expr: str): + self.expr = expr + + def __repr__(self): + return ( + f"{self.__module__}." + f"{self.__class__.__qualname__}" + f"({repr(self.expr)})" + ) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index 651a886..a31b95e 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -1,5 +1,9 @@ from __future__ import annotations +import typing + +import pybind11_stubgen.typing_ext + __all__ = [ "Enum", "Unbound", @@ -16,8 +20,24 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: ...) -> int: ... +def accept_unbound_enum( + arg0: typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Enum"), + ] +) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type(arg0: tuple[..., int]) -> int: ... +def accept_unbound_type( + arg0: tuple[ + typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), + ], + int, + ] +) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> ...: ... +def get_unbound_type() -> typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), +]: ... From 728877a2a939533edb9c0c9e701ea0028764c86c Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sat, 25 Nov 2023 22:08:40 +0900 Subject: [PATCH 02/15] fix: Don't wrap if print_invalid_expressions_as_is flag is set --- pybind11_stubgen/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pybind11_stubgen/__init__.py b/pybind11_stubgen/__init__.py index cdb5d1f..57cab14 100644 --- a/pybind11_stubgen/__init__.py +++ b/pybind11_stubgen/__init__.py @@ -249,6 +249,11 @@ def stub_parser_from_args(args: CLIArgs) -> IParser: ), ] + if args.print_invalid_expressions_as_is: + wrap_invalid_expressions = [] + else: + wrap_invalid_expressions = [WrapInvalidExpressionInAnnotated] + class Parser( *error_handlers_top, # type: ignore[misc] FixMissing__future__AnnotationsImport, @@ -263,7 +268,7 @@ class Parser( FixMissingEnumMembersAnnotation, OverridePrintSafeValues, *numpy_fixes, # type: ignore[misc] - WrapInvalidExpressionInAnnotated, + *wrap_invalid_expressions, FixNumpyDtype, FixNumpyArrayFlags, FixCurrentModulePrefixInTypeNames, From c5e74d6a83ba0e9e453af0e043cc15c3b5cadd88 Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sat, 25 Nov 2023 22:18:06 +0900 Subject: [PATCH 03/15] ci: Fix patch path --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4778517..b2418d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,8 +97,8 @@ jobs: uses: actions/upload-artifact@v3 if: failure() with: - name: "python-${{ matrix.python }}-pybind-${{ matrix.pybind11-branch }}.patch" - path: "./tests/stubs/python-${{ matrix.python }}/pybind11-${{ matrix.pybind11-branch }}.patch" + 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 From 2d1aa0fdfa17b3411b1af2571f61ab762a0a4d5a Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sat, 25 Nov 2023 23:01:28 +0900 Subject: [PATCH 04/15] refactor: Remove explicit use of `InvalidExpr` --- pybind11_stubgen/__init__.py | 6 ++--- pybind11_stubgen/parser/mixins/fix.py | 10 +++----- pybind11_stubgen/typing_ext.py | 17 ++++++------- .../demo/_bindings/flawed_bindings.pyi | 24 +++---------------- 4 files changed, 16 insertions(+), 41 deletions(-) diff --git a/pybind11_stubgen/__init__.py b/pybind11_stubgen/__init__.py index 57cab14..40e7816 100644 --- a/pybind11_stubgen/__init__.py +++ b/pybind11_stubgen/__init__.py @@ -48,7 +48,7 @@ RemoveSelfAnnotation, ReplaceReadWritePropertyWithField, RewritePybind11EnumValueRepr, - WrapInvalidExpressionInAnnotated, + WrapInvalidExpressions, ) from pybind11_stubgen.parser.mixins.parse import ( BaseParser, @@ -252,7 +252,7 @@ def stub_parser_from_args(args: CLIArgs) -> IParser: if args.print_invalid_expressions_as_is: wrap_invalid_expressions = [] else: - wrap_invalid_expressions = [WrapInvalidExpressionInAnnotated] + wrap_invalid_expressions = [WrapInvalidExpressions] class Parser( *error_handlers_top, # type: ignore[misc] @@ -268,7 +268,6 @@ class Parser( FixMissingEnumMembersAnnotation, OverridePrintSafeValues, *numpy_fixes, # type: ignore[misc] - *wrap_invalid_expressions, FixNumpyDtype, FixNumpyArrayFlags, FixCurrentModulePrefixInTypeNames, @@ -283,6 +282,7 @@ class Parser( FixRedundantMethodsFromBuiltinObject, RemoveSelfAnnotation, FixPybind11EnumStrDoc, + *wrap_invalid_expressions, ExtractSignaturesFromPybind11Docstrings, ParserDispatchMixin, BaseParser, diff --git a/pybind11_stubgen/parser/mixins/fix.py b/pybind11_stubgen/parser/mixins/fix.py index bb26b39..02dd2ab 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -36,7 +36,7 @@ TypeVar_, Value, ) -from pybind11_stubgen.typing_ext import DynamicSize, FixedSize, InvalidExpr +from pybind11_stubgen.typing_ext import DynamicSize, FixedSize logger = getLogger("pybind11_stubgen") @@ -867,7 +867,7 @@ def handle_class_member( return result -class WrapInvalidExpressionInAnnotated(IParser): +class WrapInvalidExpressions(IParser): def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: @@ -875,16 +875,12 @@ def parse_annotation_str( if not isinstance(result, InvalidExpression): return result - self.handle_type(InvalidExpr) substitute_t = ResolvedType(self.handle_type(Any)) return ResolvedType( QualifiedName.from_str("typing.Annotated"), parameters=[ substitute_t, - Value( - repr=repr(InvalidExpr(expr=annotation_str.strip())), - is_print_safe=True, - ), + result, ], ) diff --git a/pybind11_stubgen/typing_ext.py b/pybind11_stubgen/typing_ext.py index a41e7f6..7426de4 100644 --- a/pybind11_stubgen/typing_ext.py +++ b/pybind11_stubgen/typing_ext.py @@ -1,5 +1,7 @@ from __future__ import annotations +from typing import Any + class FixedSize: def __init__(self, *dim: int): @@ -25,13 +27,8 @@ def __repr__(self): ) -class InvalidExpr: - def __init__(self, expr: str): - self.expr = expr - - def __repr__(self): - return ( - f"{self.__module__}." - f"{self.__class__.__qualname__}" - f"({repr(self.expr)})" - ) +def InvalidExpr(expr: str) -> Any: + raise RuntimeError( + "The method exists only for annotation purposes in stub files. " + "Should never not be used at runtime" + ) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index a31b95e..04f104f 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = [ "Enum", "Unbound", @@ -20,24 +18,8 @@ class Enum: class Unbound: pass -def accept_unbound_enum( - arg0: typing.Annotated[ - typing.Any, - pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Enum"), - ] -) -> int: ... +def accept_unbound_enum(arg0: typing.Annotated[typing.Any, ...]) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type( - arg0: tuple[ - typing.Annotated[ - typing.Any, - pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), - ], - int, - ] -) -> int: ... +def accept_unbound_type(arg0: tuple[typing.Annotated[typing.Any, ...], int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> typing.Annotated[ - typing.Any, - pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), -]: ... +def get_unbound_type() -> typing.Annotated[typing.Any, ...]: ... From 331ccf1134f7ae84475cc836b2e672ed78724f8d Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sat, 25 Nov 2023 23:05:33 +0900 Subject: [PATCH 05/15] fix: Compatability with python<3.10 --- 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 02dd2ab..3fd68f8 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -875,7 +875,7 @@ def parse_annotation_str( if not isinstance(result, InvalidExpression): return result - substitute_t = ResolvedType(self.handle_type(Any)) + substitute_t = self.parse_annotation_str("typing.Any") return ResolvedType( QualifiedName.from_str("typing.Annotated"), parameters=[ From d04d1cce17cd82d7a981083deb91abd70fc67d66 Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sat, 25 Nov 2023 23:09:17 +0900 Subject: [PATCH 06/15] fixup --- 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 3fd68f8..144941f 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -877,7 +877,7 @@ def parse_annotation_str( substitute_t = self.parse_annotation_str("typing.Any") return ResolvedType( - QualifiedName.from_str("typing.Annotated"), + QualifiedName.from_str("Annotated"), parameters=[ substitute_t, result, From a4bde3f4c8f022feba14aa68e0afb06b1274670c Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sat, 25 Nov 2023 23:15:23 +0900 Subject: [PATCH 07/15] chore: Update stubs --- .../demo/_bindings/flawed_bindings.pyi | 8 +++++--- .../demo/_bindings/flawed_bindings.pyi | 8 +++++--- .../demo/_bindings/flawed_bindings.pyi | 8 +++++--- .../demo/_bindings/flawed_bindings.pyi | 12 +++++++++--- .../demo/_bindings/flawed_bindings.pyi | 12 +++++++++--- 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi index 651a886..04f104f 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi @@ -1,5 +1,7 @@ from __future__ import annotations +import typing + __all__ = [ "Enum", "Unbound", @@ -16,8 +18,8 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: ...) -> int: ... +def accept_unbound_enum(arg0: typing.Annotated[typing.Any, ...]) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type(arg0: tuple[..., int]) -> int: ... +def accept_unbound_type(arg0: tuple[typing.Annotated[typing.Any, ...], int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> ...: ... +def get_unbound_type() -> typing.Annotated[typing.Any, ...]: ... 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 651a886..04f104f 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 @@ -1,5 +1,7 @@ from __future__ import annotations +import typing + __all__ = [ "Enum", "Unbound", @@ -16,8 +18,8 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: ...) -> int: ... +def accept_unbound_enum(arg0: typing.Annotated[typing.Any, ...]) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type(arg0: tuple[..., int]) -> int: ... +def accept_unbound_type(arg0: tuple[typing.Annotated[typing.Any, ...], int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> ...: ... +def get_unbound_type() -> typing.Annotated[typing.Any, ...]: ... 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 651a886..04f104f 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 @@ -1,5 +1,7 @@ from __future__ import annotations +import typing + __all__ = [ "Enum", "Unbound", @@ -16,8 +18,8 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: ...) -> int: ... +def accept_unbound_enum(arg0: typing.Annotated[typing.Any, ...]) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type(arg0: tuple[..., int]) -> int: ... +def accept_unbound_type(arg0: tuple[typing.Annotated[typing.Any, ...], int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> ...: ... +def get_unbound_type() -> typing.Annotated[typing.Any, ...]: ... diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index 651a886..f61b9ca 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -1,5 +1,9 @@ from __future__ import annotations +import typing + +import typing_extensions + __all__ = [ "Enum", "Unbound", @@ -16,8 +20,10 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: ...) -> int: ... +def accept_unbound_enum(arg0: typing_extensions.Annotated[typing.Any, ...]) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type(arg0: tuple[..., int]) -> int: ... +def accept_unbound_type( + arg0: tuple[typing_extensions.Annotated[typing.Any, ...], int] +) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> ...: ... +def get_unbound_type() -> typing_extensions.Annotated[typing.Any, ...]: ... diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index 651a886..f61b9ca 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -1,5 +1,9 @@ from __future__ import annotations +import typing + +import typing_extensions + __all__ = [ "Enum", "Unbound", @@ -16,8 +20,10 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: ...) -> int: ... +def accept_unbound_enum(arg0: typing_extensions.Annotated[typing.Any, ...]) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type(arg0: tuple[..., int]) -> int: ... +def accept_unbound_type( + arg0: tuple[typing_extensions.Annotated[typing.Any, ...], int] +) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> ...: ... +def get_unbound_type() -> typing_extensions.Annotated[typing.Any, ...]: ... From 7c20ecd4558e03dedc1f4b73acb617bff07e63fb Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sun, 26 Nov 2023 00:39:23 +0900 Subject: [PATCH 08/15] fix: Replace random object address in value str --- pybind11_stubgen/parser/mixins/fix.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pybind11_stubgen/parser/mixins/fix.py b/pybind11_stubgen/parser/mixins/fix.py index 144941f..2a3a17b 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -498,6 +498,14 @@ def handle_value(self, value: Any) -> Value: result.repr = self._pattern.sub(r"<\g object>", result.repr) return result + def parse_value_str(self, value: str) -> Value | InvalidExpression: + result = super().parse_value_str(value) + if isinstance(result, Value): + result.repr = self._pattern.sub(r"<\g object>", result.repr) + else: + result.text = self._pattern.sub(r"<\g object>", result.text) + return result + class FixNumpyArrayDimAnnotation(IParser): __array_names: set[QualifiedName] = { From 671e114ee7ee9400745fd2647106173ddd34aa17 Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sun, 26 Nov 2023 00:40:31 +0900 Subject: [PATCH 09/15] fix: Recognize more print-safe type --- pybind11_stubgen/parser/mixins/parse.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pybind11_stubgen/parser/mixins/parse.py b/pybind11_stubgen/parser/mixins/parse.py index 64ea8df..fe46c24 100644 --- a/pybind11_stubgen/parser/mixins/parse.py +++ b/pybind11_stubgen/parser/mixins/parse.py @@ -1,6 +1,7 @@ from __future__ import annotations import ast +import datetime import inspect import re import types @@ -34,6 +35,7 @@ TypeVar_, Value, ) +from pybind11_stubgen.typing_ext import DynamicSize, FixedSize _generic_args = [ Argument(name=Identifier("args"), variadic=True), @@ -370,6 +372,10 @@ def handle_value(self, value: Any) -> Value: return Value(repr=str(self.handle_type(value)), is_print_safe=True) if inspect.ismodule(value): return Value(repr=value.__name__, is_print_safe=True) + if isinstance(value, datetime.timedelta): + return Value(repr=repr(value), is_print_safe=True) + if isinstance(value, (FixedSize, DynamicSize)): + return Value(repr=repr(value), is_print_safe=True) return Value(repr=repr(value), is_print_safe=False) def handle_type(self, type_: type) -> QualifiedName: From 025a6f3d51e3ed07ee86f6e45a27c5b56bfe4e27 Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sun, 26 Nov 2023 00:43:07 +0900 Subject: [PATCH 10/15] refactor!: Remove invalid `invalid_expr_as_ellipses` from printer I don't like the fact I'm modifying the module import in printer --- pybind11_stubgen/__init__.py | 9 +---- pybind11_stubgen/printer.py | 67 ++++++++++++++++++---------------- pybind11_stubgen/typing_ext.py | 7 ++++ 3 files changed, 45 insertions(+), 38 deletions(-) diff --git a/pybind11_stubgen/__init__.py b/pybind11_stubgen/__init__.py index 40e7816..8cfb9aa 100644 --- a/pybind11_stubgen/__init__.py +++ b/pybind11_stubgen/__init__.py @@ -249,11 +249,6 @@ def stub_parser_from_args(args: CLIArgs) -> IParser: ), ] - if args.print_invalid_expressions_as_is: - wrap_invalid_expressions = [] - else: - wrap_invalid_expressions = [WrapInvalidExpressions] - class Parser( *error_handlers_top, # type: ignore[misc] FixMissing__future__AnnotationsImport, @@ -282,7 +277,7 @@ class Parser( FixRedundantMethodsFromBuiltinObject, RemoveSelfAnnotation, FixPybind11EnumStrDoc, - *wrap_invalid_expressions, + WrapInvalidExpressions, ExtractSignaturesFromPybind11Docstrings, ParserDispatchMixin, BaseParser, @@ -313,7 +308,7 @@ def main(): args = arg_parser().parse_args(namespace=CLIArgs()) parser = stub_parser_from_args(args) - printer = Printer(invalid_expr_as_ellipses=not args.print_invalid_expressions_as_is) + printer = Printer() out_dir, sub_dir = to_output_and_subdir( output_dir=args.output_dir, diff --git a/pybind11_stubgen/printer.py b/pybind11_stubgen/printer.py index 1f755aa..13a24c6 100644 --- a/pybind11_stubgen/printer.py +++ b/pybind11_stubgen/printer.py @@ -19,6 +19,7 @@ Modifier, Module, Property, + QualifiedName, ResolvedType, TypeVar_, Value, @@ -30,8 +31,8 @@ def indent_lines(lines: list[str], by=4) -> list[str]: class Printer: - def __init__(self, invalid_expr_as_ellipses: bool): - self.invalid_expr_as_ellipses = invalid_expr_as_ellipses + def __init__(self): + self._need_typing_ext = False def print_alias(self, alias: Alias) -> list[str]: return [f"{alias.name} = {alias.origin}"] @@ -43,13 +44,8 @@ def print_attribute(self, attr: Attribute) -> list[str]: if attr.annotation is not None: parts.append(f": {self.print_annotation(attr.annotation)}") - if attr.value is not None and attr.value.is_print_safe: + if attr.value is not None: parts.append(f" = {self.print_value(attr.value)}") - else: - if attr.annotation is None: - parts.append(" = ...") - if attr.value is not None: - parts.append(f" # value = {self.print_value(attr.value)}") return ["".join(parts)] @@ -202,40 +198,51 @@ def print_method(self, method: Method) -> list[str]: return result def print_module(self, module: Module) -> list[str]: - result = [] - - if module.doc is not None: - result.extend(self.print_docstring(module.doc)) - - for import_ in sorted(module.imports, key=lambda x: x.origin): - result.extend(self.print_import(import_)) + result_bottom = [] + tmp = self._need_typing_ext for sub_module in module.sub_modules: - result.extend(self.print_submodule_import(sub_module.name)) + result_bottom.extend(self.print_submodule_import(sub_module.name)) # Place __all__ above everything for attr in sorted(module.attributes, key=lambda a: a.name): if attr.name == "__all__": - result.extend(self.print_attribute(attr)) + result_bottom.extend(self.print_attribute(attr)) break for type_var in sorted(module.type_vars, key=lambda t: t.name): - result.extend(self.print_type_var(type_var)) + result_bottom.extend(self.print_type_var(type_var)) for class_ in sorted(module.classes, key=lambda c: c.name): - result.extend(self.print_class(class_)) + result_bottom.extend(self.print_class(class_)) for func in sorted(module.functions, key=lambda f: f.name): - result.extend(self.print_function(func)) + result_bottom.extend(self.print_function(func)) for attr in sorted(module.attributes, key=lambda a: a.name): if attr.name != "__all__": - result.extend(self.print_attribute(attr)) + result_bottom.extend(self.print_attribute(attr)) for alias in module.aliases: - result.extend(self.print_alias(alias)) + result_bottom.extend(self.print_alias(alias)) + + if self._need_typing_ext: + module.imports.add( + Import( + name=None, + origin=QualifiedName.from_str("pybind11_stubgen.typing_ext"), + ) + ) - return result + result_top = [] + if module.doc is not None: + result_top.extend(self.print_docstring(module.doc)) + + for import_ in sorted(module.imports, key=lambda x: x.origin): + result_top.extend(self.print_import(import_)) + + self._need_typing_ext = tmp + return result_top + result_bottom def print_property(self, prop: Property) -> list[str]: if not prop.getter: @@ -276,11 +283,10 @@ def print_property(self, prop: Property) -> list[str]: return result def print_value(self, value: Value) -> str: - split = value.repr.split("\n", 1) - if len(split) == 1: - return split[0] - else: - return split[0] + "..." + if value.is_print_safe: + return value.repr + self._need_typing_ext = True + return f"pybind11_stubgen.typing_ext.ValueExpr({repr(value.repr)})" def print_type(self, type_: ResolvedType) -> str: if ( @@ -312,6 +318,5 @@ def print_annotation(self, annotation: Annotation) -> str: raise AssertionError() def print_invalid_exp(self, invalid_expr: InvalidExpression) -> str: - if self.invalid_expr_as_ellipses: - return "..." - return invalid_expr.text + self._need_typing_ext = True + return f"pybind11_stubgen.typing_ext.InvalidExpr({repr(invalid_expr.text)})" diff --git a/pybind11_stubgen/typing_ext.py b/pybind11_stubgen/typing_ext.py index 7426de4..dd9e36b 100644 --- a/pybind11_stubgen/typing_ext.py +++ b/pybind11_stubgen/typing_ext.py @@ -32,3 +32,10 @@ def InvalidExpr(expr: str) -> Any: "The method exists only for annotation purposes in stub files. " "Should never not be used at runtime" ) + + +def ValueExpr(expr: str) -> Any: + raise RuntimeError( + "The method exists only for annotation purposes in stub files. " + "Should never not be used at runtime" + ) From 8941fde58e9e01d7f75d0eeb4d7150540cae4ce8 Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sun, 26 Nov 2023 01:05:00 +0900 Subject: [PATCH 11/15] fix: Handle typing and non-typing generics --- pybind11_stubgen/parser/mixins/parse.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pybind11_stubgen/parser/mixins/parse.py b/pybind11_stubgen/parser/mixins/parse.py index fe46c24..00d87cd 100644 --- a/pybind11_stubgen/parser/mixins/parse.py +++ b/pybind11_stubgen/parser/mixins/parse.py @@ -5,6 +5,7 @@ import inspect import re import types +import typing from typing import Any from pybind11_stubgen.parser.errors import ( @@ -252,16 +253,16 @@ def handle_function(self, path: QualifiedName, func: Any) -> list[Function]: func_args[arg_name].annotation = self.parse_annotation_str( annotation ) - elif not isinstance(annotation, type): - func_args[arg_name].annotation = self.handle_value(annotation) elif self._is_generic_alias(annotation): func_args[arg_name].annotation = self.parse_annotation_str( str(annotation) ) - else: + elif isinstance(annotation, type): func_args[arg_name].annotation = ResolvedType( name=self.handle_type(annotation), ) + else: + func_args[arg_name].annotation = self.handle_value(annotation) if "return" in func_args: returns = func_args["return"].annotation else: @@ -293,7 +294,10 @@ def _is_generic_alias(self, annotation: type) -> bool: generic_alias_t: type | None = getattr(types, "GenericAlias", None) if generic_alias_t is None: return False - return isinstance(annotation, generic_alias_t) + typing_generic_alias_t = type(typing.List[int]) + return isinstance(annotation, generic_alias_t) or isinstance( + annotation, typing_generic_alias_t + ) def handle_import(self, path: QualifiedName, origin: Any) -> Import | None: full_name = self._get_full_name(path, origin) From 37feafd56ce1e7883a3d74d624c8a8e2d350da86 Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sun, 26 Nov 2023 01:29:25 +0900 Subject: [PATCH 12/15] fix: Update imports on `handle_value` --- pybind11_stubgen/parser/mixins/fix.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pybind11_stubgen/parser/mixins/fix.py b/pybind11_stubgen/parser/mixins/fix.py index 2a3a17b..4d7756f 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -144,6 +144,11 @@ def handle_value(self, value: Any) -> Value: result = super().handle_value(value) if inspect.isroutine(value) and result.is_print_safe: self._add_import(QualifiedName.from_str(result.repr)) + else: + type_ = type(value) + self._add_import( + QualifiedName.from_str(f"{type_.__module__}.{type_.__qualname__}") + ) return result def parse_annotation_str( @@ -159,7 +164,9 @@ def _add_import(self, name: QualifiedName) -> None: return if len(name) == 1 and len(name[0]) == 0: return - if hasattr(builtins, name[0]): + if len(name) == 1 and hasattr(builtins, name[0]): + return + if len(name) > 0 and name[0] == "builtins": return if self.__current_class is not None and hasattr(self.__current_class, name[0]): return @@ -171,6 +178,8 @@ def _add_import(self, name: QualifiedName) -> None: if module_name is None: self.report_error(NameResolutionError(name)) return + if self.__current_module.__name__ == str(module_name): + return self.__extra_imports.add(Import(name=None, origin=module_name)) def _get_parent_module(self, name: QualifiedName) -> QualifiedName | None: @@ -913,8 +922,6 @@ def parse_annotation_str( except ValueError: pass else: - # call `handle_type` to trigger implicit import - self.handle_type(FixedSize) return self.handle_value(FixedSize(*dimensions)) return result From 562ada4ce2ec24c964ba537e980228c19559e0c7 Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sun, 26 Nov 2023 01:30:18 +0900 Subject: [PATCH 13/15] chore: Update stubs --- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +- .../aliases/foreign_class_member.pyi | 4 +- .../demo/_bindings/classes.pyi | 14 ++++- .../demo/_bindings/duplicate_enum.pyi | 18 ++++-- .../demo/_bindings/eigen.pyi | 63 +++++++++++++++---- .../demo/_bindings/enum.pyi | 36 +++++++---- .../demo/_bindings/flawed_bindings.pyi | 36 +++++++++-- .../demo/_bindings/issues.pyi | 4 +- .../demo/_bindings/values.pyi | 15 +++-- .../demo/pure_python/functions.pyi | 10 ++- .../demo/pure_python/functions_3_8_plus.pyi | 2 +- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +- .../aliases/foreign_class_member.pyi | 4 +- .../demo/_bindings/classes.pyi | 14 ++++- .../demo/_bindings/duplicate_enum.pyi | 18 ++++-- .../demo/_bindings/enum.pyi | 36 +++++++---- .../demo/_bindings/flawed_bindings.pyi | 36 +++++++++-- .../demo/_bindings/issues.pyi | 4 +- .../demo/_bindings/values.pyi | 15 +++-- .../demo/pure_python/functions.pyi | 10 ++- .../demo/pure_python/functions_3_8_plus.pyi | 2 +- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +- .../aliases/foreign_class_member.pyi | 4 +- .../demo/_bindings/classes.pyi | 14 ++++- .../demo/_bindings/duplicate_enum.pyi | 18 ++++-- .../demo/_bindings/enum.pyi | 36 +++++++---- .../demo/_bindings/flawed_bindings.pyi | 36 +++++++++-- .../demo/_bindings/issues.pyi | 4 +- .../demo/_bindings/values.pyi | 15 +++-- .../demo/pure_python/functions.pyi | 10 ++- .../demo/pure_python/functions_3_8_plus.pyi | 2 +- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +- .../aliases/foreign_class_member.pyi | 4 +- .../demo/_bindings/classes.pyi | 14 ++++- .../demo/_bindings/duplicate_enum.pyi | 18 ++++-- .../demo/_bindings/enum.pyi | 36 +++++++---- .../demo/_bindings/flawed_bindings.pyi | 36 +++++++++-- .../demo/_bindings/issues.pyi | 4 +- .../demo/_bindings/values.pyi | 15 +++-- .../demo/pure_python/functions.pyi | 10 ++- .../demo/pure_python/functions_3_8_plus.pyi | 2 +- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +- .../aliases/foreign_class_member.pyi | 4 +- .../demo/_bindings/classes.pyi | 14 ++++- .../demo/_bindings/duplicate_enum.pyi | 18 ++++-- .../demo/_bindings/enum.pyi | 36 +++++++---- .../demo/_bindings/flawed_bindings.pyi | 33 ++++++++-- .../demo/_bindings/issues.pyi | 4 +- .../demo/_bindings/values.pyi | 15 +++-- .../demo/pure_python/functions.pyi | 10 ++- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +- .../aliases/foreign_class_member.pyi | 4 +- .../demo/_bindings/classes.pyi | 14 ++++- .../demo/_bindings/duplicate_enum.pyi | 18 ++++-- .../demo/_bindings/enum.pyi | 36 +++++++---- .../demo/_bindings/flawed_bindings.pyi | 33 ++++++++-- .../demo/_bindings/issues.pyi | 4 +- .../demo/_bindings/values.pyi | 15 +++-- .../demo/pure_python/functions.pyi | 10 ++- .../demo/pure_python/functions_3_8_plus.pyi | 4 +- 60 files changed, 713 insertions(+), 214 deletions(-) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_attr.pyi index efb53a7..bd39444 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_attr.pyi @@ -1,6 +1,10 @@ from __future__ import annotations +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo # value = +value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_class_member.pyi index 24968c9..1148e68 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["Bar1"] @@ -9,4 +11,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/classes.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/classes.pyi index 4a3b7bd..8e23a2a 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/classes.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -34,11 +36,17 @@ class Outer: TWO """ - ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = - TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = + ONE: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") + TWO: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] # value = {'ONE': , 'TWO': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'ONE': , 'TWO': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/duplicate_enum.pyi index 70eae65..35badaa 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/duplicate_enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["ConsoleForegroundColor", "Magenta", "accepts_ambiguous_enum"] class ConsoleForegroundColor: @@ -13,10 +15,12 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Magenta': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Magenta': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -32,6 +36,12 @@ class ConsoleForegroundColor: @property def value(self) -> int: ... -def accepts_ambiguous_enum(color: ConsoleForegroundColor = ...) -> None: ... +def accepts_ambiguous_enum( + color: ConsoleForegroundColor = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> None: ... -Magenta: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/eigen.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/eigen.pyi index 92c4b1c..9f6fa55 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/eigen.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/eigen.pyi @@ -3,6 +3,7 @@ from __future__ import annotations import typing import numpy +import pybind11_stubgen.typing_ext import scipy.sparse __all__ = [ @@ -25,12 +26,20 @@ N = typing.TypeVar("N", bound=int) def accept_matrix_int( arg0: numpy.ndarray[ - tuple[typing.Literal[3], typing.Literal[3]], numpy.dtype[numpy.int32] + tuple[ + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("3")], + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("3")], + ], + numpy.dtype[numpy.int32], ] ) -> None: ... def accept_vector_float64( arg0: numpy.ndarray[ - tuple[typing.Literal[3], typing.Literal[1]], numpy.dtype[numpy.float64] + tuple[ + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("3")], + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("1")], + ], + numpy.dtype[numpy.float64], ] ) -> None: ... def dense_matrix_c( @@ -41,30 +50,62 @@ def dense_matrix_r( ) -> numpy.ndarray[tuple[M, N], numpy.dtype[numpy.float32]]: ... def fixed_mutator_a( arg0: numpy.ndarray[ - tuple[typing.Literal[5], typing.Literal[6]], numpy.dtype[numpy.float32] + tuple[ + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("5")], + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("6")], + ], + numpy.dtype[numpy.float32], ] ) -> None: ... def fixed_mutator_c( arg0: numpy.ndarray[ - tuple[typing.Literal[5], typing.Literal[6]], numpy.dtype[numpy.float32] + tuple[ + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("5")], + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("6")], + ], + numpy.dtype[numpy.float32], ] ) -> None: ... def fixed_mutator_r( arg0: numpy.ndarray[ - tuple[typing.Literal[5], typing.Literal[6]], numpy.dtype[numpy.float32] + tuple[ + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("5")], + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("6")], + ], + numpy.dtype[numpy.float32], ] ) -> None: ... def four_col_matrix_r( - arg0: numpy.ndarray[tuple[M, typing.Literal[4]], numpy.dtype[numpy.float32]] -) -> numpy.ndarray[tuple[M, typing.Literal[4]], numpy.dtype[numpy.float32]]: ... + arg0: numpy.ndarray[ + tuple[M, typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("4")]], + numpy.dtype[numpy.float32], + ] +) -> numpy.ndarray[ + tuple[M, typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("4")]], + numpy.dtype[numpy.float32], +]: ... def four_row_matrix_r( - arg0: numpy.ndarray[tuple[typing.Literal[4], N], numpy.dtype[numpy.float32]] -) -> numpy.ndarray[tuple[typing.Literal[4], N], numpy.dtype[numpy.float32]]: ... + arg0: numpy.ndarray[ + tuple[typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("4")], N], + numpy.dtype[numpy.float32], + ] +) -> numpy.ndarray[ + tuple[typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("4")], N], + numpy.dtype[numpy.float32], +]: ... def get_matrix_int() -> numpy.ndarray[ - tuple[typing.Literal[3], typing.Literal[3]], numpy.dtype[numpy.int32] + tuple[ + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("3")], + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("3")], + ], + numpy.dtype[numpy.int32], ]: ... def get_vector_float64() -> numpy.ndarray[ - tuple[typing.Literal[3], typing.Literal[1]], numpy.dtype[numpy.float64] + tuple[ + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("3")], + typing.Literal[pybind11_stubgen.typing_ext.ValueExpr("1")], + ], + numpy.dtype[numpy.float64], ]: ... def sparse_matrix_c(arg0: scipy.sparse.csc_matrix) -> scipy.sparse.csc_matrix: ... def sparse_matrix_r(arg0: scipy.sparse.csr_matrix) -> scipy.sparse.csr_matrix: ... diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/enum.pyi index e3f9e10..33c8e6b 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = [ "Blue", "ConsoleForegroundColor", @@ -29,22 +31,24 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Green: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") None_: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Yellow: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -64,8 +68,18 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor # value = -Green: ConsoleForegroundColor # value = -Magenta: ConsoleForegroundColor # value = -None_: ConsoleForegroundColor # value = -Yellow: ConsoleForegroundColor # value = +Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi index 04f104f..752f2ea 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/flawed_bindings.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = [ "Enum", "Unbound", @@ -18,8 +20,32 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: typing.Annotated[typing.Any, ...]) -> int: ... -def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type(arg0: tuple[typing.Annotated[typing.Any, ...], int]) -> int: ... -def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> typing.Annotated[typing.Any, ...]: ... +def accept_unbound_enum( + arg0: typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Enum"), + ] +) -> int: ... +def accept_unbound_enum_defaulted( + x: Enum = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> int: ... +def accept_unbound_type( + arg0: tuple[ + typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), + ], + int, + ] +) -> int: ... +def accept_unbound_type_defaulted( + x: Unbound = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> int: ... +def get_unbound_type() -> typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), +]: ... diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/issues.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/issues.pyi index 09af4e4..029d664 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/issues.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -21,4 +23,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any # value = +_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/values.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/values.pyi index eb4a85a..b049f81 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/values.pyi @@ -3,6 +3,7 @@ from __future__ import annotations import datetime import numpy +import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -27,10 +28,14 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list # value = [, ] -foovar: Foo # value = +foolist: list = pybind11_stubgen.typing_ext.ValueExpr( + "[, ]" +) +foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) list_with_none: list = [None, 2, {}] none = None -t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) -t_20ns: datetime.timedelta # value = datetime.timedelta(0) -t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) +t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) +t_20ns: datetime.timedelta = datetime.timedelta(0) +t_30s: datetime.timedelta = datetime.timedelta(seconds=30) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/pure_python/functions.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/pure_python/functions.pyi index a6c7165..320ddc7 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/pure_python/functions.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/pure_python/functions.pyi @@ -3,6 +3,8 @@ from __future__ import annotations import sys as sys import typing as typing +import pybind11_stubgen.typing_ext + from demo.pure_python.functions_3_8_plus import args_mix from demo.pure_python.functions_3_9_plus import generic_alias_annotation @@ -24,8 +26,12 @@ class _Dummy: def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... -def builtin_function_as_default_arg(func: type(len) = len): ... -def function_as_default_arg(func: type(search) = search): ... +def builtin_function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(len)") = len, +): ... +def function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(search)") = search, +): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/pure_python/functions_3_8_plus.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/pure_python/functions_3_8_plus.pyi index dd9ffdc..3361a12 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/pure_python/functions_3_8_plus.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/pure_python/functions_3_8_plus.pyi @@ -11,5 +11,5 @@ def args_mix( *args: int, x: int = 1, y=int, - **kwargs: typing.Dict[int, str], + **kwargs: dict[int, str], ): ... diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi index efb53a7..bd39444 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -1,6 +1,10 @@ from __future__ import annotations +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo # value = +value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi index 24968c9..1148e68 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["Bar1"] @@ -9,4 +11,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index 4a3b7bd..8e23a2a 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -34,11 +36,17 @@ class Outer: TWO """ - ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = - TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = + ONE: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") + TWO: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] # value = {'ONE': , 'TWO': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'ONE': , 'TWO': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi index 70eae65..35badaa 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["ConsoleForegroundColor", "Magenta", "accepts_ambiguous_enum"] class ConsoleForegroundColor: @@ -13,10 +15,12 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Magenta': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Magenta': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -32,6 +36,12 @@ class ConsoleForegroundColor: @property def value(self) -> int: ... -def accepts_ambiguous_enum(color: ConsoleForegroundColor = ...) -> None: ... +def accepts_ambiguous_enum( + color: ConsoleForegroundColor = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> None: ... -Magenta: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index e3f9e10..33c8e6b 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = [ "Blue", "ConsoleForegroundColor", @@ -29,22 +31,24 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Green: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") None_: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Yellow: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -64,8 +68,18 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor # value = -Green: ConsoleForegroundColor # value = -Magenta: ConsoleForegroundColor # value = -None_: ConsoleForegroundColor # value = -Yellow: ConsoleForegroundColor # value = +Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index 04f104f..752f2ea 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = [ "Enum", "Unbound", @@ -18,8 +20,32 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: typing.Annotated[typing.Any, ...]) -> int: ... -def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type(arg0: tuple[typing.Annotated[typing.Any, ...], int]) -> int: ... -def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> typing.Annotated[typing.Any, ...]: ... +def accept_unbound_enum( + arg0: typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Enum"), + ] +) -> int: ... +def accept_unbound_enum_defaulted( + x: Enum = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> int: ... +def accept_unbound_type( + arg0: tuple[ + typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), + ], + int, + ] +) -> int: ... +def accept_unbound_type_defaulted( + x: Unbound = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> int: ... +def get_unbound_type() -> typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), +]: ... diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi index 09af4e4..029d664 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -21,4 +23,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any # value = +_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi index eb4a85a..b049f81 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -3,6 +3,7 @@ from __future__ import annotations import datetime import numpy +import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -27,10 +28,14 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list # value = [, ] -foovar: Foo # value = +foolist: list = pybind11_stubgen.typing_ext.ValueExpr( + "[, ]" +) +foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) list_with_none: list = [None, 2, {}] none = None -t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) -t_20ns: datetime.timedelta # value = datetime.timedelta(0) -t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) +t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) +t_20ns: datetime.timedelta = datetime.timedelta(0) +t_30s: datetime.timedelta = datetime.timedelta(seconds=30) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi index a6c7165..320ddc7 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi @@ -3,6 +3,8 @@ from __future__ import annotations import sys as sys import typing as typing +import pybind11_stubgen.typing_ext + from demo.pure_python.functions_3_8_plus import args_mix from demo.pure_python.functions_3_9_plus import generic_alias_annotation @@ -24,8 +26,12 @@ class _Dummy: def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... -def builtin_function_as_default_arg(func: type(len) = len): ... -def function_as_default_arg(func: type(search) = search): ... +def builtin_function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(len)") = len, +): ... +def function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(search)") = search, +): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi index dd9ffdc..3361a12 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi @@ -11,5 +11,5 @@ def args_mix( *args: int, x: int = 1, y=int, - **kwargs: typing.Dict[int, str], + **kwargs: dict[int, str], ): ... diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi index efb53a7..bd39444 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -1,6 +1,10 @@ from __future__ import annotations +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo # value = +value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi index 24968c9..1148e68 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["Bar1"] @@ -9,4 +11,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") 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 4a3b7bd..8e23a2a 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,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -34,11 +36,17 @@ class Outer: TWO """ - ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = - TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = + ONE: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") + TWO: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] # value = {'ONE': , 'TWO': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'ONE': , 'TWO': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi index 70eae65..35badaa 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["ConsoleForegroundColor", "Magenta", "accepts_ambiguous_enum"] class ConsoleForegroundColor: @@ -13,10 +15,12 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Magenta': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Magenta': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -32,6 +36,12 @@ class ConsoleForegroundColor: @property def value(self) -> int: ... -def accepts_ambiguous_enum(color: ConsoleForegroundColor = ...) -> None: ... +def accepts_ambiguous_enum( + color: ConsoleForegroundColor = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> None: ... -Magenta: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index e3f9e10..33c8e6b 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = [ "Blue", "ConsoleForegroundColor", @@ -29,22 +31,24 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Green: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") None_: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Yellow: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -64,8 +68,18 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor # value = -Green: ConsoleForegroundColor # value = -Magenta: ConsoleForegroundColor # value = -None_: ConsoleForegroundColor # value = -Yellow: ConsoleForegroundColor # value = +Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) 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 04f104f..752f2ea 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 @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = [ "Enum", "Unbound", @@ -18,8 +20,32 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: typing.Annotated[typing.Any, ...]) -> int: ... -def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type(arg0: tuple[typing.Annotated[typing.Any, ...], int]) -> int: ... -def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> typing.Annotated[typing.Any, ...]: ... +def accept_unbound_enum( + arg0: typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Enum"), + ] +) -> int: ... +def accept_unbound_enum_defaulted( + x: Enum = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> int: ... +def accept_unbound_type( + arg0: tuple[ + typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), + ], + int, + ] +) -> int: ... +def accept_unbound_type_defaulted( + x: Unbound = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> int: ... +def get_unbound_type() -> typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), +]: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi index 09af4e4..029d664 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -21,4 +23,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any # value = +_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi index eb4a85a..b049f81 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -3,6 +3,7 @@ from __future__ import annotations import datetime import numpy +import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -27,10 +28,14 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list # value = [, ] -foovar: Foo # value = +foolist: list = pybind11_stubgen.typing_ext.ValueExpr( + "[, ]" +) +foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) list_with_none: list = [None, 2, {}] none = None -t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) -t_20ns: datetime.timedelta # value = datetime.timedelta(0) -t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) +t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) +t_20ns: datetime.timedelta = datetime.timedelta(0) +t_30s: datetime.timedelta = datetime.timedelta(seconds=30) diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi index a6c7165..320ddc7 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi @@ -3,6 +3,8 @@ from __future__ import annotations import sys as sys import typing as typing +import pybind11_stubgen.typing_ext + from demo.pure_python.functions_3_8_plus import args_mix from demo.pure_python.functions_3_9_plus import generic_alias_annotation @@ -24,8 +26,12 @@ class _Dummy: def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... -def builtin_function_as_default_arg(func: type(len) = len): ... -def function_as_default_arg(func: type(search) = search): ... +def builtin_function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(len)") = len, +): ... +def function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(search)") = search, +): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi index dd9ffdc..3361a12 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi @@ -11,5 +11,5 @@ def args_mix( *args: int, x: int = 1, y=int, - **kwargs: typing.Dict[int, str], + **kwargs: dict[int, str], ): ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi index efb53a7..bd39444 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -1,6 +1,10 @@ from __future__ import annotations +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo # value = +value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi index 24968c9..1148e68 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["Bar1"] @@ -9,4 +11,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") 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 4a3b7bd..8e23a2a 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,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -34,11 +36,17 @@ class Outer: TWO """ - ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = - TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = + ONE: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") + TWO: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] # value = {'ONE': , 'TWO': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'ONE': , 'TWO': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi index 70eae65..35badaa 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["ConsoleForegroundColor", "Magenta", "accepts_ambiguous_enum"] class ConsoleForegroundColor: @@ -13,10 +15,12 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Magenta': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Magenta': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -32,6 +36,12 @@ class ConsoleForegroundColor: @property def value(self) -> int: ... -def accepts_ambiguous_enum(color: ConsoleForegroundColor = ...) -> None: ... +def accepts_ambiguous_enum( + color: ConsoleForegroundColor = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> None: ... -Magenta: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index e3f9e10..33c8e6b 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = [ "Blue", "ConsoleForegroundColor", @@ -29,22 +31,24 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Green: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") None_: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Yellow: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -64,8 +68,18 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor # value = -Green: ConsoleForegroundColor # value = -Magenta: ConsoleForegroundColor # value = -None_: ConsoleForegroundColor # value = -Yellow: ConsoleForegroundColor # value = +Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) 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 04f104f..752f2ea 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 @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = [ "Enum", "Unbound", @@ -18,8 +20,32 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: typing.Annotated[typing.Any, ...]) -> int: ... -def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... -def accept_unbound_type(arg0: tuple[typing.Annotated[typing.Any, ...], int]) -> int: ... -def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> typing.Annotated[typing.Any, ...]: ... +def accept_unbound_enum( + arg0: typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Enum"), + ] +) -> int: ... +def accept_unbound_enum_defaulted( + x: Enum = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> int: ... +def accept_unbound_type( + arg0: tuple[ + typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), + ], + int, + ] +) -> int: ... +def accept_unbound_type_defaulted( + x: Unbound = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> int: ... +def get_unbound_type() -> typing.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), +]: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi index 09af4e4..029d664 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -21,4 +23,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any # value = +_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi index eb4a85a..b049f81 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -3,6 +3,7 @@ from __future__ import annotations import datetime import numpy +import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -27,10 +28,14 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list # value = [, ] -foovar: Foo # value = +foolist: list = pybind11_stubgen.typing_ext.ValueExpr( + "[, ]" +) +foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) list_with_none: list = [None, 2, {}] none = None -t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) -t_20ns: datetime.timedelta # value = datetime.timedelta(0) -t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) +t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) +t_20ns: datetime.timedelta = datetime.timedelta(0) +t_30s: datetime.timedelta = datetime.timedelta(seconds=30) diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi index a6c7165..320ddc7 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi @@ -3,6 +3,8 @@ from __future__ import annotations import sys as sys import typing as typing +import pybind11_stubgen.typing_ext + from demo.pure_python.functions_3_8_plus import args_mix from demo.pure_python.functions_3_9_plus import generic_alias_annotation @@ -24,8 +26,12 @@ class _Dummy: def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... -def builtin_function_as_default_arg(func: type(len) = len): ... -def function_as_default_arg(func: type(search) = search): ... +def builtin_function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(len)") = len, +): ... +def function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(search)") = search, +): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi index dd9ffdc..3361a12 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi @@ -11,5 +11,5 @@ def args_mix( *args: int, x: int = 1, y=int, - **kwargs: typing.Dict[int, str], + **kwargs: dict[int, str], ): ... diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi index efb53a7..bd39444 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -1,6 +1,10 @@ from __future__ import annotations +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo # value = +value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi index 24968c9..1148e68 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["Bar1"] @@ -9,4 +11,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index 4a3b7bd..8e23a2a 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -34,11 +36,17 @@ class Outer: TWO """ - ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = - TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = + ONE: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") + TWO: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] # value = {'ONE': , 'TWO': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'ONE': , 'TWO': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi index 70eae65..35badaa 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["ConsoleForegroundColor", "Magenta", "accepts_ambiguous_enum"] class ConsoleForegroundColor: @@ -13,10 +15,12 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Magenta': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Magenta': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -32,6 +36,12 @@ class ConsoleForegroundColor: @property def value(self) -> int: ... -def accepts_ambiguous_enum(color: ConsoleForegroundColor = ...) -> None: ... +def accepts_ambiguous_enum( + color: ConsoleForegroundColor = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> None: ... -Magenta: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index e3f9e10..33c8e6b 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = [ "Blue", "ConsoleForegroundColor", @@ -29,22 +31,24 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Green: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") None_: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Yellow: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -64,8 +68,18 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor # value = -Green: ConsoleForegroundColor # value = -Magenta: ConsoleForegroundColor # value = -None_: ConsoleForegroundColor # value = -Yellow: ConsoleForegroundColor # value = +Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index f61b9ca..b0cc0b8 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -2,6 +2,7 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext import typing_extensions __all__ = [ @@ -20,10 +21,32 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: typing_extensions.Annotated[typing.Any, ...]) -> int: ... -def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... +def accept_unbound_enum( + arg0: typing_extensions.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Enum"), + ] +) -> int: ... +def accept_unbound_enum_defaulted( + x: Enum = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> int: ... def accept_unbound_type( - arg0: tuple[typing_extensions.Annotated[typing.Any, ...], int] + arg0: tuple[ + typing_extensions.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), + ], + int, + ] +) -> int: ... +def accept_unbound_type_defaulted( + x: Unbound = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), ) -> int: ... -def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> typing_extensions.Annotated[typing.Any, ...]: ... +def get_unbound_type() -> typing_extensions.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), +]: ... diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi index 09af4e4..029d664 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -21,4 +23,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any # value = +_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi index eb4a85a..b049f81 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -3,6 +3,7 @@ from __future__ import annotations import datetime import numpy +import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -27,10 +28,14 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list # value = [, ] -foovar: Foo # value = +foolist: list = pybind11_stubgen.typing_ext.ValueExpr( + "[, ]" +) +foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) list_with_none: list = [None, 2, {}] none = None -t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) -t_20ns: datetime.timedelta # value = datetime.timedelta(0) -t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) +t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) +t_20ns: datetime.timedelta = datetime.timedelta(0) +t_30s: datetime.timedelta = datetime.timedelta(seconds=30) diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi index ec036d0..b230b1d 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi @@ -3,6 +3,8 @@ from __future__ import annotations import sys as sys import typing as typing +import pybind11_stubgen.typing_ext + __all__ = [ "accept_frozenset", "builtin_function_as_default_arg", @@ -19,8 +21,12 @@ class _Dummy: def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... -def builtin_function_as_default_arg(func: type(len) = len): ... -def function_as_default_arg(func: type(search) = search): ... +def builtin_function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(len)") = len, +): ... +def function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(search)") = search, +): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi index efb53a7..bd39444 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -1,6 +1,10 @@ from __future__ import annotations +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo # value = +value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi index 24968c9..1148e68 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + import demo._bindings.classes __all__ = ["Bar1"] @@ -9,4 +11,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index 4a3b7bd..8e23a2a 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -34,11 +36,17 @@ class Outer: TWO """ - ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = - TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = + ONE: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") + TWO: typing.ClassVar[ + Outer.Inner.NestedEnum + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] # value = {'ONE': , 'TWO': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'ONE': , 'TWO': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi index 70eae65..35badaa 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["ConsoleForegroundColor", "Magenta", "accepts_ambiguous_enum"] class ConsoleForegroundColor: @@ -13,10 +15,12 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Magenta': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Magenta': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -32,6 +36,12 @@ class ConsoleForegroundColor: @property def value(self) -> int: ... -def accepts_ambiguous_enum(color: ConsoleForegroundColor = ...) -> None: ... +def accepts_ambiguous_enum( + color: ConsoleForegroundColor = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> None: ... -Magenta: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index e3f9e10..33c8e6b 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = [ "Blue", "ConsoleForegroundColor", @@ -29,22 +31,24 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Green: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Magenta: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") None_: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") Yellow: typing.ClassVar[ ConsoleForegroundColor - ] # value = + ] = pybind11_stubgen.typing_ext.ValueExpr("") __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } + ] = pybind11_stubgen.typing_ext.ValueExpr( + "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" + ) def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -64,8 +68,18 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor # value = -Green: ConsoleForegroundColor # value = -Magenta: ConsoleForegroundColor # value = -None_: ConsoleForegroundColor # value = -Yellow: ConsoleForegroundColor # value = +Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) +Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( + "" +) diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi index f61b9ca..b0cc0b8 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/flawed_bindings.pyi @@ -2,6 +2,7 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext import typing_extensions __all__ = [ @@ -20,10 +21,32 @@ class Enum: class Unbound: pass -def accept_unbound_enum(arg0: typing_extensions.Annotated[typing.Any, ...]) -> int: ... -def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... +def accept_unbound_enum( + arg0: typing_extensions.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Enum"), + ] +) -> int: ... +def accept_unbound_enum_defaulted( + x: Enum = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), +) -> int: ... def accept_unbound_type( - arg0: tuple[typing_extensions.Annotated[typing.Any, ...], int] + arg0: tuple[ + typing_extensions.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), + ], + int, + ] +) -> int: ... +def accept_unbound_type_defaulted( + x: Unbound = pybind11_stubgen.typing_ext.InvalidExpr( + "" + ), ) -> int: ... -def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... -def get_unbound_type() -> typing_extensions.Annotated[typing.Any, ...]: ... +def get_unbound_type() -> typing_extensions.Annotated[ + typing.Any, + pybind11_stubgen.typing_ext.InvalidExpr("(anonymous namespace)::Unbound"), +]: ... diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi index 09af4e4..029d664 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing +import pybind11_stubgen.typing_ext + __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -21,4 +23,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any # value = +_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi index eb4a85a..b049f81 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -3,6 +3,7 @@ from __future__ import annotations import datetime import numpy +import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -27,10 +28,14 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list # value = [, ] -foovar: Foo # value = +foolist: list = pybind11_stubgen.typing_ext.ValueExpr( + "[, ]" +) +foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( + "" +) list_with_none: list = [None, 2, {}] none = None -t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) -t_20ns: datetime.timedelta # value = datetime.timedelta(0) -t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) +t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) +t_20ns: datetime.timedelta = datetime.timedelta(0) +t_30s: datetime.timedelta = datetime.timedelta(seconds=30) diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi index 934f822..40a66e9 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions.pyi @@ -3,6 +3,8 @@ from __future__ import annotations import sys as sys import typing as typing +import pybind11_stubgen.typing_ext + from demo.pure_python.functions_3_8_plus import args_mix __all__ = [ @@ -22,8 +24,12 @@ class _Dummy: def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... -def builtin_function_as_default_arg(func: type(len) = len): ... -def function_as_default_arg(func: type(search) = search): ... +def builtin_function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(len)") = len, +): ... +def function_as_default_arg( + func: pybind11_stubgen.typing_ext.ValueExpr("type(search)") = search, +): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi index dd9ffdc..4b91799 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/pure_python/functions_3_8_plus.pyi @@ -2,6 +2,8 @@ from __future__ import annotations import typing as typing +import pybind11_stubgen.typing_ext + __all__ = ["args_mix", "typing"] def args_mix( @@ -11,5 +13,5 @@ def args_mix( *args: int, x: int = 1, y=int, - **kwargs: typing.Dict[int, str], + **kwargs: pybind11_stubgen.typing_ext.ValueExpr("typing.Dict[int, str]"), ): ... From 37f93a596103a4e41f8dcade19b4373f4f42f0df Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sun, 26 Nov 2023 01:48:42 +0900 Subject: [PATCH 14/15] revert: Use comments instead of Value expression when possible --- pybind11_stubgen/printer.py | 6 +++- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +--- .../aliases/foreign_class_member.pyi | 4 +-- .../demo/_bindings/classes.pyi | 14 ++------ .../demo/_bindings/duplicate_enum.pyi | 10 ++---- .../demo/_bindings/enum.pyi | 36 ++++++------------- .../demo/_bindings/issues.pyi | 4 +-- .../demo/_bindings/values.pyi | 9 ++--- 8 files changed, 27 insertions(+), 62 deletions(-) diff --git a/pybind11_stubgen/printer.py b/pybind11_stubgen/printer.py index 13a24c6..d45501e 100644 --- a/pybind11_stubgen/printer.py +++ b/pybind11_stubgen/printer.py @@ -45,7 +45,11 @@ def print_attribute(self, attr: Attribute) -> list[str]: parts.append(f": {self.print_annotation(attr.annotation)}") if attr.value is not None: - parts.append(f" = {self.print_value(attr.value)}") + if attr.value.is_print_safe or attr.annotation is None: + parts.append(f" = {self.print_value(attr.value)}") + else: + repr_first_line = attr.value.repr.split("\n", 1)[0] + parts.append(f" # value = {repr_first_line}") return ["".join(parts)] diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi index bd39444..efb53a7 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -1,10 +1,6 @@ from __future__ import annotations -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +value: demo._bindings.classes.Foo # value = diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi index 1148e68..24968c9 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["Bar1"] @@ -11,4 +9,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index 8e23a2a..4a3b7bd 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -36,17 +34,11 @@ class Outer: TWO """ - ONE: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") - TWO: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = + TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'ONE': , 'TWO': }" - ) + ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi index 35badaa..3665a7e 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi @@ -15,12 +15,10 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Magenta': }" - ) + ] # value = {'Magenta': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -42,6 +40,4 @@ def accepts_ambiguous_enum( ), ) -> None: ... -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Magenta: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index 33c8e6b..e3f9e10 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = [ "Blue", "ConsoleForegroundColor", @@ -31,24 +29,22 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Green: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = None_: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" - ) + ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -68,18 +64,8 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Blue: ConsoleForegroundColor # value = +Green: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor # value = +None_: ConsoleForegroundColor # value = +Yellow: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi index 029d664..09af4e4 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -23,4 +21,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") +_cleanup: typing.Any # value = diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi index b049f81..1c01295 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -3,7 +3,6 @@ from __future__ import annotations import datetime import numpy -import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -28,12 +27,8 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list = pybind11_stubgen.typing_ext.ValueExpr( - "[, ]" -) -foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +foolist: list # value = [, ] +foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) From 9d2e90fcde788887f4282444069cfd94c6d23074 Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sun, 26 Nov 2023 01:53:23 +0900 Subject: [PATCH 15/15] chore: Update stubs --- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +--- .../aliases/foreign_class_member.pyi | 4 +-- .../demo/_bindings/classes.pyi | 14 ++------ .../demo/_bindings/duplicate_enum.pyi | 10 ++---- .../demo/_bindings/enum.pyi | 36 ++++++------------- .../demo/_bindings/issues.pyi | 4 +-- .../demo/_bindings/values.pyi | 9 ++--- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +--- .../aliases/foreign_class_member.pyi | 4 +-- .../demo/_bindings/classes.pyi | 14 ++------ .../demo/_bindings/duplicate_enum.pyi | 10 ++---- .../demo/_bindings/enum.pyi | 36 ++++++------------- .../demo/_bindings/issues.pyi | 4 +-- .../demo/_bindings/values.pyi | 9 ++--- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +--- .../aliases/foreign_class_member.pyi | 4 +-- .../demo/_bindings/classes.pyi | 14 ++------ .../demo/_bindings/duplicate_enum.pyi | 10 ++---- .../demo/_bindings/enum.pyi | 36 ++++++------------- .../demo/_bindings/issues.pyi | 4 +-- .../demo/_bindings/values.pyi | 9 ++--- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +--- .../aliases/foreign_class_member.pyi | 4 +-- .../demo/_bindings/classes.pyi | 14 ++------ .../demo/_bindings/duplicate_enum.pyi | 10 ++---- .../demo/_bindings/enum.pyi | 36 ++++++------------- .../demo/_bindings/issues.pyi | 4 +-- .../demo/_bindings/values.pyi | 9 ++--- .../demo/_bindings/aliases/foreign_attr.pyi | 6 +--- .../aliases/foreign_class_member.pyi | 4 +-- .../demo/_bindings/classes.pyi | 14 ++------ .../demo/_bindings/duplicate_enum.pyi | 10 ++---- .../demo/_bindings/enum.pyi | 36 ++++++------------- .../demo/_bindings/issues.pyi | 4 +-- .../demo/_bindings/values.pyi | 9 ++--- 35 files changed, 110 insertions(+), 305 deletions(-) diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_attr.pyi index bd39444..efb53a7 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_attr.pyi @@ -1,10 +1,6 @@ from __future__ import annotations -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +value: demo._bindings.classes.Foo # value = diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_class_member.pyi index 1148e68..24968c9 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["Bar1"] @@ -11,4 +9,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/classes.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/classes.pyi index 8e23a2a..4a3b7bd 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/classes.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -36,17 +34,11 @@ class Outer: TWO """ - ONE: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") - TWO: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = + TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'ONE': , 'TWO': }" - ) + ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/duplicate_enum.pyi index 35badaa..3665a7e 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/duplicate_enum.pyi @@ -15,12 +15,10 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Magenta': }" - ) + ] # value = {'Magenta': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -42,6 +40,4 @@ def accepts_ambiguous_enum( ), ) -> None: ... -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Magenta: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/enum.pyi index 33c8e6b..e3f9e10 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/enum.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = [ "Blue", "ConsoleForegroundColor", @@ -31,24 +29,22 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Green: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = None_: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" - ) + ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -68,18 +64,8 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Blue: ConsoleForegroundColor # value = +Green: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor # value = +None_: ConsoleForegroundColor # value = +Yellow: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/issues.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/issues.pyi index 029d664..09af4e4 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/issues.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -23,4 +21,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") +_cleanup: typing.Any # value = diff --git a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/values.pyi b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/values.pyi index b049f81..1c01295 100644 --- a/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.12/pybind11-master/numpy-array-use-type-var/demo/_bindings/values.pyi @@ -3,7 +3,6 @@ from __future__ import annotations import datetime import numpy -import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -28,12 +27,8 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list = pybind11_stubgen.typing_ext.ValueExpr( - "[, ]" -) -foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +foolist: list # value = [, ] +foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi index bd39444..efb53a7 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -1,10 +1,6 @@ from __future__ import annotations -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +value: demo._bindings.classes.Foo # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi index 1148e68..24968c9 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["Bar1"] @@ -11,4 +9,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = 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 8e23a2a..4a3b7bd 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,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -36,17 +34,11 @@ class Outer: TWO """ - ONE: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") - TWO: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = + TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'ONE': , 'TWO': }" - ) + ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi index 35badaa..3665a7e 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi @@ -15,12 +15,10 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Magenta': }" - ) + ] # value = {'Magenta': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -42,6 +40,4 @@ def accepts_ambiguous_enum( ), ) -> None: ... -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Magenta: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index 33c8e6b..e3f9e10 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = [ "Blue", "ConsoleForegroundColor", @@ -31,24 +29,22 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Green: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = None_: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" - ) + ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -68,18 +64,8 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Blue: ConsoleForegroundColor # value = +Green: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor # value = +None_: ConsoleForegroundColor # value = +Yellow: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi index 029d664..09af4e4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -23,4 +21,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") +_cleanup: typing.Any # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi index b049f81..1c01295 100644 --- a/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -3,7 +3,6 @@ from __future__ import annotations import datetime import numpy -import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -28,12 +27,8 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list = pybind11_stubgen.typing_ext.ValueExpr( - "[, ]" -) -foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +foolist: list # value = [, ] +foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi index bd39444..efb53a7 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -1,10 +1,6 @@ from __future__ import annotations -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +value: demo._bindings.classes.Foo # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi index 1148e68..24968c9 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["Bar1"] @@ -11,4 +9,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = 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 8e23a2a..4a3b7bd 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,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -36,17 +34,11 @@ class Outer: TWO """ - ONE: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") - TWO: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = + TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'ONE': , 'TWO': }" - ) + ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi index 35badaa..3665a7e 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi @@ -15,12 +15,10 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Magenta': }" - ) + ] # value = {'Magenta': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -42,6 +40,4 @@ def accepts_ambiguous_enum( ), ) -> None: ... -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Magenta: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index 33c8e6b..e3f9e10 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = [ "Blue", "ConsoleForegroundColor", @@ -31,24 +29,22 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Green: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = None_: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" - ) + ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -68,18 +64,8 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Blue: ConsoleForegroundColor # value = +Green: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor # value = +None_: ConsoleForegroundColor # value = +Yellow: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi index 029d664..09af4e4 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -23,4 +21,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") +_cleanup: typing.Any # value = diff --git a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi index b049f81..1c01295 100644 --- a/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -3,7 +3,6 @@ from __future__ import annotations import datetime import numpy -import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -28,12 +27,8 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list = pybind11_stubgen.typing_ext.ValueExpr( - "[, ]" -) -foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +foolist: list # value = [, ] +foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi index bd39444..efb53a7 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -1,10 +1,6 @@ from __future__ import annotations -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +value: demo._bindings.classes.Foo # value = diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi index 1148e68..24968c9 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["Bar1"] @@ -11,4 +9,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index 8e23a2a..4a3b7bd 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -36,17 +34,11 @@ class Outer: TWO """ - ONE: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") - TWO: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = + TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'ONE': , 'TWO': }" - ) + ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi index 35badaa..3665a7e 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi @@ -15,12 +15,10 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Magenta': }" - ) + ] # value = {'Magenta': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -42,6 +40,4 @@ def accepts_ambiguous_enum( ), ) -> None: ... -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Magenta: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index 33c8e6b..e3f9e10 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = [ "Blue", "ConsoleForegroundColor", @@ -31,24 +29,22 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Green: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = None_: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" - ) + ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -68,18 +64,8 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Blue: ConsoleForegroundColor # value = +Green: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor # value = +None_: ConsoleForegroundColor # value = +Yellow: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi index 029d664..09af4e4 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -23,4 +21,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") +_cleanup: typing.Any # value = diff --git a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi index b049f81..1c01295 100644 --- a/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.7/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -3,7 +3,6 @@ from __future__ import annotations import datetime import numpy -import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -28,12 +27,8 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list = pybind11_stubgen.typing_ext.ValueExpr( - "[, ]" -) -foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +foolist: list # value = [, ] +foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000) diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi index bd39444..efb53a7 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_attr.pyi @@ -1,10 +1,6 @@ from __future__ import annotations -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["value"] -value: demo._bindings.classes.Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +value: demo._bindings.classes.Foo # value = diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi index 1148e68..24968c9 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/aliases/foreign_class_member.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - import demo._bindings.classes __all__ = ["Bar1"] @@ -11,4 +9,4 @@ __all__ = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi index 8e23a2a..4a3b7bd 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/classes.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: @@ -36,17 +34,11 @@ class Outer: TWO """ - ONE: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") - TWO: typing.ClassVar[ - Outer.Inner.NestedEnum - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = + TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'ONE': , 'TWO': }" - ) + ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi index 35badaa..3665a7e 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/duplicate_enum.pyi @@ -15,12 +15,10 @@ class ConsoleForegroundColor: Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Magenta': }" - ) + ] # value = {'Magenta': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -42,6 +40,4 @@ def accepts_ambiguous_enum( ), ) -> None: ... -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Magenta: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi index 33c8e6b..e3f9e10 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/enum.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = [ "Blue", "ConsoleForegroundColor", @@ -31,24 +29,22 @@ class ConsoleForegroundColor: Blue: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Green: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = None_: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor - ] = pybind11_stubgen.typing_ext.ValueExpr("") + ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] - ] = pybind11_stubgen.typing_ext.ValueExpr( - "{'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': }" - ) + ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... @@ -68,18 +64,8 @@ def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... -Blue: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Green: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Magenta: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -None_: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) -Yellow: ConsoleForegroundColor = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +Blue: ConsoleForegroundColor # value = +Green: ConsoleForegroundColor # value = +Magenta: ConsoleForegroundColor # value = +None_: ConsoleForegroundColor # value = +Yellow: ConsoleForegroundColor # value = diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi index 029d664..09af4e4 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/issues.pyi @@ -2,8 +2,6 @@ from __future__ import annotations import typing -import pybind11_stubgen.typing_ext - __all__ = ["issue_51_catastrophic_regex", "issue_73_utf8_doc_chars"] def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: @@ -23,4 +21,4 @@ def issue_73_utf8_doc_chars() -> None: values provide more damping in response. """ -_cleanup: typing.Any = pybind11_stubgen.typing_ext.ValueExpr("") +_cleanup: typing.Any # value = diff --git a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi index b049f81..1c01295 100644 --- a/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi +++ b/tests/stubs/python-3.8/pybind11-master/numpy-array-wrap-with-annotated/demo/_bindings/values.pyi @@ -3,7 +3,6 @@ from __future__ import annotations import datetime import numpy -import pybind11_stubgen.typing_ext from numpy import random __all__ = [ @@ -28,12 +27,8 @@ class Foo: def add_day(arg0: datetime.datetime) -> datetime.datetime: ... -foolist: list = pybind11_stubgen.typing_ext.ValueExpr( - "[, ]" -) -foovar: Foo = pybind11_stubgen.typing_ext.ValueExpr( - "" -) +foolist: list # value = [, ] +foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta = datetime.timedelta(microseconds=10000)