From 7a0ee64f187f8ab92df4be5d21cc35f7068bfc22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Mon, 24 Jan 2022 15:53:38 +0100 Subject: [PATCH 01/18] feat(python): support inheritance-based interface implementation The code generator used to represent jsii interfaces as python `Protocols`, however this mechanism is normally intended to allow structural typing in python. Python `Protocol` types are declared using a custom metaclass, which makes them tricky to inherit from without running into metaclass conflicts (especially in cases where multiple inheritance involving a `Protocol` and a non-`Protocol` base class). The jsii runtime does not perform structural typing, and hence interfaces are better modelled as abstract base classes that only declare abstract members. This, together with a minor modification to the `@jsii.interface` decorator, allows interfaces to be "implemented" by simply adding them to the implementor's inheritance chain, as is "natural" to do in Python in such cases. The "legacy" `@jsii.implements` approach to implementing interfaces is no longer recommended, however it is still supported as it is necessary when dealing with libraries generated by older versions of `jsii-pacmak`. --- .../lib-user/language-specific/python.md | 53 ++-- .../@jsii/python-runtime/src/jsii/_runtime.py | 5 +- .../python-runtime/tests/test_compliance.py | 31 +++ packages/jsii-pacmak/lib/targets/python.ts | 16 +- .../__snapshots__/target-python.test.ts.snap | 253 ++++++++++++------ 5 files changed, 237 insertions(+), 121 deletions(-) diff --git a/gh-pages/content/user-guides/lib-user/language-specific/python.md b/gh-pages/content/user-guides/lib-user/language-specific/python.md index 059fd59478..a8a82a3e32 100644 --- a/gh-pages/content/user-guides/lib-user/language-specific/python.md +++ b/gh-pages/content/user-guides/lib-user/language-specific/python.md @@ -16,38 +16,18 @@ Traditionally, **Python** developers expect to be able to either *implicitly* im required members, or *explicitly* implement interfaces by simply adding the interface to their class' or interface's inheritance chain (and implementing all required members): -!!! bug "Incorrect Use" - - ```py hl_lines="3" - from jsii_dependency import IJsiiInterface - - class MyNewClass(IJsiiInterface): - """ Traditional implementation of an interface in Python. - - This will not work with interfaces defined by jsii modules, as this will - likely cause a metaclass conflict that the user cannot solve. - """ - - # Member implementations... - - ... - ``` - The [jsii type system][jsii-type-system] however does not support *structural typing*, and interfaces must **always** be *explicitly* implemented. In order to correctly declare implementation of an interface from a *jsii module*, the following syntax is used: -```py hl_lines="1 4" -import jsii +```py hl_lines="3" from jsii_dependency import IJsiiInterface -@jsii.implements(IJsiiInterface) -class MyNewClass(): - """ A jsii-supported implementation of the `IJsiiInterface` interface +class MyNewClass(IJsiiInterface): + """ Traditional implementation of an interface in Python. - This will correctly register the explicit interface implementation on the - type's metadata, and ensure instances get correctly serialized to and from - the jsii kernel. + This will not work with interfaces defined by jsii modules, as this will + likely cause a metaclass conflict that the user cannot solve. """ # Member implementations... @@ -55,6 +35,29 @@ class MyNewClass(): ... ``` +!!! info Legacy Style + When using libraries generated by `jsii-pacmak` version `1.52.1` and earlier, using the inheritance chain style + above may result in metaclass conflicts when performing multiple inheritance. In such cases, the implementation can + be performed using the `@jsii.implements` decorator instead. + + ```py hl_lines="1 4" + import jsii + from jsii_dependency import IJsiiInterface + + @jsii.implements(IJsiiInterface) + class MyNewClass(): + """ A jsii-supported implementation of the `IJsiiInterface` interface + + This will correctly register the explicit interface implementation on the + type's metadata, and ensure instances get correctly serialized to and from + the jsii kernel. + """ + + # Member implementations... + + ... + ``` + [jsii-type-system]: ../../../specification/2-type-system.md ## Property Overrides diff --git a/packages/@jsii/python-runtime/src/jsii/_runtime.py b/packages/@jsii/python-runtime/src/jsii/_runtime.py index 3ebbf99df3..8f69b75f1a 100644 --- a/packages/@jsii/python-runtime/src/jsii/_runtime.py +++ b/packages/@jsii/python-runtime/src/jsii/_runtime.py @@ -3,13 +3,12 @@ import attr -from typing import cast, Any, Callable, ClassVar, List, Optional, Mapping, Type, TypeVar +from typing import cast, Any, Callable, List, Optional, Mapping, Type, TypeVar from . import _reference_map from ._compat import importlib_resources from ._kernel import Kernel from .python import _ClassPropertyMeta -from ._kernel.types import ObjRef # Yea, a global here is kind of gross, however, there's not really a better way of @@ -144,6 +143,8 @@ def deco(cls): def interface(*, jsii_type: str) -> Callable[[T], T]: def deco(iface): iface.__jsii_type__ = jsii_type + # This interface "implements itself" - this is a trick to ease up implementation discovery. + iface.__jsii_ifaces__ = [iface] _reference_map.register_interface(iface) return iface diff --git a/packages/@jsii/python-runtime/tests/test_compliance.py b/packages/@jsii/python-runtime/tests/test_compliance.py index 28f2ddf590..f249b13010 100644 --- a/packages/@jsii/python-runtime/tests/test_compliance.py +++ b/packages/@jsii/python-runtime/tests/test_compliance.py @@ -169,6 +169,19 @@ def next(self): return next_ +class SubclassNativeFriendlyRandom_Inheritance(Number, IFriendly, IRandomNumberGenerator): + def __init__(self): + super().__init__(908) + self.next_number = 100 + + def hello(self): + return "SubclassNativeFriendlyRandom" + + def next(self): + next_ = self.next_number + self.next_number += 100 + return next_ + @jsii.implements(IFriendlyRandomGenerator) class PureNativeFriendlyRandom: """ @@ -753,6 +766,10 @@ def test_testInterfaces(): poly.say_hello(SubclassNativeFriendlyRandom()) == "oh, SubclassNativeFriendlyRandom" ) + assert ( + poly.say_hello(SubclassNativeFriendlyRandom_Inheritance()) + == "oh, SubclassNativeFriendlyRandom" + ) assert poly.say_hello(PureNativeFriendlyRandom()) == "oh, I am a native!" @@ -777,6 +794,20 @@ def test_testNativeObjectsWithInterfaces(): assert generator_bound_to_pure_native.next_times100() == 100_000 assert generator_bound_to_pure_native.next_times100() == 200_000 + ### + # One more time, but this time implementing the interface via "classic" inheritance. + ### + subclassed_native = SubclassNativeFriendlyRandom_Inheritance() + generator_bound_to_p_subclassed_object = NumberGenerator(subclassed_native) + + assert generator_bound_to_p_subclassed_object.generator is subclassed_native + generator_bound_to_p_subclassed_object.is_same_generator(subclassed_native) + assert generator_bound_to_p_subclassed_object.next_times100() == 10000 + + # When we invoke nextTimes100 again, it will use the objref and call into the same + # object. + assert generator_bound_to_p_subclassed_object.next_times100() == 20000 + def test_testLiteralInterface(): obj = JSObjectLiteralForInterface() diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 6410ad8ed1..1110272c7f 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -508,10 +508,8 @@ abstract class BaseMethod implements PythonBase { public emit( code: CodeMaker, context: EmitContext, - opts?: BaseMethodEmitOpts, + { renderAbstract = true, forceEmitBody = false }: BaseMethodEmitOpts = {}, ) { - const { renderAbstract = true, forceEmitBody = false } = opts ?? {}; - const returnType: string = toTypeName(this.returns).pythonType(context); // We cannot (currently?) blindly use the names given to us by the JSII for @@ -874,9 +872,8 @@ abstract class BaseProperty implements PythonBase { public emit( code: CodeMaker, context: EmitContext, - opts?: BasePropertyEmitOpts, + { renderAbstract = true, forceEmitBody = false }: BasePropertyEmitOpts = {}, ) { - const { renderAbstract = true, forceEmitBody = false } = opts ?? {}; const pythonType = toTypeName(this.type).pythonType(context); // "# type: ignore[misc]" is needed because mypy cannot check decorated things @@ -973,7 +970,7 @@ class Interface extends BasePythonClassType { if (this.separateMembers) { code.line(); } - member.emit(code, context, { forceEmitBody: true }); + member.emit(code, context, { forceEmitBody: true, renderAbstract: false }); } } else { code.line('pass'); @@ -998,7 +995,8 @@ class Interface extends BasePythonClassType { toTypeName(b).pythonType({ ...context, typeAnnotation: false }), ); - params.push('typing_extensions.Protocol'); + // Interfaces are kind of like abstract classes. We type them the same way. + params.push('metaclass = jsii.JSIIAbstractClass'); return params; } @@ -1009,12 +1007,16 @@ class Interface extends BasePythonClassType { } class InterfaceMethod extends BaseMethod { + // Interface members are always abstract + public readonly abstract = true; protected readonly implicitParameter: string = 'self'; protected readonly jsiiMethod: string = 'invoke'; protected readonly shouldEmitBody: boolean = false; } class InterfaceProperty extends BaseProperty { + // Interface members are always abstract + public readonly abstract = true; protected readonly decorator: string = 'builtins.property'; protected readonly implicitParameter: string = 'self'; protected readonly jsiiGetMethod: string = 'get'; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index f618f261c7..7f3802b24f 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -399,9 +399,10 @@ class BaseProps(scope.jsii_calc_base_of_base.VeryBaseProps): @jsii.interface(jsii_type="@scope/jsii-calc-base.IBaseInterface") class IBaseInterface( scope.jsii_calc_base_of_base.IVeryBaseInterface, - typing_extensions.Protocol, + metaclass = jsii.JSIIAbstractClass, ): - @jsii.member(jsii_name="bar") + @jsii.member(jsii_name="bar") # type: ignore[misc] + @abc.abstractmethod def bar(self) -> None: ... @@ -808,8 +809,9 @@ from ._jsii import * @jsii.interface(jsii_type="@scope/jsii-calc-base-of-base.IVeryBaseInterface") -class IVeryBaseInterface(typing_extensions.Protocol): - @jsii.member(jsii_name="foo") +class IVeryBaseInterface(metaclass = jsii.JSIIAbstractClass): + @jsii.member(jsii_name="foo") # type: ignore[misc] + @abc.abstractmethod def foo(self) -> None: ... @@ -1423,7 +1425,7 @@ class EnumFromScopedModule(enum.Enum): @jsii.interface(jsii_type="@scope/jsii-calc-lib.IDoublable") -class IDoublable(typing_extensions.Protocol): +class IDoublable(metaclass = jsii.JSIIAbstractClass): '''(deprecated) The general contract for a concrete number. :stability: deprecated @@ -1431,6 +1433,7 @@ class IDoublable(typing_extensions.Protocol): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="doubleValue") + @abc.abstractmethod def double_value(self) -> jsii.Number: ''' :stability: deprecated @@ -1459,7 +1462,7 @@ typing.cast(typing.Any, IDoublable).__jsii_proxy_class__ = lambda : _IDoublableP @jsii.interface(jsii_type="@scope/jsii-calc-lib.IFriendly") -class IFriendly(typing_extensions.Protocol): +class IFriendly(metaclass = jsii.JSIIAbstractClass): '''(deprecated) Applies to classes that are considered friendly. These classes can be greeted with @@ -1468,7 +1471,8 @@ class IFriendly(typing_extensions.Protocol): :stability: deprecated ''' - @jsii.member(jsii_name="hello") + @jsii.member(jsii_name="hello") # type: ignore[misc] + @abc.abstractmethod def hello(self) -> builtins.str: '''(deprecated) Say hello! @@ -1503,7 +1507,7 @@ typing.cast(typing.Any, IFriendly).__jsii_proxy_class__ = lambda : _IFriendlyPro @jsii.interface(jsii_type="@scope/jsii-calc-lib.IThreeLevelsInterface") class IThreeLevelsInterface( scope.jsii_calc_base.IBaseInterface, - typing_extensions.Protocol, + metaclass = jsii.JSIIAbstractClass, ): '''(deprecated) Interface that inherits from packages 2 levels up the tree. @@ -1513,7 +1517,8 @@ class IThreeLevelsInterface( :stability: deprecated ''' - @jsii.member(jsii_name="baz") + @jsii.member(jsii_name="baz") # type: ignore[misc] + @abc.abstractmethod def baz(self) -> None: ''' :stability: deprecated @@ -1882,13 +1887,14 @@ from .._jsii import * @jsii.interface(jsii_type="@scope/jsii-calc-lib.submodule.IReflectable") -class IReflectable(typing_extensions.Protocol): +class IReflectable(metaclass = jsii.JSIIAbstractClass): ''' :stability: deprecated ''' @builtins.property # type: ignore[misc] @jsii.member(jsii_name="entries") + @abc.abstractmethod def entries(self) -> typing.List["ReflectableEntry"]: ''' :stability: deprecated @@ -5226,14 +5232,16 @@ class GreetingAugmenter( @jsii.interface(jsii_type="jsii-calc.IAnonymousImplementationProvider") -class IAnonymousImplementationProvider(typing_extensions.Protocol): +class IAnonymousImplementationProvider(metaclass = jsii.JSIIAbstractClass): '''We can return an anonymous interface implementation from an override without losing the interface declarations.''' - @jsii.member(jsii_name="provideAsClass") + @jsii.member(jsii_name="provideAsClass") # type: ignore[misc] + @abc.abstractmethod def provide_as_class(self) -> "Implementation": ... - @jsii.member(jsii_name="provideAsInterface") + @jsii.member(jsii_name="provideAsInterface") # type: ignore[misc] + @abc.abstractmethod def provide_as_interface(self) -> "IAnonymouslyImplementMe": ... @@ -5256,13 +5264,15 @@ typing.cast(typing.Any, IAnonymousImplementationProvider).__jsii_proxy_class__ = @jsii.interface(jsii_type="jsii-calc.IAnonymouslyImplementMe") -class IAnonymouslyImplementMe(typing_extensions.Protocol): +class IAnonymouslyImplementMe(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="value") + @abc.abstractmethod def value(self) -> jsii.Number: ... - @jsii.member(jsii_name="verb") + @jsii.member(jsii_name="verb") # type: ignore[misc] + @abc.abstractmethod def verb(self) -> builtins.str: ... @@ -5284,13 +5294,15 @@ typing.cast(typing.Any, IAnonymouslyImplementMe).__jsii_proxy_class__ = lambda : @jsii.interface(jsii_type="jsii-calc.IAnotherPublicInterface") -class IAnotherPublicInterface(typing_extensions.Protocol): +class IAnotherPublicInterface(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="a") + @abc.abstractmethod def a(self) -> builtins.str: ... @a.setter + @abc.abstractmethod def a(self, value: builtins.str) -> None: ... @@ -5312,8 +5324,9 @@ typing.cast(typing.Any, IAnotherPublicInterface).__jsii_proxy_class__ = lambda : @jsii.interface(jsii_type="jsii-calc.IBell") -class IBell(typing_extensions.Protocol): - @jsii.member(jsii_name="ring") +class IBell(metaclass = jsii.JSIIAbstractClass): + @jsii.member(jsii_name="ring") # type: ignore[misc] + @abc.abstractmethod def ring(self) -> None: ... @@ -5330,10 +5343,11 @@ typing.cast(typing.Any, IBell).__jsii_proxy_class__ = lambda : _IBellProxy @jsii.interface(jsii_type="jsii-calc.IBellRinger") -class IBellRinger(typing_extensions.Protocol): +class IBellRinger(metaclass = jsii.JSIIAbstractClass): '''Takes the object parameter as an interface.''' - @jsii.member(jsii_name="yourTurn") + @jsii.member(jsii_name="yourTurn") # type: ignore[misc] + @abc.abstractmethod def your_turn(self, bell: IBell) -> None: ''' :param bell: - @@ -5358,10 +5372,11 @@ typing.cast(typing.Any, IBellRinger).__jsii_proxy_class__ = lambda : _IBellRinge @jsii.interface(jsii_type="jsii-calc.IConcreteBellRinger") -class IConcreteBellRinger(typing_extensions.Protocol): +class IConcreteBellRinger(metaclass = jsii.JSIIAbstractClass): '''Takes the object parameter as a calss.''' - @jsii.member(jsii_name="yourTurn") + @jsii.member(jsii_name="yourTurn") # type: ignore[misc] + @abc.abstractmethod def your_turn(self, bell: "Bell") -> None: ''' :param bell: - @@ -5386,7 +5401,7 @@ typing.cast(typing.Any, IConcreteBellRinger).__jsii_proxy_class__ = lambda : _IC @jsii.interface(jsii_type="jsii-calc.IDeprecatedInterface") -class IDeprecatedInterface(typing_extensions.Protocol): +class IDeprecatedInterface(metaclass = jsii.JSIIAbstractClass): ''' :deprecated: useless interface @@ -5395,6 +5410,7 @@ class IDeprecatedInterface(typing_extensions.Protocol): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="mutableProperty") + @abc.abstractmethod def mutable_property(self) -> typing.Optional[jsii.Number]: ''' :deprecated: could be better @@ -5404,10 +5420,12 @@ class IDeprecatedInterface(typing_extensions.Protocol): ... @mutable_property.setter + @abc.abstractmethod def mutable_property(self, value: typing.Optional[jsii.Number]) -> None: ... - @jsii.member(jsii_name="method") + @jsii.member(jsii_name="method") # type: ignore[misc] + @abc.abstractmethod def method(self) -> None: ''' :deprecated: services no purpose @@ -5454,13 +5472,14 @@ typing.cast(typing.Any, IDeprecatedInterface).__jsii_proxy_class__ = lambda : _I @jsii.interface(jsii_type="jsii-calc.IExperimentalInterface") -class IExperimentalInterface(typing_extensions.Protocol): +class IExperimentalInterface(metaclass = jsii.JSIIAbstractClass): ''' :stability: experimental ''' @builtins.property # type: ignore[misc] @jsii.member(jsii_name="mutableProperty") + @abc.abstractmethod def mutable_property(self) -> typing.Optional[jsii.Number]: ''' :stability: experimental @@ -5468,10 +5487,12 @@ class IExperimentalInterface(typing_extensions.Protocol): ... @mutable_property.setter + @abc.abstractmethod def mutable_property(self, value: typing.Optional[jsii.Number]) -> None: ... - @jsii.member(jsii_name="method") + @jsii.member(jsii_name="method") # type: ignore[misc] + @abc.abstractmethod def method(self) -> None: ''' :stability: experimental @@ -5510,18 +5531,21 @@ typing.cast(typing.Any, IExperimentalInterface).__jsii_proxy_class__ = lambda : @jsii.interface(jsii_type="jsii-calc.IExtendsPrivateInterface") -class IExtendsPrivateInterface(typing_extensions.Protocol): +class IExtendsPrivateInterface(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="moreThings") + @abc.abstractmethod def more_things(self) -> typing.List[builtins.str]: ... @builtins.property # type: ignore[misc] @jsii.member(jsii_name="private") + @abc.abstractmethod def private(self) -> builtins.str: ... @private.setter + @abc.abstractmethod def private(self, value: builtins.str) -> None: ... @@ -5548,13 +5572,14 @@ typing.cast(typing.Any, IExtendsPrivateInterface).__jsii_proxy_class__ = lambda @jsii.interface(jsii_type="jsii-calc.IExternalInterface") -class IExternalInterface(typing_extensions.Protocol): +class IExternalInterface(metaclass = jsii.JSIIAbstractClass): ''' :external: true ''' @builtins.property # type: ignore[misc] @jsii.member(jsii_name="mutableProperty") + @abc.abstractmethod def mutable_property(self) -> typing.Optional[jsii.Number]: ''' :external: true @@ -5562,10 +5587,12 @@ class IExternalInterface(typing_extensions.Protocol): ... @mutable_property.setter + @abc.abstractmethod def mutable_property(self, value: typing.Optional[jsii.Number]) -> None: ... - @jsii.member(jsii_name="method") + @jsii.member(jsii_name="method") # type: ignore[misc] + @abc.abstractmethod def method(self) -> None: ''' :external: true @@ -5604,15 +5631,17 @@ typing.cast(typing.Any, IExternalInterface).__jsii_proxy_class__ = lambda : _IEx @jsii.interface(jsii_type="jsii-calc.IFriendlier") -class IFriendlier(scope.jsii_calc_lib.IFriendly, typing_extensions.Protocol): +class IFriendlier(scope.jsii_calc_lib.IFriendly, metaclass = jsii.JSIIAbstractClass): '''Even friendlier classes can implement this interface.''' - @jsii.member(jsii_name="farewell") + @jsii.member(jsii_name="farewell") # type: ignore[misc] + @abc.abstractmethod def farewell(self) -> builtins.str: '''Say farewell.''' ... - @jsii.member(jsii_name="goodbye") + @jsii.member(jsii_name="goodbye") # type: ignore[misc] + @abc.abstractmethod def goodbye(self) -> builtins.str: '''Say goodbye. @@ -5646,11 +5675,12 @@ typing.cast(typing.Any, IFriendlier).__jsii_proxy_class__ = lambda : _IFriendlie @jsii.interface(jsii_type="jsii-calc.IInterfaceImplementedByAbstractClass") -class IInterfaceImplementedByAbstractClass(typing_extensions.Protocol): +class IInterfaceImplementedByAbstractClass(metaclass = jsii.JSIIAbstractClass): '''awslabs/jsii#220 Abstract return type.''' @builtins.property # type: ignore[misc] @jsii.member(jsii_name="propFromInterface") + @abc.abstractmethod def prop_from_interface(self) -> builtins.str: ... @@ -5670,8 +5700,9 @@ typing.cast(typing.Any, IInterfaceImplementedByAbstractClass).__jsii_proxy_class @jsii.interface(jsii_type="jsii-calc.IInterfaceWithInternal") -class IInterfaceWithInternal(typing_extensions.Protocol): - @jsii.member(jsii_name="visible") +class IInterfaceWithInternal(metaclass = jsii.JSIIAbstractClass): + @jsii.member(jsii_name="visible") # type: ignore[misc] + @abc.abstractmethod def visible(self) -> None: ... @@ -5688,13 +5719,15 @@ typing.cast(typing.Any, IInterfaceWithInternal).__jsii_proxy_class__ = lambda : @jsii.interface(jsii_type="jsii-calc.IInterfaceWithMethods") -class IInterfaceWithMethods(typing_extensions.Protocol): +class IInterfaceWithMethods(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="value") + @abc.abstractmethod def value(self) -> builtins.str: ... - @jsii.member(jsii_name="doThings") + @jsii.member(jsii_name="doThings") # type: ignore[misc] + @abc.abstractmethod def do_things(self) -> None: ... @@ -5716,10 +5749,11 @@ typing.cast(typing.Any, IInterfaceWithMethods).__jsii_proxy_class__ = lambda : _ @jsii.interface(jsii_type="jsii-calc.IInterfaceWithOptionalMethodArguments") -class IInterfaceWithOptionalMethodArguments(typing_extensions.Protocol): +class IInterfaceWithOptionalMethodArguments(metaclass = jsii.JSIIAbstractClass): '''awslabs/jsii#175 Interface proxies (and builders) do not respect optional arguments in methods.''' - @jsii.member(jsii_name="hello") + @jsii.member(jsii_name="hello") # type: ignore[misc] + @abc.abstractmethod def hello( self, arg1: builtins.str, @@ -5754,18 +5788,21 @@ typing.cast(typing.Any, IInterfaceWithOptionalMethodArguments).__jsii_proxy_clas @jsii.interface(jsii_type="jsii-calc.IInterfaceWithProperties") -class IInterfaceWithProperties(typing_extensions.Protocol): +class IInterfaceWithProperties(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="readOnlyString") + @abc.abstractmethod def read_only_string(self) -> builtins.str: ... @builtins.property # type: ignore[misc] @jsii.member(jsii_name="readWriteString") + @abc.abstractmethod def read_write_string(self) -> builtins.str: ... @read_write_string.setter + @abc.abstractmethod def read_write_string(self, value: builtins.str) -> None: ... @@ -5794,14 +5831,16 @@ typing.cast(typing.Any, IInterfaceWithProperties).__jsii_proxy_class__ = lambda @jsii.interface(jsii_type="jsii-calc.IInterfaceWithPropertiesExtension") class IInterfaceWithPropertiesExtension( IInterfaceWithProperties, - typing_extensions.Protocol, + metaclass = jsii.JSIIAbstractClass, ): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="foo") + @abc.abstractmethod def foo(self) -> jsii.Number: ... @foo.setter + @abc.abstractmethod def foo(self, value: jsii.Number) -> None: ... @@ -5825,13 +5864,15 @@ typing.cast(typing.Any, IInterfaceWithPropertiesExtension).__jsii_proxy_class__ @jsii.interface(jsii_type="jsii-calc.IJSII417PublicBaseOfBase") -class IJSII417PublicBaseOfBase(typing_extensions.Protocol): +class IJSII417PublicBaseOfBase(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="hasRoot") + @abc.abstractmethod def has_root(self) -> builtins.bool: ... - @jsii.member(jsii_name="foo") + @jsii.member(jsii_name="foo") # type: ignore[misc] + @abc.abstractmethod def foo(self) -> None: ... @@ -5853,7 +5894,7 @@ typing.cast(typing.Any, IJSII417PublicBaseOfBase).__jsii_proxy_class__ = lambda @jsii.interface(jsii_type="jsii-calc.IJsii487External") -class IJsii487External(typing_extensions.Protocol): +class IJsii487External(metaclass = jsii.JSIIAbstractClass): pass @@ -5866,7 +5907,7 @@ typing.cast(typing.Any, IJsii487External).__jsii_proxy_class__ = lambda : _IJsii @jsii.interface(jsii_type="jsii-calc.IJsii487External2") -class IJsii487External2(typing_extensions.Protocol): +class IJsii487External2(metaclass = jsii.JSIIAbstractClass): pass @@ -5879,7 +5920,7 @@ typing.cast(typing.Any, IJsii487External2).__jsii_proxy_class__ = lambda : _IJsi @jsii.interface(jsii_type="jsii-calc.IJsii496") -class IJsii496(typing_extensions.Protocol): +class IJsii496(metaclass = jsii.JSIIAbstractClass): pass @@ -5892,13 +5933,15 @@ typing.cast(typing.Any, IJsii496).__jsii_proxy_class__ = lambda : _IJsii496Proxy @jsii.interface(jsii_type="jsii-calc.IMutableObjectLiteral") -class IMutableObjectLiteral(typing_extensions.Protocol): +class IMutableObjectLiteral(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="value") + @abc.abstractmethod def value(self) -> builtins.str: ... @value.setter + @abc.abstractmethod def value(self, value: builtins.str) -> None: ... @@ -5920,22 +5963,29 @@ typing.cast(typing.Any, IMutableObjectLiteral).__jsii_proxy_class__ = lambda : _ @jsii.interface(jsii_type="jsii-calc.INonInternalInterface") -class INonInternalInterface(IAnotherPublicInterface, typing_extensions.Protocol): +class INonInternalInterface( + IAnotherPublicInterface, + metaclass = jsii.JSIIAbstractClass, +): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="b") + @abc.abstractmethod def b(self) -> builtins.str: ... @b.setter + @abc.abstractmethod def b(self, value: builtins.str) -> None: ... @builtins.property # type: ignore[misc] @jsii.member(jsii_name="c") + @abc.abstractmethod def c(self) -> builtins.str: ... @c.setter + @abc.abstractmethod def c(self, value: builtins.str) -> None: ... @@ -5968,19 +6018,22 @@ typing.cast(typing.Any, INonInternalInterface).__jsii_proxy_class__ = lambda : _ @jsii.interface(jsii_type="jsii-calc.IObjectWithProperty") -class IObjectWithProperty(typing_extensions.Protocol): +class IObjectWithProperty(metaclass = jsii.JSIIAbstractClass): '''Make sure that setters are properly called on objects with interfaces.''' @builtins.property # type: ignore[misc] @jsii.member(jsii_name="property") + @abc.abstractmethod def property(self) -> builtins.str: ... @property.setter + @abc.abstractmethod def property(self, value: builtins.str) -> None: ... - @jsii.member(jsii_name="wasSet") + @jsii.member(jsii_name="wasSet") # type: ignore[misc] + @abc.abstractmethod def was_set(self) -> builtins.bool: ... @@ -6008,10 +6061,11 @@ typing.cast(typing.Any, IObjectWithProperty).__jsii_proxy_class__ = lambda : _IO @jsii.interface(jsii_type="jsii-calc.IOptionalMethod") -class IOptionalMethod(typing_extensions.Protocol): +class IOptionalMethod(metaclass = jsii.JSIIAbstractClass): '''Checks that optional result from interface method code generates correctly.''' - @jsii.member(jsii_name="optional") + @jsii.member(jsii_name="optional") # type: ignore[misc] + @abc.abstractmethod def optional(self) -> typing.Optional[builtins.str]: ... @@ -6030,9 +6084,10 @@ typing.cast(typing.Any, IOptionalMethod).__jsii_proxy_class__ = lambda : _IOptio @jsii.interface(jsii_type="jsii-calc.IPrivatelyImplemented") -class IPrivatelyImplemented(typing_extensions.Protocol): +class IPrivatelyImplemented(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="success") + @abc.abstractmethod def success(self) -> builtins.bool: ... @@ -6050,8 +6105,9 @@ typing.cast(typing.Any, IPrivatelyImplemented).__jsii_proxy_class__ = lambda : _ @jsii.interface(jsii_type="jsii-calc.IPublicInterface") -class IPublicInterface(typing_extensions.Protocol): - @jsii.member(jsii_name="bye") +class IPublicInterface(metaclass = jsii.JSIIAbstractClass): + @jsii.member(jsii_name="bye") # type: ignore[misc] + @abc.abstractmethod def bye(self) -> builtins.str: ... @@ -6068,8 +6124,9 @@ typing.cast(typing.Any, IPublicInterface).__jsii_proxy_class__ = lambda : _IPubl @jsii.interface(jsii_type="jsii-calc.IPublicInterface2") -class IPublicInterface2(typing_extensions.Protocol): - @jsii.member(jsii_name="ciao") +class IPublicInterface2(metaclass = jsii.JSIIAbstractClass): + @jsii.member(jsii_name="ciao") # type: ignore[misc] + @abc.abstractmethod def ciao(self) -> builtins.str: ... @@ -6086,10 +6143,11 @@ typing.cast(typing.Any, IPublicInterface2).__jsii_proxy_class__ = lambda : _IPub @jsii.interface(jsii_type="jsii-calc.IRandomNumberGenerator") -class IRandomNumberGenerator(typing_extensions.Protocol): +class IRandomNumberGenerator(metaclass = jsii.JSIIAbstractClass): '''Generates random numbers.''' - @jsii.member(jsii_name="next") + @jsii.member(jsii_name="next") # type: ignore[misc] + @abc.abstractmethod def next(self) -> jsii.Number: '''Returns another random number. @@ -6116,11 +6174,12 @@ typing.cast(typing.Any, IRandomNumberGenerator).__jsii_proxy_class__ = lambda : @jsii.interface(jsii_type="jsii-calc.IReturnJsii976") -class IReturnJsii976(typing_extensions.Protocol): +class IReturnJsii976(metaclass = jsii.JSIIAbstractClass): '''Returns a subclass of a known class which implements an interface.''' @builtins.property # type: ignore[misc] @jsii.member(jsii_name="foo") + @abc.abstractmethod def foo(self) -> jsii.Number: ... @@ -6140,13 +6199,15 @@ typing.cast(typing.Any, IReturnJsii976).__jsii_proxy_class__ = lambda : _IReturn @jsii.interface(jsii_type="jsii-calc.IReturnsNumber") -class IReturnsNumber(typing_extensions.Protocol): +class IReturnsNumber(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="numberProp") + @abc.abstractmethod def number_prop(self) -> scope.jsii_calc_lib.Number: ... - @jsii.member(jsii_name="obtainNumber") + @jsii.member(jsii_name="obtainNumber") # type: ignore[misc] + @abc.abstractmethod def obtain_number(self) -> scope.jsii_calc_lib.IDoublable: ... @@ -6168,17 +6229,20 @@ typing.cast(typing.Any, IReturnsNumber).__jsii_proxy_class__ = lambda : _IReturn @jsii.interface(jsii_type="jsii-calc.IStableInterface") -class IStableInterface(typing_extensions.Protocol): +class IStableInterface(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="mutableProperty") + @abc.abstractmethod def mutable_property(self) -> typing.Optional[jsii.Number]: ... @mutable_property.setter + @abc.abstractmethod def mutable_property(self, value: typing.Optional[jsii.Number]) -> None: ... - @jsii.member(jsii_name="method") + @jsii.member(jsii_name="method") # type: ignore[misc] + @abc.abstractmethod def method(self) -> None: ... @@ -6204,10 +6268,11 @@ typing.cast(typing.Any, IStableInterface).__jsii_proxy_class__ = lambda : _IStab @jsii.interface(jsii_type="jsii-calc.IStructReturningDelegate") -class IStructReturningDelegate(typing_extensions.Protocol): +class IStructReturningDelegate(metaclass = jsii.JSIIAbstractClass): '''Verifies that a "pure" implementation of an interface works correctly.''' - @jsii.member(jsii_name="returnStruct") + @jsii.member(jsii_name="returnStruct") # type: ignore[misc] + @abc.abstractmethod def return_struct(self) -> "StructB": ... @@ -6226,10 +6291,11 @@ typing.cast(typing.Any, IStructReturningDelegate).__jsii_proxy_class__ = lambda @jsii.interface(jsii_type="jsii-calc.IWallClock") -class IWallClock(typing_extensions.Protocol): +class IWallClock(metaclass = jsii.JSIIAbstractClass): '''Implement this interface.''' - @jsii.member(jsii_name="iso8601Now") + @jsii.member(jsii_name="iso8601Now") # type: ignore[misc] + @abc.abstractmethod def iso8601_now(self) -> builtins.str: '''Returns the current time, formatted as an ISO-8601 string.''' ... @@ -9762,7 +9828,7 @@ class ClassWithPrivateConstructorAndAutomaticProperties( class IFriendlyRandomGenerator( IRandomNumberGenerator, scope.jsii_calc_lib.IFriendly, - typing_extensions.Protocol, + metaclass = jsii.JSIIAbstractClass, ): pass @@ -9781,12 +9847,13 @@ typing.cast(typing.Any, IFriendlyRandomGenerator).__jsii_proxy_class__ = lambda @jsii.interface(jsii_type="jsii-calc.IInterfaceThatShouldNotBeADataType") class IInterfaceThatShouldNotBeADataType( IInterfaceWithMethods, - typing_extensions.Protocol, + metaclass = jsii.JSIIAbstractClass, ): '''Even though this interface has only properties, it is disqualified from being a datatype because it inherits from an interface that is not a datatype.''' @builtins.property # type: ignore[misc] @jsii.member(jsii_name="otherValue") + @abc.abstractmethod def other_value(self) -> builtins.str: ... @@ -9808,17 +9875,20 @@ typing.cast(typing.Any, IInterfaceThatShouldNotBeADataType).__jsii_proxy_class__ @jsii.interface(jsii_type="jsii-calc.IJSII417Derived") -class IJSII417Derived(IJSII417PublicBaseOfBase, typing_extensions.Protocol): +class IJSII417Derived(IJSII417PublicBaseOfBase, metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="property") + @abc.abstractmethod def property(self) -> builtins.str: ... - @jsii.member(jsii_name="bar") + @jsii.member(jsii_name="bar") # type: ignore[misc] + @abc.abstractmethod def bar(self) -> None: ... - @jsii.member(jsii_name="baz") + @jsii.member(jsii_name="baz") # type: ignore[misc] + @abc.abstractmethod def baz(self) -> None: ... @@ -11235,13 +11305,15 @@ from .._jsii import * @jsii.interface(jsii_type="jsii-calc.module2700.IFoo") -class IFoo(typing_extensions.Protocol): +class IFoo(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="baz") + @abc.abstractmethod def baz(self) -> jsii.Number: ... - @jsii.member(jsii_name="bar") + @jsii.member(jsii_name="bar") # type: ignore[misc] + @abc.abstractmethod def bar(self) -> builtins.str: ... @@ -11359,8 +11431,9 @@ class Class3(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Class3"): @jsii.interface(jsii_type="jsii-calc.module2702.IBaz") -class IBaz(scope.jsii_calc_base.IBaseInterface, typing_extensions.Protocol): - @jsii.member(jsii_name="bazMethod") +class IBaz(scope.jsii_calc_base.IBaseInterface, metaclass = jsii.JSIIAbstractClass): + @jsii.member(jsii_name="bazMethod") # type: ignore[misc] + @abc.abstractmethod def baz_method(self) -> None: ... @@ -11379,8 +11452,9 @@ typing.cast(typing.Any, IBaz).__jsii_proxy_class__ = lambda : _IBazProxy @jsii.interface(jsii_type="jsii-calc.module2702.IConstruct") -class IConstruct(typing_extensions.Protocol): - @jsii.member(jsii_name="constructMethod") +class IConstruct(metaclass = jsii.JSIIAbstractClass): + @jsii.member(jsii_name="constructMethod") # type: ignore[misc] + @abc.abstractmethod def construct_method(self) -> None: ... @@ -11397,9 +11471,10 @@ typing.cast(typing.Any, IConstruct).__jsii_proxy_class__ = lambda : _IConstructP @jsii.interface(jsii_type="jsii-calc.module2702.IFoo") -class IFoo(scope.jsii_calc_base.IBaseInterface, typing_extensions.Protocol): +class IFoo(scope.jsii_calc_base.IBaseInterface, metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="iBaseInterface") + @abc.abstractmethod def i_base_interface(self) -> builtins.str: ... @@ -11419,8 +11494,9 @@ typing.cast(typing.Any, IFoo).__jsii_proxy_class__ = lambda : _IFooProxy @jsii.interface(jsii_type="jsii-calc.module2702.IResource") -class IResource(IConstruct, typing_extensions.Protocol): - @jsii.member(jsii_name="resourceMethod") +class IResource(IConstruct, metaclass = jsii.JSIIAbstractClass): + @jsii.member(jsii_name="resourceMethod") # type: ignore[misc] + @abc.abstractmethod def resource_method(self) -> None: ... @@ -11439,8 +11515,9 @@ typing.cast(typing.Any, IResource).__jsii_proxy_class__ = lambda : _IResourcePro @jsii.interface(jsii_type="jsii-calc.module2702.IVpc") -class IVpc(IResource, typing_extensions.Protocol): - @jsii.member(jsii_name="vpcMethod") +class IVpc(IResource, metaclass = jsii.JSIIAbstractClass): + @jsii.member(jsii_name="vpcMethod") # type: ignore[misc] + @abc.abstractmethod def vpc_method(self) -> None: ... @@ -11710,8 +11787,9 @@ class ClassWithSelfKwarg( @jsii.interface(jsii_type="jsii-calc.PythonSelf.IInterfaceWithSelf") -class IInterfaceWithSelf(typing_extensions.Protocol): - @jsii.member(jsii_name="method") +class IInterfaceWithSelf(metaclass = jsii.JSIIAbstractClass): + @jsii.member(jsii_name="method") # type: ignore[misc] + @abc.abstractmethod def method(self_, self: jsii.Number) -> builtins.str: ''' :param self: - @@ -12264,9 +12342,10 @@ from ...._jsii import * @jsii.interface( jsii_type="jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced" ) -class INamespaced(typing_extensions.Protocol): +class INamespaced(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="definedAt") + @abc.abstractmethod def defined_at(self) -> builtins.str: ... From e5259ea09134e1f4a4426338d1fb7bc695601fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Mon, 24 Jan 2022 16:06:17 +0100 Subject: [PATCH 02/18] linter fix --- packages/@jsii/python-runtime/tests/test_compliance.py | 5 ++++- packages/jsii-pacmak/lib/targets/python.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/@jsii/python-runtime/tests/test_compliance.py b/packages/@jsii/python-runtime/tests/test_compliance.py index f249b13010..b8f7f0e881 100644 --- a/packages/@jsii/python-runtime/tests/test_compliance.py +++ b/packages/@jsii/python-runtime/tests/test_compliance.py @@ -169,7 +169,9 @@ def next(self): return next_ -class SubclassNativeFriendlyRandom_Inheritance(Number, IFriendly, IRandomNumberGenerator): +class SubclassNativeFriendlyRandom_Inheritance( + Number, IFriendly, IRandomNumberGenerator +): def __init__(self): super().__init__(908) self.next_number = 100 @@ -182,6 +184,7 @@ def next(self): self.next_number += 100 return next_ + @jsii.implements(IFriendlyRandomGenerator) class PureNativeFriendlyRandom: """ diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 1110272c7f..838835aa9b 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -970,7 +970,10 @@ class Interface extends BasePythonClassType { if (this.separateMembers) { code.line(); } - member.emit(code, context, { forceEmitBody: true, renderAbstract: false }); + member.emit(code, context, { + forceEmitBody: true, + renderAbstract: false, + }); } } else { code.line('pass'); From bfa7492b78ce5d7c8a007b0a09a4f9ab8ec6ade1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Tue, 25 Jan 2022 10:17:20 +0100 Subject: [PATCH 03/18] fix snapshot --- .../test/generated-code/__snapshots__/examples.test.ts.snap | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap index 24cd0361f9..a7d9046812 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap @@ -2571,13 +2571,15 @@ class Namespace1(metaclass=jsii.JSIIMeta, jsii_type="testpkg.Namespace1"): ) @jsii.interface(jsii_type="testpkg.Namespace1.IBar") - class IBar(typing_extensions.Protocol): + class IBar(metaclass = jsii.JSIIAbstractClass): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="bar") + @abc.abstractmethod def bar(self) -> builtins.str: ... - @jsii.member(jsii_name="method") + @jsii.member(jsii_name="method") # type: ignore[misc] + @abc.abstractmethod def method(self) -> None: ... From 5a6b6e391049401c9b64db4d521a4edb7b166d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Tue, 25 Jan 2022 11:51:27 +0100 Subject: [PATCH 04/18] make generated classes extend the interfaces they implement --- packages/jsii-pacmak/lib/targets/python.ts | 29 ++--- .../__snapshots__/target-python.test.ts.snap | 107 +++++++++++------- 2 files changed, 79 insertions(+), 57 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 838835aa9b..270a51bd35 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -327,11 +327,9 @@ abstract class BasePythonClassType implements PythonType, ISortableType { public readonly pythonName: string, public readonly spec: spec.Type, public readonly fqn: string | undefined, - opts: PythonTypeOpts, + { bases = [] }: PythonTypeOpts, public readonly docs: spec.Docs | undefined, ) { - const { bases = [] } = opts; - this.bases = bases; this.members = []; } @@ -1348,14 +1346,6 @@ class Class extends BasePythonClassType implements ISortableType { } public emit(code: CodeMaker, context: EmitContext) { - // First we emit our implments decorator - if (this.interfaces.length > 0) { - const interfaces: string[] = this.interfaces.map((b) => - toTypeName(b).pythonType({ ...context, typeAnnotation: false }), - ); - code.line(`@jsii.implements(${interfaces.join(', ')})`); - } - // Then we do our normal class logic for emitting our members. super.emit(code, context); @@ -1414,15 +1404,18 @@ class Class extends BasePythonClassType implements ISortableType { } protected getClassParams(context: EmitContext): string[] { - const params: string[] = this.bases.map((b) => - toTypeName(b).pythonType({ ...context, typeAnnotation: false }), - ); const metaclass: string = this.abstract ? 'JSIIAbstractClass' : 'JSIIMeta'; - params.push(`metaclass=jsii.${metaclass}`); - params.push(`jsii_type="${this.fqn}"`); - - return params; + return [ + ...this.bases.map((b) => + toTypeName(b).pythonType({ ...context, typeAnnotation: false }), + ), + ...this.interfaces.map((i) => + toTypeName(i).pythonType({ ...context, typeAnnotation: false }), + ), + `metaclass=jsii.${metaclass}`, + `jsii_type="${this.fqn}"`, + ]; } private get proxyClassName(): string { diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index 7f3802b24f..b17ece857b 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -1778,9 +1778,9 @@ class StructWithOnlyOptionals: ) -@jsii.implements(IDoublable) class Number( NumericValue, + IDoublable, metaclass=jsii.JSIIMeta, jsii_type="@scope/jsii-calc-lib.Number", ): @@ -3028,9 +3028,9 @@ class BaseJsii976(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.BaseJsii976"): jsii.create(self.__class__, self, []) -@jsii.implements(scope.jsii_calc_lib.IFriendly) class BinaryOperation( scope.jsii_calc_lib.Operation, + scope.jsii_calc_lib.IFriendly, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.BinaryOperation", ): @@ -6342,8 +6342,8 @@ class Implementation(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Implementatio return typing.cast(jsii.Number, jsii.get(self, "value")) -@jsii.implements(IInterfaceWithInternal) class ImplementsInterfaceWithInternal( + IInterfaceWithInternal, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ImplementsInterfaceWithInternal", ): @@ -6822,14 +6822,21 @@ class JavaReservedWords( jsii.set(self, "while", value) -@jsii.implements(IJsii487External2, IJsii487External) -class Jsii487Derived(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Jsii487Derived"): +class Jsii487Derived( + IJsii487External2, + IJsii487External, + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.Jsii487Derived", +): def __init__(self) -> None: jsii.create(self.__class__, self, []) -@jsii.implements(IJsii496) -class Jsii496Derived(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Jsii496Derived"): +class Jsii496Derived( + IJsii496, + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.Jsii496Derived", +): def __init__(self) -> None: jsii.create(self.__class__, self, []) @@ -7183,9 +7190,10 @@ class MethodNamedProperty( return typing.cast(jsii.Number, jsii.get(self, "elite")) -@jsii.implements(IFriendlier, IRandomNumberGenerator) class Multiply( BinaryOperation, + IFriendlier, + IRandomNumberGenerator, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Multiply", ): @@ -9335,8 +9343,8 @@ class UnionProperties: ) -@jsii.implements(scope.jsii_calc_lib.custom_submodule_name.IReflectable) class UpcasingReflectable( + scope.jsii_calc_lib.custom_submodule_name.IReflectable, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.UpcasingReflectable", ): @@ -9555,9 +9563,9 @@ class WithPrivatePropertyInConstructor( return typing.cast(builtins.bool, jsii.get(self, "success")) -@jsii.implements(IInterfaceImplementedByAbstractClass) class AbstractClass( AbstractClassBase, + IInterfaceImplementedByAbstractClass, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.AbstractClass", ): @@ -9623,8 +9631,8 @@ class Add(BinaryOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Add"): return typing.cast(jsii.Number, jsii.get(self, "value")) -@jsii.implements(IAnonymousImplementationProvider) class AnonymousImplementationProvider( + IAnonymousImplementationProvider, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AnonymousImplementationProvider", ): @@ -9640,8 +9648,7 @@ class AnonymousImplementationProvider( return typing.cast(IAnonymouslyImplementMe, jsii.invoke(self, "provideAsInterface", [])) -@jsii.implements(IBell) -class Bell(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Bell"): +class Bell(IBell, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Bell"): def __init__(self) -> None: jsii.create(self.__class__, self, []) @@ -9699,8 +9706,8 @@ class ChildStruct982(ParentStruct982): ) -@jsii.implements(INonInternalInterface) class ClassThatImplementsTheInternalInterface( + INonInternalInterface, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ClassThatImplementsTheInternalInterface", ): @@ -9744,8 +9751,8 @@ class ClassThatImplementsTheInternalInterface( jsii.set(self, "d", value) -@jsii.implements(INonInternalInterface) class ClassThatImplementsThePrivateInterface( + INonInternalInterface, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ClassThatImplementsThePrivateInterface", ): @@ -9789,8 +9796,8 @@ class ClassThatImplementsThePrivateInterface( jsii.set(self, "e", value) -@jsii.implements(IInterfaceWithProperties) class ClassWithPrivateConstructorAndAutomaticProperties( + IInterfaceWithProperties, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ClassWithPrivateConstructorAndAutomaticProperties", ): @@ -9915,9 +9922,9 @@ class _IJSII417DerivedProxy( typing.cast(typing.Any, IJSII417Derived).__jsii_proxy_class__ = lambda : _IJSII417DerivedProxy -@jsii.implements(IPublicInterface2) class InbetweenClass( PublicClass, + IPublicInterface2, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.InbetweenClass", ): @@ -9954,8 +9961,12 @@ class JSII417Derived( return typing.cast(builtins.str, jsii.get(self, "property")) -@jsii.implements(IFriendlier) -class Negate(UnaryOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Negate"): +class Negate( + UnaryOperation, + IFriendlier, + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.Negate", +): '''The negation operation ("-value").''' def __init__(self, operand: scope.jsii_calc_lib.NumericValue) -> None: @@ -10039,8 +10050,11 @@ class SupportsNiceJavaBuilder( return typing.cast(typing.List[builtins.str], jsii.get(self, "rest")) -@jsii.implements(IFriendlyRandomGenerator) -class DoubleTrouble(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DoubleTrouble"): +class DoubleTrouble( + IFriendlyRandomGenerator, + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.DoubleTrouble", +): def __init__(self) -> None: jsii.create(self.__class__, self, []) @@ -10422,8 +10436,8 @@ from ..._jsii import * from ... import IRandomNumberGenerator as _IRandomNumberGenerator_9643a8b9 -@jsii.implements(_IRandomNumberGenerator_9643a8b9) class UnimportedSubmoduleType( + _IRandomNumberGenerator_9643a8b9, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.cdk16625.donotimport.UnimportedSubmoduleType", ): @@ -10852,9 +10866,9 @@ import scope.jsii_calc_base_of_base import scope.jsii_calc_lib -@jsii.implements(scope.jsii_calc_lib.IFriendly) class ExtendAndImplement( scope.jsii_calc_lib.BaseFor2647, + scope.jsii_calc_lib.IFriendly, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2647.ExtendAndImplement", ): @@ -11334,8 +11348,7 @@ class _IFooProxy: typing.cast(typing.Any, IFoo).__jsii_proxy_class__ = lambda : _IFooProxy -@jsii.implements(IFoo) -class Base(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2700.Base"): +class Base(IFoo, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2700.Base"): def __init__(self) -> None: jsii.create(self.__class__, self, []) @@ -11349,8 +11362,12 @@ class Base(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2700.Base"): return typing.cast(jsii.Number, jsii.get(self, "baz")) -@jsii.implements(IFoo) -class Derived(Base, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2700.Derived"): +class Derived( + Base, + IFoo, + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.module2700.Derived", +): def __init__(self) -> None: jsii.create(self.__class__, self, []) @@ -11412,8 +11429,11 @@ class Class2( return typing.cast(builtins.str, jsii.get(self, "base")) -@jsii.implements(scope.jsii_calc_base.IBaseInterface) -class Class3(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Class3"): +class Class3( + scope.jsii_calc_base.IBaseInterface, + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.module2702.Class3", +): def __init__(self) -> None: jsii.create(self.__class__, self, []) @@ -11535,8 +11555,7 @@ class _IVpcProxy( typing.cast(typing.Any, IVpc).__jsii_proxy_class__ = lambda : _IVpcProxy -@jsii.implements(IBaz) -class Baz(Class3, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Baz"): +class Baz(Class3, IBaz, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Baz"): def __init__(self) -> None: jsii.create(self.__class__, self, []) @@ -11545,8 +11564,11 @@ class Baz(Class3, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Baz") return typing.cast(None, jsii.invoke(self, "bazMethod", [])) -@jsii.implements(IConstruct) -class Construct(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Construct"): +class Construct( + IConstruct, + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.module2702.Construct", +): def __init__(self) -> None: jsii.create(self.__class__, self, []) @@ -11555,9 +11577,9 @@ class Construct(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Constru return typing.cast(None, jsii.invoke(self, "constructMethod", [])) -@jsii.implements(IResource) class Resource( Construct, + IResource, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.module2702.Resource", ): @@ -11576,8 +11598,12 @@ class _ResourceProxy(Resource): typing.cast(typing.Any, Resource).__jsii_proxy_class__ = lambda : _ResourceProxy -@jsii.implements(IVpc) -class Vpc(Resource, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Vpc"): +class Vpc( + Resource, + IVpc, + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.module2702.Vpc", +): def __init__(self) -> None: jsii.create(self.__class__, self, []) @@ -11918,8 +11944,11 @@ class Default: ) -@jsii.implements(_INamespaced_e2f386ad) -class MyClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.submodule.MyClass"): +class MyClass( + _INamespaced_e2f386ad, + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.submodule.MyClass", +): def __init__(self, *, prop: _SomeEnum_b2e41d92) -> None: ''' :param prop: @@ -12290,8 +12319,8 @@ from ..child import Goodness as _Goodness_2df26737 from .deeply_nested import INamespaced as _INamespaced_e2f386ad -@jsii.implements(_INamespaced_e2f386ad) class Namespaced( + _INamespaced_e2f386ad, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.submodule.nested_submodule.Namespaced", ): From 742e12e1f9894142da47e87b500e249fea82d984 Mon Sep 17 00:00:00 2001 From: Romain Marcadier Date: Tue, 25 Jan 2022 12:29:24 +0100 Subject: [PATCH 05/18] Update python.md --- .../user-guides/lib-user/language-specific/python.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gh-pages/content/user-guides/lib-user/language-specific/python.md b/gh-pages/content/user-guides/lib-user/language-specific/python.md index a8a82a3e32..5ab3bf39b3 100644 --- a/gh-pages/content/user-guides/lib-user/language-specific/python.md +++ b/gh-pages/content/user-guides/lib-user/language-specific/python.md @@ -26,8 +26,10 @@ from jsii_dependency import IJsiiInterface class MyNewClass(IJsiiInterface): """ Traditional implementation of an interface in Python. - This will not work with interfaces defined by jsii modules, as this will - likely cause a metaclass conflict that the user cannot solve. + In multiple inheritance scenarios, you may encouter a metaclass conflict + if one of the ancestor interfaces is from a library generated with jsii-pacmak + releases <= 1.52.1. In this case, you may need to use the "Legacy Style" (see + below) declaration with the affected interfaces. """ # Member implementations... From 31feec86fcdefd9fe65762a7907a58acbb7848c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Wed, 26 Jan 2022 15:21:34 +0100 Subject: [PATCH 06/18] Try to be dependency-has-protocol-friendly --- packages/@jsii/python-runtime/mypy.ini | 11 +++ .../src/jsii/_kernel/__init__.py | 25 ++++--- .../src/jsii/_kernel/providers/process.py | 4 +- .../@jsii/python-runtime/src/jsii/_runtime.py | 2 +- .../@jsii/python-runtime/src/jsii/_utils.py | 9 ++- packages/jsii-pacmak/lib/targets/python.ts | 69 ++++++++++++++----- .../__snapshots__/target-python.test.ts.snap | 37 +++++++--- 7 files changed, 111 insertions(+), 46 deletions(-) diff --git a/packages/@jsii/python-runtime/mypy.ini b/packages/@jsii/python-runtime/mypy.ini index 976ba02946..7ff19570f6 100644 --- a/packages/@jsii/python-runtime/mypy.ini +++ b/packages/@jsii/python-runtime/mypy.ini @@ -1,2 +1,13 @@ [mypy] +disallow_untyped_decorators = True +pretty = True +python_version = 3.6 +warn_unused_configs = True +warn_unused_ignores = True +warn_unreachable = True + +[mypy-setuptools] +ignore_missing_imports = True + +[mypy-importlib_resources] ignore_missing_imports = True diff --git a/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py b/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py index 95959e7f62..86ec57fade 100644 --- a/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py +++ b/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py @@ -3,7 +3,7 @@ import itertools from types import FunctionType, MethodType, BuiltinFunctionType, LambdaType -from typing import Any, List, Optional, Type, Union +from typing import Any, Callable, List, Optional, Type import functools @@ -137,7 +137,7 @@ def _recursize_dereference(kernel, d): return d -def _dereferenced(fn): +def _dereferenced(fn: Callable[..., Any]) -> Callable[..., Any]: @functools.wraps(fn) def wrapped(kernel, *args, **kwargs): return _recursize_dereference(kernel, fn(kernel, *args, **kwargs)) @@ -224,22 +224,21 @@ def _handle_callback(kernel, callback): def _callback_till_result( kernel, response: Callback, response_type: Type[KernelResponse] ) -> Any: - while isinstance(response, Callback): + current: Any = response + while isinstance(current, Callback): try: - result = _handle_callback(kernel, response) + result = _handle_callback(kernel, current) except Exception as exc: - response = kernel.sync_complete( - response.cbid, str(exc), None, response_type - ) + current = kernel.sync_complete(current.cbid, str(exc), None, response_type) else: - response = kernel.sync_complete(response.cbid, None, result, response_type) + current = kernel.sync_complete(current.cbid, None, result, response_type) - if isinstance(response, InvokeResponse): - return response.result - elif isinstance(response, GetResponse): - return response.value + if isinstance(current, InvokeResponse): + return current.result + elif isinstance(current, GetResponse): + return current.value else: - return response + return current @attr.s(auto_attribs=True, frozen=True, slots=True) diff --git a/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py b/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py index 37cde885b5..85c36b51c4 100644 --- a/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py +++ b/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py @@ -13,10 +13,10 @@ import tempfile import threading -from typing import TYPE_CHECKING, Type, Union, Mapping, IO, Any, AnyStr, Optional +from typing import Type, Union, Mapping, IO, Any, AnyStr, Optional import attr -import cattr # type: ignore +import cattr import dateutil.parser import jsii._embedded.jsii diff --git a/packages/@jsii/python-runtime/src/jsii/_runtime.py b/packages/@jsii/python-runtime/src/jsii/_runtime.py index 8f69b75f1a..0066fec7f8 100644 --- a/packages/@jsii/python-runtime/src/jsii/_runtime.py +++ b/packages/@jsii/python-runtime/src/jsii/_runtime.py @@ -144,7 +144,7 @@ def interface(*, jsii_type: str) -> Callable[[T], T]: def deco(iface): iface.__jsii_type__ = jsii_type # This interface "implements itself" - this is a trick to ease up implementation discovery. - iface.__jsii_ifaces__ = [iface] + iface.__jsii_ifaces__ = [iface] + getattr(iface, "__jsii_ifaces__", []) _reference_map.register_interface(iface) return iface diff --git a/packages/@jsii/python-runtime/src/jsii/_utils.py b/packages/@jsii/python-runtime/src/jsii/_utils.py index 08e69ba035..1592cc988c 100644 --- a/packages/@jsii/python-runtime/src/jsii/_utils.py +++ b/packages/@jsii/python-runtime/src/jsii/_utils.py @@ -1,6 +1,6 @@ import functools -from typing import Any, Mapping, Type +from typing import Any, Callable, List, Mapping, Type, TypeVar class Singleton(type): @@ -14,8 +14,11 @@ def __call__(cls, *args, **kwargs): return cls._instances[cls] -def memoized_property(fgetter): - stored = [] +T = TypeVar("T", bound=Any) + + +def memoized_property(fgetter: Callable[[Any], T]) -> property: + stored: List[T] = [] @functools.wraps(fgetter) def wrapped(self): diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 270a51bd35..3322b09375 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -315,10 +315,12 @@ function isSortableType(arg: unknown): arg is ISortableType { interface PythonTypeOpts { bases?: spec.TypeReference[]; + interfaces?: readonly spec.NamedTypeReference[]; } abstract class BasePythonClassType implements PythonType, ISortableType { protected bases: spec.TypeReference[]; + protected interfaces: readonly spec.NamedTypeReference[]; protected members: PythonBase[]; protected readonly separateMembers: boolean = true; @@ -327,10 +329,11 @@ abstract class BasePythonClassType implements PythonType, ISortableType { public readonly pythonName: string, public readonly spec: spec.Type, public readonly fqn: string | undefined, - { bases = [] }: PythonTypeOpts, + { bases = [], interfaces = [] }: PythonTypeOpts, public readonly docs: spec.Docs | undefined, ) { this.bases = bases; + this.interfaces = interfaces; this.members = []; } @@ -338,10 +341,12 @@ abstract class BasePythonClassType implements PythonType, ISortableType { const dependencies = new Array(); const parent = resolver.getParent(this.fqn!); - // We need to return any bases that are in the same module at the same level of - // nesting. + // We need to return any bases that are in the same module at the same level + // of nesting. For the purpose of this function, interfaces are also bases + // (those are python base classes, and we'll extend interfaces being + // implemented) const seen = new Set(); - for (const base of this.bases) { + for (const base of [...this.bases, ...this.interfaces]) { if (spec.isNamedTypeReference(base)) { if (resolver.isInModule(base)) { // Given a base, we need to locate the base's parent that is the same as @@ -937,10 +942,31 @@ abstract class BaseProperty implements PythonBase { } class Interface extends BasePythonClassType { + public constructor( + generator: PythonGenerator, + pythonName: string, + spec: spec.Type, + fqn: string | undefined, + opts: Omit & { readonly bases?: never }, + docs: spec.Docs | undefined, + ) { + super(generator, pythonName, spec, fqn, opts, docs); + } + public emit(code: CodeMaker, context: EmitContext) { context = nestedContext(context, this.fqn); emitList(code, '@jsii.interface(', [`jsii_type="${this.fqn}"`], ')'); + const interfaces = this.interfaces + // Only emit decorators for foreign interfaces (those could be Protocols, we don't know yet) + .filter((iface) => !context.resolver.isInModule(iface)) + // Turn all those interface types to type reference names... + .map((iface) => toTypeName(iface).pythonType(context)); + // If we have anything, emit an `@jsii.implements` declaration. + if (interfaces.length > 0) { + code.line(`@jsii.implements(${interfaces.join(', ')})`); + } + // First we do our normal class logic for emitting our members. super.emit(code, context); @@ -948,10 +974,10 @@ class Interface extends BasePythonClassType { code.line(); // Then, we have to emit a Proxy class which implements our proxy interface. - const proxyBases: string[] = this.bases.map( - (b) => + const proxyBases: string[] = this.interfaces.map( + (iface) => // "# type: ignore[misc]" because MyPy cannot check dynamic base classes (naturally) - `jsii.proxy_for(${toTypeName(b).pythonType({ + `jsii.proxy_for(${toTypeName(iface).pythonType({ ...context, typeAnnotation: false, })}) # type: ignore[misc]`, @@ -992,9 +1018,15 @@ class Interface extends BasePythonClassType { } protected getClassParams(context: EmitContext): string[] { - const params: string[] = this.bases.map((b) => - toTypeName(b).pythonType({ ...context, typeAnnotation: false }), - ); + const params: string[] = this.interfaces.map((iface) => { + const rawType = toTypeName(iface).pythonType({ ...context, typeAnnotation: false }); + return context.resolver.isInModule(iface) + ? rawType + // If the interface is a protocol, we cannot "directly" extend it, as that would end up + // causing a metaclass conflict. Those will effectively be "duck typed" in, so that is okay. + // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. + : `*(() if type(${rawType}) is typing_extensions.Protocol else (${rawType},))`; + }); // Interfaces are kind of like abstract classes. We type them the same way. params.push('metaclass = jsii.JSIIAbstractClass'); @@ -1286,7 +1318,6 @@ interface ClassOpts extends PythonTypeOpts { class Class extends BasePythonClassType implements ISortableType { private readonly abstract: boolean; private readonly abstractBases: spec.ClassType[]; - private readonly interfaces: spec.NamedTypeReference[]; public constructor( generator: PythonGenerator, @@ -1298,10 +1329,9 @@ class Class extends BasePythonClassType implements ISortableType { ) { super(generator, name, spec, fqn, opts, docs); - const { abstract = false, interfaces = [], abstractBases = [] } = opts; + const { abstract = false, abstractBases = [] } = opts; this.abstract = abstract; - this.interfaces = interfaces; this.abstractBases = abstractBases; } @@ -1410,8 +1440,15 @@ class Class extends BasePythonClassType implements ISortableType { ...this.bases.map((b) => toTypeName(b).pythonType({ ...context, typeAnnotation: false }), ), - ...this.interfaces.map((i) => - toTypeName(i).pythonType({ ...context, typeAnnotation: false }), + ...this.interfaces.map((i) => { + const rawTypeName = toTypeName(i).pythonType({ ...context, typeAnnotation: false }); + // If the interface is a protocol, we cannot "directly" extend it, as that would end up + // causing a metaclass conflict. Those will effectively be "duck typed" in, so that is okay. + // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. + return context.resolver.isInModule(i) + ? rawTypeName + : `*(() if type(${rawTypeName}) is typing_extensions.Protocol else (${rawTypeName},))`; + }, ), `metaclass=jsii.${metaclass}`, `jsii_type="${this.fqn}"`, @@ -2664,7 +2701,7 @@ class PythonGenerator extends Generator { toPythonIdentifier(ifc.name), ifc, ifc.fqn, - { bases: ifc.interfaces?.map((base) => this.findType(base)) }, + { interfaces: ifc.interfaces?.map((base) => this.findType(base)) }, ifc.docs, ); } diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index b17ece857b..c983490149 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -397,8 +397,9 @@ class BaseProps(scope.jsii_calc_base_of_base.VeryBaseProps): @jsii.interface(jsii_type="@scope/jsii-calc-base.IBaseInterface") +@jsii.implements(scope.jsii_calc_base_of_base.IVeryBaseInterface) class IBaseInterface( - scope.jsii_calc_base_of_base.IVeryBaseInterface, + *(() if type(scope.jsii_calc_base_of_base.IVeryBaseInterface) is typing_extensions.Protocol else (scope.jsii_calc_base_of_base.IVeryBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): @jsii.member(jsii_name="bar") # type: ignore[misc] @@ -1505,8 +1506,9 @@ typing.cast(typing.Any, IFriendly).__jsii_proxy_class__ = lambda : _IFriendlyPro @jsii.interface(jsii_type="@scope/jsii-calc-lib.IThreeLevelsInterface") +@jsii.implements(scope.jsii_calc_base.IBaseInterface) class IThreeLevelsInterface( - scope.jsii_calc_base.IBaseInterface, + *(() if type(scope.jsii_calc_base.IBaseInterface) is typing_extensions.Protocol else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): '''(deprecated) Interface that inherits from packages 2 levels up the tree. @@ -3030,7 +3032,7 @@ class BaseJsii976(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.BaseJsii976"): class BinaryOperation( scope.jsii_calc_lib.Operation, - scope.jsii_calc_lib.IFriendly, + *(() if type(scope.jsii_calc_lib.IFriendly) is typing_extensions.Protocol else (scope.jsii_calc_lib.IFriendly,)), metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.BinaryOperation", ): @@ -5631,7 +5633,11 @@ typing.cast(typing.Any, IExternalInterface).__jsii_proxy_class__ = lambda : _IEx @jsii.interface(jsii_type="jsii-calc.IFriendlier") -class IFriendlier(scope.jsii_calc_lib.IFriendly, metaclass = jsii.JSIIAbstractClass): +@jsii.implements(scope.jsii_calc_lib.IFriendly) +class IFriendlier( + *(() if type(scope.jsii_calc_lib.IFriendly) is typing_extensions.Protocol else (scope.jsii_calc_lib.IFriendly,)), + metaclass = jsii.JSIIAbstractClass, +): '''Even friendlier classes can implement this interface.''' @jsii.member(jsii_name="farewell") # type: ignore[misc] @@ -9344,7 +9350,7 @@ class UnionProperties: class UpcasingReflectable( - scope.jsii_calc_lib.custom_submodule_name.IReflectable, + *(() if type(scope.jsii_calc_lib.custom_submodule_name.IReflectable) is typing_extensions.Protocol else (scope.jsii_calc_lib.custom_submodule_name.IReflectable,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.UpcasingReflectable", ): @@ -9832,9 +9838,10 @@ class ClassWithPrivateConstructorAndAutomaticProperties( @jsii.interface(jsii_type="jsii-calc.IFriendlyRandomGenerator") +@jsii.implements(scope.jsii_calc_lib.IFriendly) class IFriendlyRandomGenerator( IRandomNumberGenerator, - scope.jsii_calc_lib.IFriendly, + *(() if type(scope.jsii_calc_lib.IFriendly) is typing_extensions.Protocol else (scope.jsii_calc_lib.IFriendly,)), metaclass = jsii.JSIIAbstractClass, ): pass @@ -10437,7 +10444,7 @@ from ... import IRandomNumberGenerator as _IRandomNumberGenerator_9643a8b9 class UnimportedSubmoduleType( - _IRandomNumberGenerator_9643a8b9, + *(() if type(_IRandomNumberGenerator_9643a8b9) is typing_extensions.Protocol else (_IRandomNumberGenerator_9643a8b9,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.cdk16625.donotimport.UnimportedSubmoduleType", ): @@ -10868,7 +10875,7 @@ import scope.jsii_calc_lib class ExtendAndImplement( scope.jsii_calc_lib.BaseFor2647, - scope.jsii_calc_lib.IFriendly, + *(() if type(scope.jsii_calc_lib.IFriendly) is typing_extensions.Protocol else (scope.jsii_calc_lib.IFriendly,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2647.ExtendAndImplement", ): @@ -11430,7 +11437,7 @@ class Class2( class Class3( - scope.jsii_calc_base.IBaseInterface, + *(() if type(scope.jsii_calc_base.IBaseInterface) is typing_extensions.Protocol else (scope.jsii_calc_base.IBaseInterface,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Class3", ): @@ -11451,7 +11458,11 @@ class Class3( @jsii.interface(jsii_type="jsii-calc.module2702.IBaz") -class IBaz(scope.jsii_calc_base.IBaseInterface, metaclass = jsii.JSIIAbstractClass): +@jsii.implements(scope.jsii_calc_base.IBaseInterface) +class IBaz( + *(() if type(scope.jsii_calc_base.IBaseInterface) is typing_extensions.Protocol else (scope.jsii_calc_base.IBaseInterface,)), + metaclass = jsii.JSIIAbstractClass, +): @jsii.member(jsii_name="bazMethod") # type: ignore[misc] @abc.abstractmethod def baz_method(self) -> None: @@ -11491,7 +11502,11 @@ typing.cast(typing.Any, IConstruct).__jsii_proxy_class__ = lambda : _IConstructP @jsii.interface(jsii_type="jsii-calc.module2702.IFoo") -class IFoo(scope.jsii_calc_base.IBaseInterface, metaclass = jsii.JSIIAbstractClass): +@jsii.implements(scope.jsii_calc_base.IBaseInterface) +class IFoo( + *(() if type(scope.jsii_calc_base.IBaseInterface) is typing_extensions.Protocol else (scope.jsii_calc_base.IBaseInterface,)), + metaclass = jsii.JSIIAbstractClass, +): @builtins.property # type: ignore[misc] @jsii.member(jsii_name="iBaseInterface") @abc.abstractmethod From 715a3f77f2f114d9bb06da32a3d8b26c29cc289d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Wed, 26 Jan 2022 15:35:53 +0100 Subject: [PATCH 07/18] linter fix + version fix --- .../@jsii/python-runtime/build-tools/gen.ts | 6 +++++- packages/jsii-pacmak/lib/targets/python.ts | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/@jsii/python-runtime/build-tools/gen.ts b/packages/@jsii/python-runtime/build-tools/gen.ts index e375f61a0a..16ed023b2e 100644 --- a/packages/@jsii/python-runtime/build-tools/gen.ts +++ b/packages/@jsii/python-runtime/build-tools/gen.ts @@ -3,6 +3,10 @@ import { copyFileSync, readdirSync, statSync, writeFileSync } from 'fs'; import { resolve } from 'path'; +// Ensure we use a version number that is coherent with Python specifics. +import { TargetName } from 'jsii-pacmak/lib/targets'; +import { toReleaseVersion } from 'jsii-pacmak/lib/targets/version-utils'; + const EMBEDDED_SOURCE = resolve(__dirname, '..', '..', 'runtime', 'webpack'); const EMBEDDED_INFO = resolve(__dirname, '..', '..', 'runtime', 'package.json'); @@ -13,7 +17,7 @@ writeFileSync( resolve(__dirname, '..', 'src', 'jsii', '_metadata.json'), JSON.stringify( { - version: data.version, + version: toReleaseVersion(data.version, TargetName.PYTHON), description: data.description, license: data.license, author: data.author.name, diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 3322b09375..698098111f 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -1019,13 +1019,16 @@ class Interface extends BasePythonClassType { protected getClassParams(context: EmitContext): string[] { const params: string[] = this.interfaces.map((iface) => { - const rawType = toTypeName(iface).pythonType({ ...context, typeAnnotation: false }); + const rawType = toTypeName(iface).pythonType({ + ...context, + typeAnnotation: false, + }); return context.resolver.isInModule(iface) ? rawType - // If the interface is a protocol, we cannot "directly" extend it, as that would end up - // causing a metaclass conflict. Those will effectively be "duck typed" in, so that is okay. - // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. - : `*(() if type(${rawType}) is typing_extensions.Protocol else (${rawType},))`; + : // If the interface is a protocol, we cannot "directly" extend it, as that would end up + // causing a metaclass conflict. Those will effectively be "duck typed" in, so that is okay. + // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. + `*(() if type(${rawType}) is typing_extensions.Protocol else (${rawType},))`; }); // Interfaces are kind of like abstract classes. We type them the same way. @@ -1441,15 +1444,17 @@ class Class extends BasePythonClassType implements ISortableType { toTypeName(b).pythonType({ ...context, typeAnnotation: false }), ), ...this.interfaces.map((i) => { - const rawTypeName = toTypeName(i).pythonType({ ...context, typeAnnotation: false }); + const rawTypeName = toTypeName(i).pythonType({ + ...context, + typeAnnotation: false, + }); // If the interface is a protocol, we cannot "directly" extend it, as that would end up // causing a metaclass conflict. Those will effectively be "duck typed" in, so that is okay. // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. return context.resolver.isInModule(i) ? rawTypeName : `*(() if type(${rawTypeName}) is typing_extensions.Protocol else (${rawTypeName},))`; - }, - ), + }), `metaclass=jsii.${metaclass}`, `jsii_type="${this.fqn}"`, ]; From 7c7da80879af589a634db7fb1a42af0e7575c045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Wed, 26 Jan 2022 16:55:06 +0100 Subject: [PATCH 08/18] use issubclass instead of trying to match type --- packages/jsii-pacmak/lib/targets/python.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 698098111f..3cc2026ef1 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -1019,16 +1019,16 @@ class Interface extends BasePythonClassType { protected getClassParams(context: EmitContext): string[] { const params: string[] = this.interfaces.map((iface) => { - const rawType = toTypeName(iface).pythonType({ + const rawTypeName = toTypeName(iface).pythonType({ ...context, typeAnnotation: false, }); return context.resolver.isInModule(iface) - ? rawType + ? rawTypeName : // If the interface is a protocol, we cannot "directly" extend it, as that would end up // causing a metaclass conflict. Those will effectively be "duck typed" in, so that is okay. // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. - `*(() if type(${rawType}) is typing_extensions.Protocol else (${rawType},))`; + `*(() if issubclass(${rawTypeName}), typing_extensions.Protocol) else (${rawTypeName},))`; }); // Interfaces are kind of like abstract classes. We type them the same way. @@ -1453,7 +1453,7 @@ class Class extends BasePythonClassType implements ISortableType { // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. return context.resolver.isInModule(i) ? rawTypeName - : `*(() if type(${rawTypeName}) is typing_extensions.Protocol else (${rawTypeName},))`; + : `*(() if issubclass(${rawTypeName}), typing_extensions.Protocol) else (${rawTypeName},))`; }), `metaclass=jsii.${metaclass}`, `jsii_type="${this.fqn}"`, From ae365fc48fc9b60f4e20e1a1e4835377677352ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Wed, 26 Jan 2022 17:35:45 +0100 Subject: [PATCH 09/18] fix typo --- packages/jsii-pacmak/lib/targets/python.ts | 4 ++-- .../__snapshots__/target-python.test.ts.snap | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 3cc2026ef1..c6e6670a26 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -1028,7 +1028,7 @@ class Interface extends BasePythonClassType { : // If the interface is a protocol, we cannot "directly" extend it, as that would end up // causing a metaclass conflict. Those will effectively be "duck typed" in, so that is okay. // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. - `*(() if issubclass(${rawTypeName}), typing_extensions.Protocol) else (${rawTypeName},))`; + `*(() if issubclass(${rawTypeName}, typing_extensions.Protocol) else (${rawTypeName},))`; }); // Interfaces are kind of like abstract classes. We type them the same way. @@ -1453,7 +1453,7 @@ class Class extends BasePythonClassType implements ISortableType { // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. return context.resolver.isInModule(i) ? rawTypeName - : `*(() if issubclass(${rawTypeName}), typing_extensions.Protocol) else (${rawTypeName},))`; + : `*(() if issubclass(${rawTypeName}, typing_extensions.Protocol) else (${rawTypeName},))`; }), `metaclass=jsii.${metaclass}`, `jsii_type="${this.fqn}"`, diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index c983490149..dbdb87bff1 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -399,7 +399,7 @@ class BaseProps(scope.jsii_calc_base_of_base.VeryBaseProps): @jsii.interface(jsii_type="@scope/jsii-calc-base.IBaseInterface") @jsii.implements(scope.jsii_calc_base_of_base.IVeryBaseInterface) class IBaseInterface( - *(() if type(scope.jsii_calc_base_of_base.IVeryBaseInterface) is typing_extensions.Protocol else (scope.jsii_calc_base_of_base.IVeryBaseInterface,)), + *(() if issubclass(scope.jsii_calc_base_of_base.IVeryBaseInterface, typing_extensions.Protocol) else (scope.jsii_calc_base_of_base.IVeryBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): @jsii.member(jsii_name="bar") # type: ignore[misc] @@ -1508,7 +1508,7 @@ typing.cast(typing.Any, IFriendly).__jsii_proxy_class__ = lambda : _IFriendlyPro @jsii.interface(jsii_type="@scope/jsii-calc-lib.IThreeLevelsInterface") @jsii.implements(scope.jsii_calc_base.IBaseInterface) class IThreeLevelsInterface( - *(() if type(scope.jsii_calc_base.IBaseInterface) is typing_extensions.Protocol else (scope.jsii_calc_base.IBaseInterface,)), + *(() if issubclass(scope.jsii_calc_base.IBaseInterface, typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): '''(deprecated) Interface that inherits from packages 2 levels up the tree. @@ -3032,7 +3032,7 @@ class BaseJsii976(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.BaseJsii976"): class BinaryOperation( scope.jsii_calc_lib.Operation, - *(() if type(scope.jsii_calc_lib.IFriendly) is typing_extensions.Protocol else (scope.jsii_calc_lib.IFriendly,)), + *(() if issubclass(scope.jsii_calc_lib.IFriendly, typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.BinaryOperation", ): @@ -5635,7 +5635,7 @@ typing.cast(typing.Any, IExternalInterface).__jsii_proxy_class__ = lambda : _IEx @jsii.interface(jsii_type="jsii-calc.IFriendlier") @jsii.implements(scope.jsii_calc_lib.IFriendly) class IFriendlier( - *(() if type(scope.jsii_calc_lib.IFriendly) is typing_extensions.Protocol else (scope.jsii_calc_lib.IFriendly,)), + *(() if issubclass(scope.jsii_calc_lib.IFriendly, typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), metaclass = jsii.JSIIAbstractClass, ): '''Even friendlier classes can implement this interface.''' @@ -9350,7 +9350,7 @@ class UnionProperties: class UpcasingReflectable( - *(() if type(scope.jsii_calc_lib.custom_submodule_name.IReflectable) is typing_extensions.Protocol else (scope.jsii_calc_lib.custom_submodule_name.IReflectable,)), + *(() if issubclass(scope.jsii_calc_lib.custom_submodule_name.IReflectable, typing_extensions.Protocol) else (scope.jsii_calc_lib.custom_submodule_name.IReflectable,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.UpcasingReflectable", ): @@ -9841,7 +9841,7 @@ class ClassWithPrivateConstructorAndAutomaticProperties( @jsii.implements(scope.jsii_calc_lib.IFriendly) class IFriendlyRandomGenerator( IRandomNumberGenerator, - *(() if type(scope.jsii_calc_lib.IFriendly) is typing_extensions.Protocol else (scope.jsii_calc_lib.IFriendly,)), + *(() if issubclass(scope.jsii_calc_lib.IFriendly, typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), metaclass = jsii.JSIIAbstractClass, ): pass @@ -10444,7 +10444,7 @@ from ... import IRandomNumberGenerator as _IRandomNumberGenerator_9643a8b9 class UnimportedSubmoduleType( - *(() if type(_IRandomNumberGenerator_9643a8b9) is typing_extensions.Protocol else (_IRandomNumberGenerator_9643a8b9,)), + *(() if issubclass(_IRandomNumberGenerator_9643a8b9, typing_extensions.Protocol) else (_IRandomNumberGenerator_9643a8b9,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.cdk16625.donotimport.UnimportedSubmoduleType", ): @@ -10875,7 +10875,7 @@ import scope.jsii_calc_lib class ExtendAndImplement( scope.jsii_calc_lib.BaseFor2647, - *(() if type(scope.jsii_calc_lib.IFriendly) is typing_extensions.Protocol else (scope.jsii_calc_lib.IFriendly,)), + *(() if issubclass(scope.jsii_calc_lib.IFriendly, typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2647.ExtendAndImplement", ): @@ -11437,7 +11437,7 @@ class Class2( class Class3( - *(() if type(scope.jsii_calc_base.IBaseInterface) is typing_extensions.Protocol else (scope.jsii_calc_base.IBaseInterface,)), + *(() if issubclass(scope.jsii_calc_base.IBaseInterface, typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Class3", ): @@ -11460,7 +11460,7 @@ class Class3( @jsii.interface(jsii_type="jsii-calc.module2702.IBaz") @jsii.implements(scope.jsii_calc_base.IBaseInterface) class IBaz( - *(() if type(scope.jsii_calc_base.IBaseInterface) is typing_extensions.Protocol else (scope.jsii_calc_base.IBaseInterface,)), + *(() if issubclass(scope.jsii_calc_base.IBaseInterface, typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): @jsii.member(jsii_name="bazMethod") # type: ignore[misc] @@ -11504,7 +11504,7 @@ typing.cast(typing.Any, IConstruct).__jsii_proxy_class__ = lambda : _IConstructP @jsii.interface(jsii_type="jsii-calc.module2702.IFoo") @jsii.implements(scope.jsii_calc_base.IBaseInterface) class IFoo( - *(() if type(scope.jsii_calc_base.IBaseInterface) is typing_extensions.Protocol else (scope.jsii_calc_base.IBaseInterface,)), + *(() if issubclass(scope.jsii_calc_base.IBaseInterface, typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): @builtins.property # type: ignore[misc] From 24243927ef45daf32e258dd3fd6eb7a7ccdbd13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Wed, 26 Jan 2022 19:30:38 +0100 Subject: [PATCH 10/18] try to not use issubclass (won't work in python 3.6) --- packages/jsii-pacmak/lib/targets/python.ts | 4 ++-- .../__snapshots__/target-python.test.ts.snap | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index c6e6670a26..d860f25ba5 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -1028,7 +1028,7 @@ class Interface extends BasePythonClassType { : // If the interface is a protocol, we cannot "directly" extend it, as that would end up // causing a metaclass conflict. Those will effectively be "duck typed" in, so that is okay. // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. - `*(() if issubclass(${rawTypeName}, typing_extensions.Protocol) else (${rawTypeName},))`; + `*(() if type(${rawTypeName}) is type(typing_extensions.Protocol) else (${rawTypeName},))`; }); // Interfaces are kind of like abstract classes. We type them the same way. @@ -1453,7 +1453,7 @@ class Class extends BasePythonClassType implements ISortableType { // The "erasure" is achieved by splat-ing an empty tuple in case it's a Protocol. return context.resolver.isInModule(i) ? rawTypeName - : `*(() if issubclass(${rawTypeName}, typing_extensions.Protocol) else (${rawTypeName},))`; + : `*(() if type(${rawTypeName}) is type(typing_extensions.Protocol) else (${rawTypeName},))`; }), `metaclass=jsii.${metaclass}`, `jsii_type="${this.fqn}"`, diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index dbdb87bff1..5e3f0cb4be 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -399,7 +399,7 @@ class BaseProps(scope.jsii_calc_base_of_base.VeryBaseProps): @jsii.interface(jsii_type="@scope/jsii-calc-base.IBaseInterface") @jsii.implements(scope.jsii_calc_base_of_base.IVeryBaseInterface) class IBaseInterface( - *(() if issubclass(scope.jsii_calc_base_of_base.IVeryBaseInterface, typing_extensions.Protocol) else (scope.jsii_calc_base_of_base.IVeryBaseInterface,)), + *(() if type(scope.jsii_calc_base_of_base.IVeryBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base_of_base.IVeryBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): @jsii.member(jsii_name="bar") # type: ignore[misc] @@ -1508,7 +1508,7 @@ typing.cast(typing.Any, IFriendly).__jsii_proxy_class__ = lambda : _IFriendlyPro @jsii.interface(jsii_type="@scope/jsii-calc-lib.IThreeLevelsInterface") @jsii.implements(scope.jsii_calc_base.IBaseInterface) class IThreeLevelsInterface( - *(() if issubclass(scope.jsii_calc_base.IBaseInterface, typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), + *(() if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): '''(deprecated) Interface that inherits from packages 2 levels up the tree. @@ -3032,7 +3032,7 @@ class BaseJsii976(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.BaseJsii976"): class BinaryOperation( scope.jsii_calc_lib.Operation, - *(() if issubclass(scope.jsii_calc_lib.IFriendly, typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), + *(() if type(scope.jsii_calc_lib.IFriendly) is type(typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.BinaryOperation", ): @@ -5635,7 +5635,7 @@ typing.cast(typing.Any, IExternalInterface).__jsii_proxy_class__ = lambda : _IEx @jsii.interface(jsii_type="jsii-calc.IFriendlier") @jsii.implements(scope.jsii_calc_lib.IFriendly) class IFriendlier( - *(() if issubclass(scope.jsii_calc_lib.IFriendly, typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), + *(() if type(scope.jsii_calc_lib.IFriendly) is type(typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), metaclass = jsii.JSIIAbstractClass, ): '''Even friendlier classes can implement this interface.''' @@ -9350,7 +9350,7 @@ class UnionProperties: class UpcasingReflectable( - *(() if issubclass(scope.jsii_calc_lib.custom_submodule_name.IReflectable, typing_extensions.Protocol) else (scope.jsii_calc_lib.custom_submodule_name.IReflectable,)), + *(() if type(scope.jsii_calc_lib.custom_submodule_name.IReflectable) is type(typing_extensions.Protocol) else (scope.jsii_calc_lib.custom_submodule_name.IReflectable,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.UpcasingReflectable", ): @@ -9841,7 +9841,7 @@ class ClassWithPrivateConstructorAndAutomaticProperties( @jsii.implements(scope.jsii_calc_lib.IFriendly) class IFriendlyRandomGenerator( IRandomNumberGenerator, - *(() if issubclass(scope.jsii_calc_lib.IFriendly, typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), + *(() if type(scope.jsii_calc_lib.IFriendly) is type(typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), metaclass = jsii.JSIIAbstractClass, ): pass @@ -10444,7 +10444,7 @@ from ... import IRandomNumberGenerator as _IRandomNumberGenerator_9643a8b9 class UnimportedSubmoduleType( - *(() if issubclass(_IRandomNumberGenerator_9643a8b9, typing_extensions.Protocol) else (_IRandomNumberGenerator_9643a8b9,)), + *(() if type(_IRandomNumberGenerator_9643a8b9) is type(typing_extensions.Protocol) else (_IRandomNumberGenerator_9643a8b9,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.cdk16625.donotimport.UnimportedSubmoduleType", ): @@ -10875,7 +10875,7 @@ import scope.jsii_calc_lib class ExtendAndImplement( scope.jsii_calc_lib.BaseFor2647, - *(() if issubclass(scope.jsii_calc_lib.IFriendly, typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), + *(() if type(scope.jsii_calc_lib.IFriendly) is type(typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2647.ExtendAndImplement", ): @@ -11437,7 +11437,7 @@ class Class2( class Class3( - *(() if issubclass(scope.jsii_calc_base.IBaseInterface, typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), + *(() if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2702.Class3", ): @@ -11460,7 +11460,7 @@ class Class3( @jsii.interface(jsii_type="jsii-calc.module2702.IBaz") @jsii.implements(scope.jsii_calc_base.IBaseInterface) class IBaz( - *(() if issubclass(scope.jsii_calc_base.IBaseInterface, typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), + *(() if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): @jsii.member(jsii_name="bazMethod") # type: ignore[misc] @@ -11504,7 +11504,7 @@ typing.cast(typing.Any, IConstruct).__jsii_proxy_class__ = lambda : _IConstructP @jsii.interface(jsii_type="jsii-calc.module2702.IFoo") @jsii.implements(scope.jsii_calc_base.IBaseInterface) class IFoo( - *(() if issubclass(scope.jsii_calc_base.IBaseInterface, typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), + *(() if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): @builtins.property # type: ignore[misc] From 9e0d3c57bf82d0d22391254d0b761fd659a1d660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Thu, 27 Jan 2022 10:15:26 +0100 Subject: [PATCH 11/18] de-duplicate interfaces to avoid MRO issues --- packages/jsii-pacmak/lib/generator.ts | 9 ++++- packages/jsii-pacmak/lib/targets/python.ts | 38 ++++++++++++++++++- .../__snapshots__/target-python.test.ts.snap | 7 +--- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/packages/jsii-pacmak/lib/generator.ts b/packages/jsii-pacmak/lib/generator.ts index 0e7be32f55..ade01f824b 100644 --- a/packages/jsii-pacmak/lib/generator.ts +++ b/packages/jsii-pacmak/lib/generator.ts @@ -676,7 +676,14 @@ export abstract class Generator implements IGenerator { ); } + /** + * @deprecated use findReflectType instead. + */ protected findType(fqn: string): spec.Type { + return this.findReflectType(fqn).spec; + } + + protected findReflectType(fqn: string): reflect.Type { const ret = this.reflectAssembly.system.tryFindFqn(fqn); if (!ret) { throw new Error( @@ -684,6 +691,6 @@ export abstract class Generator implements IGenerator { ); } - return ret.spec; + return ret; } } diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index d860f25ba5..afd253adb6 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -2557,7 +2557,7 @@ class PythonGenerator extends Generator { { abstract, bases: cls.base ? [this.findType(cls.base)] : undefined, - interfaces: cls.interfaces?.map((base) => this.findType(base)), + interfaces: this.deduplicatedInterfaces(cls.interfaces, cls.base), abstractBases: abstract ? this.getAbstractBases(cls) : [], }, cls.docs, @@ -2706,7 +2706,7 @@ class PythonGenerator extends Generator { toPythonIdentifier(ifc.name), ifc, ifc.fqn, - { interfaces: ifc.interfaces?.map((base) => this.findType(base)) }, + { interfaces: this.deduplicatedInterfaces(ifc.interfaces) }, ifc.docs, ); } @@ -2796,6 +2796,40 @@ class PythonGenerator extends Generator { throw new Error('Unhandled Type: StaticMethodOverload'); } + /** + * De-duplicates a list of interfaces, removing those that are already transitively implemented. + * This is useful as Python will not manage to create a consistent MRO in case the same interface + * is both directly and transitively extended (as a consistent MRO would then require that + * interface to be at two different locations in the list). + * + * @param fqns a possibly empty set of interface FQNs to de-duplicate. + * @param baseFqns the list of base classes that may also implement interfaces + * + * @returns the de-duplicated list of interface types. + */ + private deduplicatedInterfaces(fqns: readonly string[] | undefined, baseFqn?: string) { + if (fqns == null) { + return []; + } + + const result = new Array(); + + const interfaces = fqns.map((fqn) => this.findReflectType(fqn) as reflect.InterfaceType).reverse(); + const base = baseFqn == null ? undefined : this.findReflectType(baseFqn) as reflect.ClassType; + while (interfaces.length > 0) { + const iface = interfaces.pop()!; + if (interfaces.some((other) => other.getInterfaces(true).some(({fqn}) => fqn === iface.fqn))) { + continue; + } + if (base?.getInterfaces(true).some(({ fqn }) => fqn === iface.fqn)) { + continue; + } + result.push(iface.spec); + } + + return result; + } + private getAssemblyModuleName(assm: spec.Assembly): string { return `${assm.targets!.python!.module}._jsii`; } diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index 5e3f0cb4be..e63bf36c47 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -11369,12 +11369,7 @@ class Base(IFoo, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2700.Base") return typing.cast(jsii.Number, jsii.get(self, "baz")) -class Derived( - Base, - IFoo, - metaclass=jsii.JSIIMeta, - jsii_type="jsii-calc.module2700.Derived", -): +class Derived(Base, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2700.Derived"): def __init__(self) -> None: jsii.create(self.__class__, self, []) From 2bae124bb46fefa16cefdd10f70393997dacab8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Thu, 27 Jan 2022 10:35:22 +0100 Subject: [PATCH 12/18] linter fix --- packages/jsii-pacmak/lib/targets/python.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index afd253adb6..a330aafa67 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -2807,18 +2807,30 @@ class PythonGenerator extends Generator { * * @returns the de-duplicated list of interface types. */ - private deduplicatedInterfaces(fqns: readonly string[] | undefined, baseFqn?: string) { + private deduplicatedInterfaces( + fqns: readonly string[] | undefined, + baseFqn?: string, + ) { if (fqns == null) { return []; } const result = new Array(); - const interfaces = fqns.map((fqn) => this.findReflectType(fqn) as reflect.InterfaceType).reverse(); - const base = baseFqn == null ? undefined : this.findReflectType(baseFqn) as reflect.ClassType; + const interfaces = fqns + .map((fqn) => this.findReflectType(fqn) as reflect.InterfaceType) + .reverse(); + const base = + baseFqn == null + ? undefined + : (this.findReflectType(baseFqn) as reflect.ClassType); while (interfaces.length > 0) { const iface = interfaces.pop()!; - if (interfaces.some((other) => other.getInterfaces(true).some(({fqn}) => fqn === iface.fqn))) { + if ( + interfaces.some((other) => + other.getInterfaces(true).some(({ fqn }) => fqn === iface.fqn), + ) + ) { continue; } if (base?.getInterfaces(true).some(({ fqn }) => fqn === iface.fqn)) { From 2eb82ed23df031b660ed7139766bce32672700b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Fri, 28 Jan 2022 12:25:56 +0100 Subject: [PATCH 13/18] remove type: ignore[misc] --- .../@jsii/python-runtime/src/jsii/_runtime.py | 5 +- packages/jsii-pacmak/lib/targets/python.ts | 15 +- .../__snapshots__/examples.test.ts.snap | 10 +- .../__snapshots__/target-python.test.ts.snap | 730 +++++++++--------- 4 files changed, 366 insertions(+), 394 deletions(-) diff --git a/packages/@jsii/python-runtime/src/jsii/_runtime.py b/packages/@jsii/python-runtime/src/jsii/_runtime.py index 0066fec7f8..67ba12a7ec 100644 --- a/packages/@jsii/python-runtime/src/jsii/_runtime.py +++ b/packages/@jsii/python-runtime/src/jsii/_runtime.py @@ -151,7 +151,10 @@ def deco(iface): return deco -def proxy_for(abstract_class: Type[Any]) -> Type[Any]: +T = TypeVar("T") + + +def proxy_for(abstract_class: Type[T]) -> Type[T]: if not hasattr(abstract_class, "__jsii_proxy_class__"): raise TypeError(f"{abstract_class} is not a JSII Abstract class.") diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index a330aafa67..405afc380b 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -624,7 +624,6 @@ abstract class BaseMethod implements PythonBase { const decorators = new Array(); if (this.jsName !== undefined) { - // "# type: ignore[misc]" needed because mypy does not know how to check decorated declarations decorators.push(`@jsii.member(jsii_name="${this.jsName}")`); } @@ -637,10 +636,7 @@ abstract class BaseMethod implements PythonBase { } if (decorators.length > 0) { - // "# type: ignore[misc]" needed because mypy does not know how to check decorated declarations - for (const decorator of decorators - .join(' # type: ignore[misc]\n') - .split('\n')) { + for (const decorator of decorators) { code.line(decorator); } } @@ -879,8 +875,7 @@ abstract class BaseProperty implements PythonBase { ) { const pythonType = toTypeName(this.type).pythonType(context); - // "# type: ignore[misc]" is needed because mypy cannot check decorated things - code.line(`@${this.decorator} # type: ignore[misc]`); + code.line(`@${this.decorator}`); code.line(`@jsii.member(jsii_name="${this.jsName}")`); if (renderAbstract && this.abstract) { code.line('@abc.abstractmethod'); @@ -976,11 +971,10 @@ class Interface extends BasePythonClassType { // Then, we have to emit a Proxy class which implements our proxy interface. const proxyBases: string[] = this.interfaces.map( (iface) => - // "# type: ignore[misc]" because MyPy cannot check dynamic base classes (naturally) `jsii.proxy_for(${toTypeName(iface).pythonType({ ...context, typeAnnotation: false, - })}) # type: ignore[misc]`, + })})`, ); openSignature(code, 'class', this.proxyClassName, proxyBases); this.generator.emitDocString(code, this.apiLocation, this.docs, { @@ -1390,12 +1384,11 @@ class Class extends BasePythonClassType implements ISortableType { const proxyBases = [this.pythonName]; for (const base of this.abstractBases) { - // "# type: ignore[misc]" because MyPy cannot check dynamic base classes (naturally) proxyBases.push( `jsii.proxy_for(${toTypeName(base).pythonType({ ...context, typeAnnotation: false, - })}) # type: ignore[misc]`, + })})`, ); } diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap index a7d9046812..2cf4d61d47 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap @@ -1232,7 +1232,7 @@ from ._jsii import * class Consumer(metaclass=jsii.JSIIMeta, jsii_type="testpkg.Consumer"): - @jsii.member(jsii_name="consumeBaz") # type: ignore[misc] + @jsii.member(jsii_name="consumeBaz") @builtins.classmethod def consume_baz( cls, @@ -2572,13 +2572,13 @@ class Namespace1(metaclass=jsii.JSIIMeta, jsii_type="testpkg.Namespace1"): @jsii.interface(jsii_type="testpkg.Namespace1.IBar") class IBar(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="bar") @abc.abstractmethod def bar(self) -> builtins.str: ... - @jsii.member(jsii_name="method") # type: ignore[misc] + @jsii.member(jsii_name="method") @abc.abstractmethod def method(self) -> None: ... @@ -2587,7 +2587,7 @@ class Namespace1(metaclass=jsii.JSIIMeta, jsii_type="testpkg.Namespace1"): class _IBarProxy: __jsii_type__: typing.ClassVar[str] = "testpkg.Namespace1.IBar" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="bar") def bar(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "bar")) @@ -2616,7 +2616,7 @@ class Namespace2(metaclass=jsii.JSIIMeta, jsii_type="testpkg.Namespace2"): def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="done") def done(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "done")) diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index e63bf36c47..9c5a175b76 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -402,14 +402,14 @@ class IBaseInterface( *(() if type(scope.jsii_calc_base_of_base.IVeryBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base_of_base.IVeryBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): - @jsii.member(jsii_name="bar") # type: ignore[misc] + @jsii.member(jsii_name="bar") @abc.abstractmethod def bar(self) -> None: ... class _IBaseInterfaceProxy( - jsii.proxy_for(scope.jsii_calc_base_of_base.IVeryBaseInterface), # type: ignore[misc] + jsii.proxy_for(scope.jsii_calc_base_of_base.IVeryBaseInterface), ): __jsii_type__: typing.ClassVar[str] = "@scope/jsii-calc-base.IBaseInterface" @@ -430,7 +430,7 @@ class StaticConsumer( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="consume") # type: ignore[misc] + @jsii.member(jsii_name="consume") @builtins.classmethod def consume(cls, *args: typing.Any) -> None: ''' @@ -811,7 +811,7 @@ from ._jsii import * @jsii.interface(jsii_type="@scope/jsii-calc-base-of-base.IVeryBaseInterface") class IVeryBaseInterface(metaclass = jsii.JSIIAbstractClass): - @jsii.member(jsii_name="foo") # type: ignore[misc] + @jsii.member(jsii_name="foo") @abc.abstractmethod def foo(self) -> None: ... @@ -832,7 +832,7 @@ class StaticConsumer( metaclass=jsii.JSIIMeta, jsii_type="@scope/jsii-calc-base-of-base.StaticConsumer", ): - @jsii.member(jsii_name="consume") # type: ignore[misc] + @jsii.member(jsii_name="consume") @builtins.classmethod def consume(cls, *_args: typing.Any) -> None: ''' @@ -1432,7 +1432,7 @@ class IDoublable(metaclass = jsii.JSIIAbstractClass): :stability: deprecated ''' - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="doubleValue") @abc.abstractmethod def double_value(self) -> jsii.Number: @@ -1450,7 +1450,7 @@ class _IDoublableProxy: __jsii_type__: typing.ClassVar[str] = "@scope/jsii-calc-lib.IDoublable" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="doubleValue") def double_value(self) -> jsii.Number: ''' @@ -1472,7 +1472,7 @@ class IFriendly(metaclass = jsii.JSIIAbstractClass): :stability: deprecated ''' - @jsii.member(jsii_name="hello") # type: ignore[misc] + @jsii.member(jsii_name="hello") @abc.abstractmethod def hello(self) -> builtins.str: '''(deprecated) Say hello! @@ -1519,7 +1519,7 @@ class IThreeLevelsInterface( :stability: deprecated ''' - @jsii.member(jsii_name="baz") # type: ignore[misc] + @jsii.member(jsii_name="baz") @abc.abstractmethod def baz(self) -> None: ''' @@ -1528,9 +1528,7 @@ class IThreeLevelsInterface( ... -class _IThreeLevelsInterfaceProxy( - jsii.proxy_for(scope.jsii_calc_base.IBaseInterface) # type: ignore[misc] -): +class _IThreeLevelsInterfaceProxy(jsii.proxy_for(scope.jsii_calc_base.IBaseInterface)): '''(deprecated) Interface that inherits from packages 2 levels up the tree. Their presence validates that .NET/Java/jsii-reflect can track all fields @@ -1645,7 +1643,7 @@ class NumericValue( ''' return typing.cast(builtins.str, jsii.invoke(self, "toString", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") @abc.abstractmethod def value(self) -> jsii.Number: @@ -1656,10 +1654,8 @@ class NumericValue( ... -class _NumericValueProxy( - NumericValue, jsii.proxy_for(scope.jsii_calc_base.Base) # type: ignore[misc] -): - @builtins.property # type: ignore[misc] +class _NumericValueProxy(NumericValue, jsii.proxy_for(scope.jsii_calc_base.Base)): + @builtins.property @jsii.member(jsii_name="value") def value(self) -> jsii.Number: '''(deprecated) The value. @@ -1685,7 +1681,7 @@ class Operation( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="toString") # type: ignore[misc] + @jsii.member(jsii_name="toString") @abc.abstractmethod def to_string(self) -> builtins.str: '''(deprecated) String representation of the value. @@ -1695,9 +1691,7 @@ class Operation( ... -class _OperationProxy( - Operation, jsii.proxy_for(NumericValue) # type: ignore[misc] -): +class _OperationProxy(Operation, jsii.proxy_for(NumericValue)): @jsii.member(jsii_name="toString") def to_string(self) -> builtins.str: '''(deprecated) String representation of the value. @@ -1800,7 +1794,7 @@ class Number( ''' jsii.create(self.__class__, self, [value]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="doubleValue") def double_value(self) -> jsii.Number: '''(deprecated) The number multiplied by 2. @@ -1809,7 +1803,7 @@ class Number( ''' return typing.cast(jsii.Number, jsii.get(self, "doubleValue")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") def value(self) -> jsii.Number: '''(deprecated) The number. @@ -1894,7 +1888,7 @@ class IReflectable(metaclass = jsii.JSIIAbstractClass): :stability: deprecated ''' - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="entries") @abc.abstractmethod def entries(self) -> typing.List["ReflectableEntry"]: @@ -1911,7 +1905,7 @@ class _IReflectableProxy: __jsii_type__: typing.ClassVar[str] = "@scope/jsii-calc-lib.submodule.IReflectable" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="entries") def entries(self) -> typing.List["ReflectableEntry"]: ''' @@ -1947,7 +1941,7 @@ class NestingClass( ''' jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="property") def property(self) -> builtins.str: ''' @@ -2577,7 +2571,7 @@ class AbstractClassBase( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="abstractProperty") @abc.abstractmethod def abstract_property(self) -> builtins.str: @@ -2585,7 +2579,7 @@ class AbstractClassBase( class _AbstractClassBaseProxy(AbstractClassBase): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="abstractProperty") def abstract_property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "abstractProperty")) @@ -2609,7 +2603,7 @@ class AbstractClassReturner( def give_me_interface(self) -> "IInterfaceImplementedByAbstractClass": return typing.cast("IInterfaceImplementedByAbstractClass", jsii.invoke(self, "giveMeInterface", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="returnAbstractFromProperty") def return_abstract_from_property(self) -> AbstractClassBase: return typing.cast(AbstractClassBase, jsii.get(self, "returnAbstractFromProperty")) @@ -2624,7 +2618,7 @@ class AbstractSuite( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="someMethod") # type: ignore[misc] + @jsii.member(jsii_name="someMethod") @abc.abstractmethod def _some_method(self, str: builtins.str) -> builtins.str: ''' @@ -2640,7 +2634,7 @@ class AbstractSuite( ''' return typing.cast(builtins.str, jsii.invoke(self, "workItAll", [seed])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="property") @abc.abstractmethod def _property(self) -> builtins.str: @@ -2660,7 +2654,7 @@ class _AbstractSuiteProxy(AbstractSuite): ''' return typing.cast(builtins.str, jsii.invoke(self, "someMethod", [str])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="property") def _property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "property")) @@ -2701,12 +2695,12 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): ''' return typing.cast("StringEnum", jsii.invoke(self, "enumMethod", [value])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="enumPropertyValue") def enum_property_value(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "enumPropertyValue")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="anyArrayProperty") def any_array_property(self) -> typing.List[typing.Any]: return typing.cast(typing.List[typing.Any], jsii.get(self, "anyArrayProperty")) @@ -2715,7 +2709,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def any_array_property(self, value: typing.List[typing.Any]) -> None: jsii.set(self, "anyArrayProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="anyMapProperty") def any_map_property(self) -> typing.Mapping[builtins.str, typing.Any]: return typing.cast(typing.Mapping[builtins.str, typing.Any], jsii.get(self, "anyMapProperty")) @@ -2724,7 +2718,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def any_map_property(self, value: typing.Mapping[builtins.str, typing.Any]) -> None: jsii.set(self, "anyMapProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="anyProperty") def any_property(self) -> typing.Any: return typing.cast(typing.Any, jsii.get(self, "anyProperty")) @@ -2733,7 +2727,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def any_property(self, value: typing.Any) -> None: jsii.set(self, "anyProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="arrayProperty") def array_property(self) -> typing.List[builtins.str]: return typing.cast(typing.List[builtins.str], jsii.get(self, "arrayProperty")) @@ -2742,7 +2736,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def array_property(self, value: typing.List[builtins.str]) -> None: jsii.set(self, "arrayProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="booleanProperty") def boolean_property(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "booleanProperty")) @@ -2751,7 +2745,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def boolean_property(self, value: builtins.bool) -> None: jsii.set(self, "booleanProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="dateProperty") def date_property(self) -> datetime.datetime: return typing.cast(datetime.datetime, jsii.get(self, "dateProperty")) @@ -2760,7 +2754,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def date_property(self, value: datetime.datetime) -> None: jsii.set(self, "dateProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="enumProperty") def enum_property(self) -> "AllTypesEnum": return typing.cast("AllTypesEnum", jsii.get(self, "enumProperty")) @@ -2769,7 +2763,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def enum_property(self, value: "AllTypesEnum") -> None: jsii.set(self, "enumProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="jsonProperty") def json_property(self) -> typing.Mapping[typing.Any, typing.Any]: return typing.cast(typing.Mapping[typing.Any, typing.Any], jsii.get(self, "jsonProperty")) @@ -2778,7 +2772,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def json_property(self, value: typing.Mapping[typing.Any, typing.Any]) -> None: jsii.set(self, "jsonProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mapProperty") def map_property(self) -> typing.Mapping[builtins.str, scope.jsii_calc_lib.Number]: return typing.cast(typing.Mapping[builtins.str, scope.jsii_calc_lib.Number], jsii.get(self, "mapProperty")) @@ -2790,7 +2784,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): ) -> None: jsii.set(self, "mapProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="numberProperty") def number_property(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "numberProperty")) @@ -2799,7 +2793,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def number_property(self, value: jsii.Number) -> None: jsii.set(self, "numberProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="stringProperty") def string_property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "stringProperty")) @@ -2808,7 +2802,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def string_property(self, value: builtins.str) -> None: jsii.set(self, "stringProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="unionArrayProperty") def union_array_property( self, @@ -2822,7 +2816,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): ) -> None: jsii.set(self, "unionArrayProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="unionMapProperty") def union_map_property( self, @@ -2836,7 +2830,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): ) -> None: jsii.set(self, "unionMapProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="unionProperty") def union_property( self, @@ -2850,7 +2844,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): ) -> None: jsii.set(self, "unionProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="unknownArrayProperty") def unknown_array_property(self) -> typing.List[typing.Any]: return typing.cast(typing.List[typing.Any], jsii.get(self, "unknownArrayProperty")) @@ -2859,7 +2853,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def unknown_array_property(self, value: typing.List[typing.Any]) -> None: jsii.set(self, "unknownArrayProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="unknownMapProperty") def unknown_map_property(self) -> typing.Mapping[builtins.str, typing.Any]: return typing.cast(typing.Mapping[builtins.str, typing.Any], jsii.get(self, "unknownMapProperty")) @@ -2871,7 +2865,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): ) -> None: jsii.set(self, "unknownMapProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="unknownProperty") def unknown_property(self) -> typing.Any: return typing.cast(typing.Any, jsii.get(self, "unknownProperty")) @@ -2880,7 +2874,7 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): def unknown_property(self, value: typing.Any) -> None: jsii.set(self, "unknownProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="optionalEnumValue") def optional_enum_value(self) -> typing.Optional["StringEnum"]: return typing.cast(typing.Optional["StringEnum"], jsii.get(self, "optionalEnumValue")) @@ -2959,12 +2953,12 @@ class AmbiguousParameters( jsii.create(self.__class__, self, [scope_, props_]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="props") def props(self) -> "StructParameterType": return typing.cast("StructParameterType", jsii.get(self, "props")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="scope") def scope(self) -> "Bell": return typing.cast("Bell", jsii.get(self, "scope")) @@ -3055,13 +3049,13 @@ class BinaryOperation( '''(deprecated) Say hello!''' return typing.cast(builtins.str, jsii.invoke(self, "hello", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="lhs") def lhs(self) -> scope.jsii_calc_lib.NumericValue: '''Left-hand side operand.''' return typing.cast(scope.jsii_calc_lib.NumericValue, jsii.get(self, "lhs")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="rhs") def rhs(self) -> scope.jsii_calc_lib.NumericValue: '''Right-hand side operand.''' @@ -3069,7 +3063,8 @@ class BinaryOperation( class _BinaryOperationProxy( - BinaryOperation, jsii.proxy_for(scope.jsii_calc_lib.Operation) # type: ignore[misc] + BinaryOperation, + jsii.proxy_for(scope.jsii_calc_lib.Operation), ): pass @@ -3090,7 +3085,7 @@ class BurriedAnonymousObject( def check(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.invoke(self, "check", [])) - @jsii.member(jsii_name="giveItBack") # type: ignore[misc] + @jsii.member(jsii_name="giveItBack") @abc.abstractmethod def give_it_back(self, value: typing.Any) -> typing.Any: '''Implement this method and have it return it's parameter. @@ -3192,19 +3187,19 @@ class Calculator( '''Returns teh value of the union property (if defined).''' return typing.cast(jsii.Number, jsii.invoke(self, "readUnionValue", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="expression") def expression(self) -> scope.jsii_calc_lib.NumericValue: '''Returns the expression.''' return typing.cast(scope.jsii_calc_lib.NumericValue, jsii.get(self, "expression")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="operationsLog") def operations_log(self) -> typing.List[scope.jsii_calc_lib.NumericValue]: '''A log of all operations.''' return typing.cast(typing.List[scope.jsii_calc_lib.NumericValue], jsii.get(self, "operationsLog")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="operationsMap") def operations_map( self, @@ -3212,7 +3207,7 @@ class Calculator( '''A map of per operation name of all operations performed.''' return typing.cast(typing.Mapping[builtins.str, typing.List[scope.jsii_calc_lib.NumericValue]], jsii.get(self, "operationsMap")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="curr") def curr(self) -> scope.jsii_calc_lib.NumericValue: '''The current value.''' @@ -3222,7 +3217,7 @@ class Calculator( def curr(self, value: scope.jsii_calc_lib.NumericValue) -> None: jsii.set(self, "curr", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="maxValue") def max_value(self) -> typing.Optional[jsii.Number]: '''The maximum value allows in this calculator.''' @@ -3232,7 +3227,7 @@ class Calculator( def max_value(self, value: typing.Optional[jsii.Number]) -> None: jsii.set(self, "maxValue", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="unionProperty") def union_property( self, @@ -3318,17 +3313,17 @@ class ClassWithCollections( ''' jsii.create(self.__class__, self, [map, array]) - @jsii.member(jsii_name="createAList") # type: ignore[misc] + @jsii.member(jsii_name="createAList") @builtins.classmethod def create_a_list(cls) -> typing.List[builtins.str]: return typing.cast(typing.List[builtins.str], jsii.sinvoke(cls, "createAList", [])) - @jsii.member(jsii_name="createAMap") # type: ignore[misc] + @jsii.member(jsii_name="createAMap") @builtins.classmethod def create_a_map(cls) -> typing.Mapping[builtins.str, builtins.str]: return typing.cast(typing.Mapping[builtins.str, builtins.str], jsii.sinvoke(cls, "createAMap", [])) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="staticArray") def static_array(cls) -> typing.List[builtins.str]: return typing.cast(typing.List[builtins.str], jsii.sget(cls, "staticArray")) @@ -3337,7 +3332,7 @@ class ClassWithCollections( def static_array(cls, value: typing.List[builtins.str]) -> None: jsii.sset(cls, "staticArray", value) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="staticMap") def static_map(cls) -> typing.Mapping[builtins.str, builtins.str]: return typing.cast(typing.Mapping[builtins.str, builtins.str], jsii.sget(cls, "staticMap")) @@ -3346,7 +3341,7 @@ class ClassWithCollections( def static_map(cls, value: typing.Mapping[builtins.str, builtins.str]) -> None: jsii.sset(cls, "staticMap", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="array") def array(self) -> typing.List[builtins.str]: return typing.cast(typing.List[builtins.str], jsii.get(self, "array")) @@ -3355,7 +3350,7 @@ class ClassWithCollections( def array(self, value: typing.List[builtins.str]) -> None: jsii.set(self, "array", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="map") def map(self) -> typing.Mapping[builtins.str, builtins.str]: return typing.cast(typing.Mapping[builtins.str, builtins.str], jsii.get(self, "map")) @@ -3393,22 +3388,22 @@ class ClassWithContainerTypes( jsii.create(self.__class__, self, [array, record, obj, props]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="array") def array(self) -> typing.List["DummyObj"]: return typing.cast(typing.List["DummyObj"], jsii.get(self, "array")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="obj") def obj(self) -> typing.Mapping[builtins.str, "DummyObj"]: return typing.cast(typing.Mapping[builtins.str, "DummyObj"], jsii.get(self, "obj")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="record") def record(self) -> typing.Mapping[builtins.str, "DummyObj"]: return typing.cast(typing.Mapping[builtins.str, "DummyObj"], jsii.get(self, "record")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="props") def props(self) -> typing.Optional["ContainerProps"]: return typing.cast(typing.Optional["ContainerProps"], jsii.get(self, "props")) @@ -3449,7 +3444,7 @@ class ClassWithJavaReservedWords( ''' return typing.cast(builtins.str, jsii.invoke(self, "import", [assert_])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="int") def int(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "int")) @@ -3462,7 +3457,7 @@ class ClassWithMutableObjectLiteralProperty( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableObject") def mutable_object(self) -> "IMutableObjectLiteral": return typing.cast("IMutableObjectLiteral", jsii.get(self, "mutableObject")) @@ -3481,17 +3476,17 @@ class ConfusingToJackson( :see: https://github.com/aws/aws-cdk/issues/4080 ''' - @jsii.member(jsii_name="makeInstance") # type: ignore[misc] + @jsii.member(jsii_name="makeInstance") @builtins.classmethod def make_instance(cls) -> "ConfusingToJackson": return typing.cast("ConfusingToJackson", jsii.sinvoke(cls, "makeInstance", [])) - @jsii.member(jsii_name="makeStructInstance") # type: ignore[misc] + @jsii.member(jsii_name="makeStructInstance") @builtins.classmethod def make_struct_instance(cls) -> "ConfusingToJacksonStruct": return typing.cast("ConfusingToJacksonStruct", jsii.sinvoke(cls, "makeStructInstance", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="unionProperty") def union_property( self, @@ -3558,37 +3553,37 @@ class Constructors(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Constructors"): def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="hiddenInterface") # type: ignore[misc] + @jsii.member(jsii_name="hiddenInterface") @builtins.classmethod def hidden_interface(cls) -> "IPublicInterface": return typing.cast("IPublicInterface", jsii.sinvoke(cls, "hiddenInterface", [])) - @jsii.member(jsii_name="hiddenInterfaces") # type: ignore[misc] + @jsii.member(jsii_name="hiddenInterfaces") @builtins.classmethod def hidden_interfaces(cls) -> typing.List["IPublicInterface"]: return typing.cast(typing.List["IPublicInterface"], jsii.sinvoke(cls, "hiddenInterfaces", [])) - @jsii.member(jsii_name="hiddenSubInterfaces") # type: ignore[misc] + @jsii.member(jsii_name="hiddenSubInterfaces") @builtins.classmethod def hidden_sub_interfaces(cls) -> typing.List["IPublicInterface"]: return typing.cast(typing.List["IPublicInterface"], jsii.sinvoke(cls, "hiddenSubInterfaces", [])) - @jsii.member(jsii_name="makeClass") # type: ignore[misc] + @jsii.member(jsii_name="makeClass") @builtins.classmethod def make_class(cls) -> "PublicClass": return typing.cast("PublicClass", jsii.sinvoke(cls, "makeClass", [])) - @jsii.member(jsii_name="makeInterface") # type: ignore[misc] + @jsii.member(jsii_name="makeInterface") @builtins.classmethod def make_interface(cls) -> "IPublicInterface": return typing.cast("IPublicInterface", jsii.sinvoke(cls, "makeInterface", [])) - @jsii.member(jsii_name="makeInterface2") # type: ignore[misc] + @jsii.member(jsii_name="makeInterface2") @builtins.classmethod def make_interface2(cls) -> "IPublicInterface2": return typing.cast("IPublicInterface2", jsii.sinvoke(cls, "makeInterface2", [])) - @jsii.member(jsii_name="makeInterfaces") # type: ignore[misc] + @jsii.member(jsii_name="makeInterfaces") @builtins.classmethod def make_interfaces(cls) -> typing.List["IPublicInterface"]: return typing.cast(typing.List["IPublicInterface"], jsii.sinvoke(cls, "makeInterfaces", [])) @@ -3622,7 +3617,7 @@ class ConsumerCanRingBell( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="staticImplementedByObjectLiteral") # type: ignore[misc] + @jsii.member(jsii_name="staticImplementedByObjectLiteral") @builtins.classmethod def static_implemented_by_object_literal( cls, @@ -3636,7 +3631,7 @@ class ConsumerCanRingBell( ''' return typing.cast(builtins.bool, jsii.sinvoke(cls, "staticImplementedByObjectLiteral", [ringer])) - @jsii.member(jsii_name="staticImplementedByPrivateClass") # type: ignore[misc] + @jsii.member(jsii_name="staticImplementedByPrivateClass") @builtins.classmethod def static_implemented_by_private_class( cls, @@ -3650,7 +3645,7 @@ class ConsumerCanRingBell( ''' return typing.cast(builtins.bool, jsii.sinvoke(cls, "staticImplementedByPrivateClass", [ringer])) - @jsii.member(jsii_name="staticImplementedByPublicClass") # type: ignore[misc] + @jsii.member(jsii_name="staticImplementedByPublicClass") @builtins.classmethod def static_implemented_by_public_class(cls, ringer: "IBellRinger") -> builtins.bool: '''...if the interface is implemented using a public class. @@ -3661,7 +3656,7 @@ class ConsumerCanRingBell( ''' return typing.cast(builtins.bool, jsii.sinvoke(cls, "staticImplementedByPublicClass", [ringer])) - @jsii.member(jsii_name="staticWhenTypedAsClass") # type: ignore[misc] + @jsii.member(jsii_name="staticWhenTypedAsClass") @builtins.classmethod def static_when_typed_as_class(cls, ringer: "IConcreteBellRinger") -> builtins.bool: '''If the parameter is a concrete class instead of an interface. @@ -3873,17 +3868,17 @@ class DefaultedConstructorArgument( ''' jsii.create(self.__class__, self, [arg1, arg2, arg3]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="arg1") def arg1(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "arg1")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="arg3") def arg3(self) -> datetime.datetime: return typing.cast(datetime.datetime, jsii.get(self, "arg3")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="arg2") def arg2(self) -> typing.Optional[builtins.str]: return typing.cast(typing.Optional[builtins.str], jsii.get(self, "arg2")) @@ -3899,13 +3894,13 @@ class Demonstrate982(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Demonstrate98 def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="takeThis") # type: ignore[misc] + @jsii.member(jsii_name="takeThis") @builtins.classmethod def take_this(cls) -> "ChildStruct982": '''It's dangerous to go alone!''' return typing.cast("ChildStruct982", jsii.sinvoke(cls, "takeThis", [])) - @jsii.member(jsii_name="takeThisToo") # type: ignore[misc] + @jsii.member(jsii_name="takeThisToo") @builtins.classmethod def take_this_too(cls) -> "ParentStruct982": '''It's dangerous to go alone!''' @@ -3943,7 +3938,7 @@ class DeprecatedClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DeprecatedCl ''' return typing.cast(None, jsii.invoke(self, "method", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readonlyProperty") def readonly_property(self) -> builtins.str: ''' @@ -3953,7 +3948,7 @@ class DeprecatedClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DeprecatedCl ''' return typing.cast(builtins.str, jsii.get(self, "readonlyProperty")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") def mutable_property(self) -> typing.Optional[jsii.Number]: ''' @@ -4453,7 +4448,7 @@ class DisappointingCollectionSource( This source of collections is disappointing - it'll always give you nothing :( ''' - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="maybeList") def MAYBE_LIST(cls) -> typing.Optional[typing.List[builtins.str]]: '''Some List of strings, maybe? @@ -4462,7 +4457,7 @@ class DisappointingCollectionSource( ''' return typing.cast(typing.Optional[typing.List[builtins.str]], jsii.sget(cls, "maybeList")) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="maybeMap") def MAYBE_MAP(cls) -> typing.Optional[typing.Mapping[builtins.str, jsii.Number]]: '''Some Map of strings to numbers, maybe? @@ -4631,7 +4626,7 @@ class DynamicPropertyBearer( ''' jsii.create(self.__class__, self, [value_store]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="dynamicProperty") def dynamic_property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "dynamicProperty")) @@ -4640,7 +4635,7 @@ class DynamicPropertyBearer( def dynamic_property(self, value: builtins.str) -> None: jsii.set(self, "dynamicProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="valueStore") def value_store(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "valueStore")) @@ -4671,7 +4666,7 @@ class DynamicPropertyBearerChild( ''' return typing.cast(builtins.str, jsii.invoke(self, "overrideValue", [new_value])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="originalValue") def original_value(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "originalValue")) @@ -4695,7 +4690,7 @@ class Entropy(metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.Entropy"): ''' return typing.cast(builtins.str, jsii.invoke(self, "increase", [])) - @jsii.member(jsii_name="repeat") # type: ignore[misc] + @jsii.member(jsii_name="repeat") @abc.abstractmethod def repeat(self, word: builtins.str) -> builtins.str: '''Implement this method such that it returns \`\`word\`\`. @@ -4723,12 +4718,12 @@ typing.cast(typing.Any, Entropy).__jsii_proxy_class__ = lambda : _EntropyProxy class EnumDispenser(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.EnumDispenser"): - @jsii.member(jsii_name="randomIntegerLikeEnum") # type: ignore[misc] + @jsii.member(jsii_name="randomIntegerLikeEnum") @builtins.classmethod def random_integer_like_enum(cls) -> AllTypesEnum: return typing.cast(AllTypesEnum, jsii.sinvoke(cls, "randomIntegerLikeEnum", [])) - @jsii.member(jsii_name="randomStringLikeEnum") # type: ignore[misc] + @jsii.member(jsii_name="randomStringLikeEnum") @builtins.classmethod def random_string_like_enum(cls) -> "StringEnum": return typing.cast("StringEnum", jsii.sinvoke(cls, "randomStringLikeEnum", [])) @@ -4741,7 +4736,7 @@ class EraseUndefinedHashValues( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="doesKeyExist") # type: ignore[misc] + @jsii.member(jsii_name="doesKeyExist") @builtins.classmethod def does_key_exist( cls, @@ -4758,13 +4753,13 @@ class EraseUndefinedHashValues( ''' return typing.cast(builtins.bool, jsii.sinvoke(cls, "doesKeyExist", [opts, key])) - @jsii.member(jsii_name="prop1IsNull") # type: ignore[misc] + @jsii.member(jsii_name="prop1IsNull") @builtins.classmethod def prop1_is_null(cls) -> typing.Mapping[builtins.str, typing.Any]: '''We expect "prop1" to be erased.''' return typing.cast(typing.Mapping[builtins.str, typing.Any], jsii.sinvoke(cls, "prop1IsNull", [])) - @jsii.member(jsii_name="prop2IsUndefined") # type: ignore[misc] + @jsii.member(jsii_name="prop2IsUndefined") @builtins.classmethod def prop2_is_undefined(cls) -> typing.Mapping[builtins.str, typing.Any]: '''We expect "prop2" to be erased.''' @@ -4843,7 +4838,7 @@ class ExperimentalClass( ''' return typing.cast(None, jsii.invoke(self, "method", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readonlyProperty") def readonly_property(self) -> builtins.str: ''' @@ -4851,7 +4846,7 @@ class ExperimentalClass( ''' return typing.cast(builtins.str, jsii.get(self, "readonlyProperty")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") def mutable_property(self) -> typing.Optional[jsii.Number]: ''' @@ -4927,7 +4922,7 @@ class ExportedBaseClass( ''' jsii.create(self.__class__, self, [success]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="success") def success(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "success")) @@ -4998,7 +4993,7 @@ class ExternalClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ExternalClass" ''' return typing.cast(None, jsii.invoke(self, "method", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readonlyProperty") def readonly_property(self) -> builtins.str: ''' @@ -5006,7 +5001,7 @@ class ExternalClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ExternalClass" ''' return typing.cast(builtins.str, jsii.get(self, "readonlyProperty")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") def mutable_property(self) -> typing.Optional[jsii.Number]: ''' @@ -5176,7 +5171,7 @@ class GiveMeStructs(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.GiveMeStructs" return typing.cast(jsii.Number, jsii.invoke(self, "readFirstNumber", [first])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="structLiteral") def struct_literal(self) -> scope.jsii_calc_lib.StructWithOnlyOptionals: return typing.cast(scope.jsii_calc_lib.StructWithOnlyOptionals, jsii.get(self, "structLiteral")) @@ -5237,12 +5232,12 @@ class GreetingAugmenter( class IAnonymousImplementationProvider(metaclass = jsii.JSIIAbstractClass): '''We can return an anonymous interface implementation from an override without losing the interface declarations.''' - @jsii.member(jsii_name="provideAsClass") # type: ignore[misc] + @jsii.member(jsii_name="provideAsClass") @abc.abstractmethod def provide_as_class(self) -> "Implementation": ... - @jsii.member(jsii_name="provideAsInterface") # type: ignore[misc] + @jsii.member(jsii_name="provideAsInterface") @abc.abstractmethod def provide_as_interface(self) -> "IAnonymouslyImplementMe": ... @@ -5267,13 +5262,13 @@ typing.cast(typing.Any, IAnonymousImplementationProvider).__jsii_proxy_class__ = @jsii.interface(jsii_type="jsii-calc.IAnonymouslyImplementMe") class IAnonymouslyImplementMe(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") @abc.abstractmethod def value(self) -> jsii.Number: ... - @jsii.member(jsii_name="verb") # type: ignore[misc] + @jsii.member(jsii_name="verb") @abc.abstractmethod def verb(self) -> builtins.str: ... @@ -5282,7 +5277,7 @@ class IAnonymouslyImplementMe(metaclass = jsii.JSIIAbstractClass): class _IAnonymouslyImplementMeProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IAnonymouslyImplementMe" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") def value(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "value")) @@ -5297,7 +5292,7 @@ typing.cast(typing.Any, IAnonymouslyImplementMe).__jsii_proxy_class__ = lambda : @jsii.interface(jsii_type="jsii-calc.IAnotherPublicInterface") class IAnotherPublicInterface(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="a") @abc.abstractmethod def a(self) -> builtins.str: @@ -5312,7 +5307,7 @@ class IAnotherPublicInterface(metaclass = jsii.JSIIAbstractClass): class _IAnotherPublicInterfaceProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IAnotherPublicInterface" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="a") def a(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "a")) @@ -5327,7 +5322,7 @@ typing.cast(typing.Any, IAnotherPublicInterface).__jsii_proxy_class__ = lambda : @jsii.interface(jsii_type="jsii-calc.IBell") class IBell(metaclass = jsii.JSIIAbstractClass): - @jsii.member(jsii_name="ring") # type: ignore[misc] + @jsii.member(jsii_name="ring") @abc.abstractmethod def ring(self) -> None: ... @@ -5348,7 +5343,7 @@ typing.cast(typing.Any, IBell).__jsii_proxy_class__ = lambda : _IBellProxy class IBellRinger(metaclass = jsii.JSIIAbstractClass): '''Takes the object parameter as an interface.''' - @jsii.member(jsii_name="yourTurn") # type: ignore[misc] + @jsii.member(jsii_name="yourTurn") @abc.abstractmethod def your_turn(self, bell: IBell) -> None: ''' @@ -5377,7 +5372,7 @@ typing.cast(typing.Any, IBellRinger).__jsii_proxy_class__ = lambda : _IBellRinge class IConcreteBellRinger(metaclass = jsii.JSIIAbstractClass): '''Takes the object parameter as a calss.''' - @jsii.member(jsii_name="yourTurn") # type: ignore[misc] + @jsii.member(jsii_name="yourTurn") @abc.abstractmethod def your_turn(self, bell: "Bell") -> None: ''' @@ -5410,7 +5405,7 @@ class IDeprecatedInterface(metaclass = jsii.JSIIAbstractClass): :stability: deprecated ''' - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") @abc.abstractmethod def mutable_property(self) -> typing.Optional[jsii.Number]: @@ -5426,7 +5421,7 @@ class IDeprecatedInterface(metaclass = jsii.JSIIAbstractClass): def mutable_property(self, value: typing.Optional[jsii.Number]) -> None: ... - @jsii.member(jsii_name="method") # type: ignore[misc] + @jsii.member(jsii_name="method") @abc.abstractmethod def method(self) -> None: ''' @@ -5446,7 +5441,7 @@ class _IDeprecatedInterfaceProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IDeprecatedInterface" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") def mutable_property(self) -> typing.Optional[jsii.Number]: ''' @@ -5479,7 +5474,7 @@ class IExperimentalInterface(metaclass = jsii.JSIIAbstractClass): :stability: experimental ''' - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") @abc.abstractmethod def mutable_property(self) -> typing.Optional[jsii.Number]: @@ -5493,7 +5488,7 @@ class IExperimentalInterface(metaclass = jsii.JSIIAbstractClass): def mutable_property(self, value: typing.Optional[jsii.Number]) -> None: ... - @jsii.member(jsii_name="method") # type: ignore[misc] + @jsii.member(jsii_name="method") @abc.abstractmethod def method(self) -> None: ''' @@ -5509,7 +5504,7 @@ class _IExperimentalInterfaceProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IExperimentalInterface" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") def mutable_property(self) -> typing.Optional[jsii.Number]: ''' @@ -5534,13 +5529,13 @@ typing.cast(typing.Any, IExperimentalInterface).__jsii_proxy_class__ = lambda : @jsii.interface(jsii_type="jsii-calc.IExtendsPrivateInterface") class IExtendsPrivateInterface(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="moreThings") @abc.abstractmethod def more_things(self) -> typing.List[builtins.str]: ... - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="private") @abc.abstractmethod def private(self) -> builtins.str: @@ -5555,12 +5550,12 @@ class IExtendsPrivateInterface(metaclass = jsii.JSIIAbstractClass): class _IExtendsPrivateInterfaceProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IExtendsPrivateInterface" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="moreThings") def more_things(self) -> typing.List[builtins.str]: return typing.cast(typing.List[builtins.str], jsii.get(self, "moreThings")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="private") def private(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "private")) @@ -5579,7 +5574,7 @@ class IExternalInterface(metaclass = jsii.JSIIAbstractClass): :external: true ''' - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") @abc.abstractmethod def mutable_property(self) -> typing.Optional[jsii.Number]: @@ -5593,7 +5588,7 @@ class IExternalInterface(metaclass = jsii.JSIIAbstractClass): def mutable_property(self, value: typing.Optional[jsii.Number]) -> None: ... - @jsii.member(jsii_name="method") # type: ignore[misc] + @jsii.member(jsii_name="method") @abc.abstractmethod def method(self) -> None: ''' @@ -5609,7 +5604,7 @@ class _IExternalInterfaceProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IExternalInterface" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") def mutable_property(self) -> typing.Optional[jsii.Number]: ''' @@ -5640,13 +5635,13 @@ class IFriendlier( ): '''Even friendlier classes can implement this interface.''' - @jsii.member(jsii_name="farewell") # type: ignore[misc] + @jsii.member(jsii_name="farewell") @abc.abstractmethod def farewell(self) -> builtins.str: '''Say farewell.''' ... - @jsii.member(jsii_name="goodbye") # type: ignore[misc] + @jsii.member(jsii_name="goodbye") @abc.abstractmethod def goodbye(self) -> builtins.str: '''Say goodbye. @@ -5656,9 +5651,7 @@ class IFriendlier( ... -class _IFriendlierProxy( - jsii.proxy_for(scope.jsii_calc_lib.IFriendly) # type: ignore[misc] -): +class _IFriendlierProxy(jsii.proxy_for(scope.jsii_calc_lib.IFriendly)): '''Even friendlier classes can implement this interface.''' __jsii_type__: typing.ClassVar[str] = "jsii-calc.IFriendlier" @@ -5684,7 +5677,7 @@ typing.cast(typing.Any, IFriendlier).__jsii_proxy_class__ = lambda : _IFriendlie class IInterfaceImplementedByAbstractClass(metaclass = jsii.JSIIAbstractClass): '''awslabs/jsii#220 Abstract return type.''' - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="propFromInterface") @abc.abstractmethod def prop_from_interface(self) -> builtins.str: @@ -5696,7 +5689,7 @@ class _IInterfaceImplementedByAbstractClassProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IInterfaceImplementedByAbstractClass" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="propFromInterface") def prop_from_interface(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "propFromInterface")) @@ -5707,7 +5700,7 @@ typing.cast(typing.Any, IInterfaceImplementedByAbstractClass).__jsii_proxy_class @jsii.interface(jsii_type="jsii-calc.IInterfaceWithInternal") class IInterfaceWithInternal(metaclass = jsii.JSIIAbstractClass): - @jsii.member(jsii_name="visible") # type: ignore[misc] + @jsii.member(jsii_name="visible") @abc.abstractmethod def visible(self) -> None: ... @@ -5726,13 +5719,13 @@ typing.cast(typing.Any, IInterfaceWithInternal).__jsii_proxy_class__ = lambda : @jsii.interface(jsii_type="jsii-calc.IInterfaceWithMethods") class IInterfaceWithMethods(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") @abc.abstractmethod def value(self) -> builtins.str: ... - @jsii.member(jsii_name="doThings") # type: ignore[misc] + @jsii.member(jsii_name="doThings") @abc.abstractmethod def do_things(self) -> None: ... @@ -5741,7 +5734,7 @@ class IInterfaceWithMethods(metaclass = jsii.JSIIAbstractClass): class _IInterfaceWithMethodsProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IInterfaceWithMethods" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") def value(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "value")) @@ -5758,7 +5751,7 @@ typing.cast(typing.Any, IInterfaceWithMethods).__jsii_proxy_class__ = lambda : _ class IInterfaceWithOptionalMethodArguments(metaclass = jsii.JSIIAbstractClass): '''awslabs/jsii#175 Interface proxies (and builders) do not respect optional arguments in methods.''' - @jsii.member(jsii_name="hello") # type: ignore[misc] + @jsii.member(jsii_name="hello") @abc.abstractmethod def hello( self, @@ -5795,13 +5788,13 @@ typing.cast(typing.Any, IInterfaceWithOptionalMethodArguments).__jsii_proxy_clas @jsii.interface(jsii_type="jsii-calc.IInterfaceWithProperties") class IInterfaceWithProperties(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readOnlyString") @abc.abstractmethod def read_only_string(self) -> builtins.str: ... - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readWriteString") @abc.abstractmethod def read_write_string(self) -> builtins.str: @@ -5816,12 +5809,12 @@ class IInterfaceWithProperties(metaclass = jsii.JSIIAbstractClass): class _IInterfaceWithPropertiesProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IInterfaceWithProperties" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readOnlyString") def read_only_string(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "readOnlyString")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readWriteString") def read_write_string(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "readWriteString")) @@ -5839,7 +5832,7 @@ class IInterfaceWithPropertiesExtension( IInterfaceWithProperties, metaclass = jsii.JSIIAbstractClass, ): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="foo") @abc.abstractmethod def foo(self) -> jsii.Number: @@ -5851,12 +5844,10 @@ class IInterfaceWithPropertiesExtension( ... -class _IInterfaceWithPropertiesExtensionProxy( - jsii.proxy_for(IInterfaceWithProperties) # type: ignore[misc] -): +class _IInterfaceWithPropertiesExtensionProxy(jsii.proxy_for(IInterfaceWithProperties)): __jsii_type__: typing.ClassVar[str] = "jsii-calc.IInterfaceWithPropertiesExtension" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="foo") def foo(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "foo")) @@ -5871,13 +5862,13 @@ typing.cast(typing.Any, IInterfaceWithPropertiesExtension).__jsii_proxy_class__ @jsii.interface(jsii_type="jsii-calc.IJSII417PublicBaseOfBase") class IJSII417PublicBaseOfBase(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="hasRoot") @abc.abstractmethod def has_root(self) -> builtins.bool: ... - @jsii.member(jsii_name="foo") # type: ignore[misc] + @jsii.member(jsii_name="foo") @abc.abstractmethod def foo(self) -> None: ... @@ -5886,7 +5877,7 @@ class IJSII417PublicBaseOfBase(metaclass = jsii.JSIIAbstractClass): class _IJSII417PublicBaseOfBaseProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IJSII417PublicBaseOfBase" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="hasRoot") def has_root(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "hasRoot")) @@ -5940,7 +5931,7 @@ typing.cast(typing.Any, IJsii496).__jsii_proxy_class__ = lambda : _IJsii496Proxy @jsii.interface(jsii_type="jsii-calc.IMutableObjectLiteral") class IMutableObjectLiteral(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") @abc.abstractmethod def value(self) -> builtins.str: @@ -5955,7 +5946,7 @@ class IMutableObjectLiteral(metaclass = jsii.JSIIAbstractClass): class _IMutableObjectLiteralProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IMutableObjectLiteral" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") def value(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "value")) @@ -5973,7 +5964,7 @@ class INonInternalInterface( IAnotherPublicInterface, metaclass = jsii.JSIIAbstractClass, ): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="b") @abc.abstractmethod def b(self) -> builtins.str: @@ -5984,7 +5975,7 @@ class INonInternalInterface( def b(self, value: builtins.str) -> None: ... - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="c") @abc.abstractmethod def c(self) -> builtins.str: @@ -5996,12 +5987,10 @@ class INonInternalInterface( ... -class _INonInternalInterfaceProxy( - jsii.proxy_for(IAnotherPublicInterface) # type: ignore[misc] -): +class _INonInternalInterfaceProxy(jsii.proxy_for(IAnotherPublicInterface)): __jsii_type__: typing.ClassVar[str] = "jsii-calc.INonInternalInterface" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="b") def b(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "b")) @@ -6010,7 +5999,7 @@ class _INonInternalInterfaceProxy( def b(self, value: builtins.str) -> None: jsii.set(self, "b", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="c") def c(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "c")) @@ -6027,7 +6016,7 @@ typing.cast(typing.Any, INonInternalInterface).__jsii_proxy_class__ = lambda : _ class IObjectWithProperty(metaclass = jsii.JSIIAbstractClass): '''Make sure that setters are properly called on objects with interfaces.''' - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="property") @abc.abstractmethod def property(self) -> builtins.str: @@ -6038,7 +6027,7 @@ class IObjectWithProperty(metaclass = jsii.JSIIAbstractClass): def property(self, value: builtins.str) -> None: ... - @jsii.member(jsii_name="wasSet") # type: ignore[misc] + @jsii.member(jsii_name="wasSet") @abc.abstractmethod def was_set(self) -> builtins.bool: ... @@ -6049,7 +6038,7 @@ class _IObjectWithPropertyProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IObjectWithProperty" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="property") def property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "property")) @@ -6070,7 +6059,7 @@ typing.cast(typing.Any, IObjectWithProperty).__jsii_proxy_class__ = lambda : _IO class IOptionalMethod(metaclass = jsii.JSIIAbstractClass): '''Checks that optional result from interface method code generates correctly.''' - @jsii.member(jsii_name="optional") # type: ignore[misc] + @jsii.member(jsii_name="optional") @abc.abstractmethod def optional(self) -> typing.Optional[builtins.str]: ... @@ -6091,7 +6080,7 @@ typing.cast(typing.Any, IOptionalMethod).__jsii_proxy_class__ = lambda : _IOptio @jsii.interface(jsii_type="jsii-calc.IPrivatelyImplemented") class IPrivatelyImplemented(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="success") @abc.abstractmethod def success(self) -> builtins.bool: @@ -6101,7 +6090,7 @@ class IPrivatelyImplemented(metaclass = jsii.JSIIAbstractClass): class _IPrivatelyImplementedProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IPrivatelyImplemented" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="success") def success(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "success")) @@ -6112,7 +6101,7 @@ typing.cast(typing.Any, IPrivatelyImplemented).__jsii_proxy_class__ = lambda : _ @jsii.interface(jsii_type="jsii-calc.IPublicInterface") class IPublicInterface(metaclass = jsii.JSIIAbstractClass): - @jsii.member(jsii_name="bye") # type: ignore[misc] + @jsii.member(jsii_name="bye") @abc.abstractmethod def bye(self) -> builtins.str: ... @@ -6131,7 +6120,7 @@ typing.cast(typing.Any, IPublicInterface).__jsii_proxy_class__ = lambda : _IPubl @jsii.interface(jsii_type="jsii-calc.IPublicInterface2") class IPublicInterface2(metaclass = jsii.JSIIAbstractClass): - @jsii.member(jsii_name="ciao") # type: ignore[misc] + @jsii.member(jsii_name="ciao") @abc.abstractmethod def ciao(self) -> builtins.str: ... @@ -6152,7 +6141,7 @@ typing.cast(typing.Any, IPublicInterface2).__jsii_proxy_class__ = lambda : _IPub class IRandomNumberGenerator(metaclass = jsii.JSIIAbstractClass): '''Generates random numbers.''' - @jsii.member(jsii_name="next") # type: ignore[misc] + @jsii.member(jsii_name="next") @abc.abstractmethod def next(self) -> jsii.Number: '''Returns another random number. @@ -6183,7 +6172,7 @@ typing.cast(typing.Any, IRandomNumberGenerator).__jsii_proxy_class__ = lambda : class IReturnJsii976(metaclass = jsii.JSIIAbstractClass): '''Returns a subclass of a known class which implements an interface.''' - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="foo") @abc.abstractmethod def foo(self) -> jsii.Number: @@ -6195,7 +6184,7 @@ class _IReturnJsii976Proxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IReturnJsii976" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="foo") def foo(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "foo")) @@ -6206,13 +6195,13 @@ typing.cast(typing.Any, IReturnJsii976).__jsii_proxy_class__ = lambda : _IReturn @jsii.interface(jsii_type="jsii-calc.IReturnsNumber") class IReturnsNumber(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="numberProp") @abc.abstractmethod def number_prop(self) -> scope.jsii_calc_lib.Number: ... - @jsii.member(jsii_name="obtainNumber") # type: ignore[misc] + @jsii.member(jsii_name="obtainNumber") @abc.abstractmethod def obtain_number(self) -> scope.jsii_calc_lib.IDoublable: ... @@ -6221,7 +6210,7 @@ class IReturnsNumber(metaclass = jsii.JSIIAbstractClass): class _IReturnsNumberProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IReturnsNumber" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="numberProp") def number_prop(self) -> scope.jsii_calc_lib.Number: return typing.cast(scope.jsii_calc_lib.Number, jsii.get(self, "numberProp")) @@ -6236,7 +6225,7 @@ typing.cast(typing.Any, IReturnsNumber).__jsii_proxy_class__ = lambda : _IReturn @jsii.interface(jsii_type="jsii-calc.IStableInterface") class IStableInterface(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") @abc.abstractmethod def mutable_property(self) -> typing.Optional[jsii.Number]: @@ -6247,7 +6236,7 @@ class IStableInterface(metaclass = jsii.JSIIAbstractClass): def mutable_property(self, value: typing.Optional[jsii.Number]) -> None: ... - @jsii.member(jsii_name="method") # type: ignore[misc] + @jsii.member(jsii_name="method") @abc.abstractmethod def method(self) -> None: ... @@ -6256,7 +6245,7 @@ class IStableInterface(metaclass = jsii.JSIIAbstractClass): class _IStableInterfaceProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.IStableInterface" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") def mutable_property(self) -> typing.Optional[jsii.Number]: return typing.cast(typing.Optional[jsii.Number], jsii.get(self, "mutableProperty")) @@ -6277,7 +6266,7 @@ typing.cast(typing.Any, IStableInterface).__jsii_proxy_class__ = lambda : _IStab class IStructReturningDelegate(metaclass = jsii.JSIIAbstractClass): '''Verifies that a "pure" implementation of an interface works correctly.''' - @jsii.member(jsii_name="returnStruct") # type: ignore[misc] + @jsii.member(jsii_name="returnStruct") @abc.abstractmethod def return_struct(self) -> "StructB": ... @@ -6300,7 +6289,7 @@ typing.cast(typing.Any, IStructReturningDelegate).__jsii_proxy_class__ = lambda class IWallClock(metaclass = jsii.JSIIAbstractClass): '''Implement this interface.''' - @jsii.member(jsii_name="iso8601Now") # type: ignore[misc] + @jsii.member(jsii_name="iso8601Now") @abc.abstractmethod def iso8601_now(self) -> builtins.str: '''Returns the current time, formatted as an ISO-8601 string.''' @@ -6328,7 +6317,7 @@ class ImplementInternalInterface( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="prop") def prop(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "prop")) @@ -6342,7 +6331,7 @@ class Implementation(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Implementatio def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") def value(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "value")) @@ -6377,7 +6366,7 @@ class ImplementsPrivateInterface( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="private") def private(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "private")) @@ -6450,22 +6439,22 @@ class InterfaceCollections( See: https://github.com/aws/jsii/issues/1196 ''' - @jsii.member(jsii_name="listOfInterfaces") # type: ignore[misc] + @jsii.member(jsii_name="listOfInterfaces") @builtins.classmethod def list_of_interfaces(cls) -> typing.List[IBell]: return typing.cast(typing.List[IBell], jsii.sinvoke(cls, "listOfInterfaces", [])) - @jsii.member(jsii_name="listOfStructs") # type: ignore[misc] + @jsii.member(jsii_name="listOfStructs") @builtins.classmethod def list_of_structs(cls) -> typing.List["StructA"]: return typing.cast(typing.List["StructA"], jsii.sinvoke(cls, "listOfStructs", [])) - @jsii.member(jsii_name="mapOfInterfaces") # type: ignore[misc] + @jsii.member(jsii_name="mapOfInterfaces") @builtins.classmethod def map_of_interfaces(cls) -> typing.Mapping[builtins.str, IBell]: return typing.cast(typing.Mapping[builtins.str, IBell], jsii.sinvoke(cls, "mapOfInterfaces", [])) - @jsii.member(jsii_name="mapOfStructs") # type: ignore[misc] + @jsii.member(jsii_name="mapOfStructs") @builtins.classmethod def map_of_structs(cls) -> typing.Mapping[builtins.str, "StructA"]: return typing.cast(typing.Mapping[builtins.str, "StructA"], jsii.sinvoke(cls, "mapOfStructs", [])) @@ -6474,7 +6463,7 @@ class InterfaceCollections( class InterfacesMaker(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.InterfacesMaker"): '''We can return arrays of interfaces See aws/aws-cdk#2362.''' - @jsii.member(jsii_name="makeInterfaces") # type: ignore[misc] + @jsii.member(jsii_name="makeInterfaces") @builtins.classmethod def make_interfaces( cls, @@ -6534,7 +6523,7 @@ class JSII417PublicBaseOfBase( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="makeInstance") # type: ignore[misc] + @jsii.member(jsii_name="makeInstance") @builtins.classmethod def make_instance(cls) -> "JSII417PublicBaseOfBase": return typing.cast("JSII417PublicBaseOfBase", jsii.sinvoke(cls, "makeInstance", [])) @@ -6543,7 +6532,7 @@ class JSII417PublicBaseOfBase( def foo(self) -> None: return typing.cast(None, jsii.invoke(self, "foo", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="hasRoot") def has_root(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "hasRoot")) @@ -6584,7 +6573,7 @@ class JSObjectLiteralToNativeClass( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="propA") def prop_a(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "propA")) @@ -6593,7 +6582,7 @@ class JSObjectLiteralToNativeClass( def prop_a(self, value: builtins.str) -> None: jsii.set(self, "propA", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="propB") def prop_b(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "propB")) @@ -6818,7 +6807,7 @@ class JavaReservedWords( def volatile(self) -> None: return typing.cast(None, jsii.invoke(self, "volatile", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="while") def while_(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "while")) @@ -6853,7 +6842,7 @@ class JsiiAgent(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.JsiiAgent"): def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="value") def value(cls) -> typing.Optional[builtins.str]: '''Returns the value of the JSII_AGENT environment variable.''' @@ -6866,72 +6855,72 @@ class JsonFormatter(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.JsonFormatter" :see: https://github.com/aws/aws-cdk/issues/5066 ''' - @jsii.member(jsii_name="anyArray") # type: ignore[misc] + @jsii.member(jsii_name="anyArray") @builtins.classmethod def any_array(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyArray", [])) - @jsii.member(jsii_name="anyBooleanFalse") # type: ignore[misc] + @jsii.member(jsii_name="anyBooleanFalse") @builtins.classmethod def any_boolean_false(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyBooleanFalse", [])) - @jsii.member(jsii_name="anyBooleanTrue") # type: ignore[misc] + @jsii.member(jsii_name="anyBooleanTrue") @builtins.classmethod def any_boolean_true(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyBooleanTrue", [])) - @jsii.member(jsii_name="anyDate") # type: ignore[misc] + @jsii.member(jsii_name="anyDate") @builtins.classmethod def any_date(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyDate", [])) - @jsii.member(jsii_name="anyEmptyString") # type: ignore[misc] + @jsii.member(jsii_name="anyEmptyString") @builtins.classmethod def any_empty_string(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyEmptyString", [])) - @jsii.member(jsii_name="anyFunction") # type: ignore[misc] + @jsii.member(jsii_name="anyFunction") @builtins.classmethod def any_function(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyFunction", [])) - @jsii.member(jsii_name="anyHash") # type: ignore[misc] + @jsii.member(jsii_name="anyHash") @builtins.classmethod def any_hash(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyHash", [])) - @jsii.member(jsii_name="anyNull") # type: ignore[misc] + @jsii.member(jsii_name="anyNull") @builtins.classmethod def any_null(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyNull", [])) - @jsii.member(jsii_name="anyNumber") # type: ignore[misc] + @jsii.member(jsii_name="anyNumber") @builtins.classmethod def any_number(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyNumber", [])) - @jsii.member(jsii_name="anyRef") # type: ignore[misc] + @jsii.member(jsii_name="anyRef") @builtins.classmethod def any_ref(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyRef", [])) - @jsii.member(jsii_name="anyString") # type: ignore[misc] + @jsii.member(jsii_name="anyString") @builtins.classmethod def any_string(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyString", [])) - @jsii.member(jsii_name="anyUndefined") # type: ignore[misc] + @jsii.member(jsii_name="anyUndefined") @builtins.classmethod def any_undefined(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyUndefined", [])) - @jsii.member(jsii_name="anyZero") # type: ignore[misc] + @jsii.member(jsii_name="anyZero") @builtins.classmethod def any_zero(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "anyZero", [])) - @jsii.member(jsii_name="stringify") # type: ignore[misc] + @jsii.member(jsii_name="stringify") @builtins.classmethod def stringify(cls, value: typing.Any = None) -> typing.Optional[builtins.str]: ''' @@ -6951,7 +6940,7 @@ class LevelOne(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.LevelOne"): jsii.create(self.__class__, self, [props]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="props") def props(self) -> "LevelOneProps": return typing.cast("LevelOneProps", jsii.get(self, "props")) @@ -7190,7 +7179,7 @@ class MethodNamedProperty( def property(self) -> builtins.str: return typing.cast(builtins.str, jsii.invoke(self, "property", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="elite") def elite(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "elite")) @@ -7237,7 +7226,7 @@ class Multiply( '''(deprecated) String representation of the value.''' return typing.cast(builtins.str, jsii.invoke(self, "toString", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") def value(self) -> jsii.Number: '''(deprecated) The value.''' @@ -7248,7 +7237,7 @@ class NestedClassInstance( metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.NestedClassInstance", ): - @jsii.member(jsii_name="makeInstance") # type: ignore[misc] + @jsii.member(jsii_name="makeInstance") @builtins.classmethod def make_instance( cls, @@ -7322,7 +7311,7 @@ class NodeStandardLibrary( ''' return typing.cast(builtins.str, jsii.invoke(self, "fsReadFileSync", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="osPlatform") def os_platform(self) -> builtins.str: '''Returns the current os.platform() from the "os" node module.''' @@ -7371,7 +7360,7 @@ class NullShouldBeTreatedAsUndefined( def verify_property_is_undefined(self) -> None: return typing.cast(None, jsii.invoke(self, "verifyPropertyIsUndefined", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="changeMeToUndefined") def change_me_to_undefined(self) -> typing.Optional[builtins.str]: return typing.cast(typing.Optional[builtins.str], jsii.get(self, "changeMeToUndefined")) @@ -7451,7 +7440,7 @@ class NumberGenerator(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.NumberGenera def next_times100(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.invoke(self, "nextTimes100", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="generator") def generator(self) -> IRandomNumberGenerator: return typing.cast(IRandomNumberGenerator, jsii.get(self, "generator")) @@ -7497,7 +7486,7 @@ class ObjectWithPropertyProvider( metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ObjectWithPropertyProvider", ): - @jsii.member(jsii_name="provide") # type: ignore[misc] + @jsii.member(jsii_name="provide") @builtins.classmethod def provide(cls) -> IObjectWithProperty: return typing.cast(IObjectWithProperty, jsii.sinvoke(cls, "provide", [])) @@ -7562,17 +7551,17 @@ class OptionalConstructorArgument( ''' jsii.create(self.__class__, self, [arg1, arg2, arg3]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="arg1") def arg1(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "arg1")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="arg2") def arg2(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "arg2")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="arg3") def arg3(self) -> typing.Optional[datetime.datetime]: return typing.cast(typing.Optional[datetime.datetime], jsii.get(self, "arg3")) @@ -7621,12 +7610,12 @@ class OptionalStructConsumer( jsii.create(self.__class__, self, [optional_struct]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="parameterWasUndefined") def parameter_was_undefined(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "parameterWasUndefined")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="fieldValue") def field_value(self) -> typing.Optional[builtins.str]: return typing.cast(typing.Optional[builtins.str], jsii.get(self, "fieldValue")) @@ -7655,12 +7644,12 @@ class OverridableProtectedMember( def value_from_protected(self) -> builtins.str: return typing.cast(builtins.str, jsii.invoke(self, "valueFromProtected", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="overrideReadOnly") def _override_read_only(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "overrideReadOnly")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="overrideReadWrite") def _override_read_write(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "overrideReadWrite")) @@ -7725,7 +7714,7 @@ class PartiallyInitializedThisConsumer( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="consumePartiallyInitializedThis") # type: ignore[misc] + @jsii.member(jsii_name="consumePartiallyInitializedThis") @abc.abstractmethod def consume_partially_initialized_this( self, @@ -7791,13 +7780,13 @@ class Power( ''' jsii.create(self.__class__, self, [base, pow]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="base") def base(self) -> scope.jsii_calc_lib.NumericValue: '''The base of the power.''' return typing.cast(scope.jsii_calc_lib.NumericValue, jsii.get(self, "base")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="expression") def expression(self) -> scope.jsii_calc_lib.NumericValue: '''The expression that this operation consists of. @@ -7806,7 +7795,7 @@ class Power( ''' return typing.cast(scope.jsii_calc_lib.NumericValue, jsii.get(self, "expression")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="pow") def pow(self) -> scope.jsii_calc_lib.NumericValue: '''The number of times to multiply.''' @@ -7822,12 +7811,12 @@ class PropertyNamedProperty( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="property") def property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "property")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="yetAnoterOne") def yet_anoter_one(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "yetAnoterOne")) @@ -7998,7 +7987,7 @@ class ReferenceEnumFromScopedPackage( ''' return typing.cast(None, jsii.invoke(self, "saveFoo", [value])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="foo") def foo(self) -> typing.Optional[scope.jsii_calc_lib.EnumFromScopedModule]: return typing.cast(typing.Optional[scope.jsii_calc_lib.EnumFromScopedModule], jsii.get(self, "foo")) @@ -8025,7 +8014,7 @@ class ReturnsPrivateImplementationOfInterface( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="privateImplementation") def private_implementation(self) -> IPrivatelyImplemented: return typing.cast(IPrivatelyImplemented, jsii.get(self, "privateImplementation")) @@ -8087,7 +8076,7 @@ class RootStructValidator( metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.RootStructValidator", ): - @jsii.member(jsii_name="validate") # type: ignore[misc] + @jsii.member(jsii_name="validate") @builtins.classmethod def validate( cls, @@ -8314,12 +8303,12 @@ class SomeTypeJsii976(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.SomeTypeJsii def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="returnAnonymous") # type: ignore[misc] + @jsii.member(jsii_name="returnAnonymous") @builtins.classmethod def return_anonymous(cls) -> typing.Any: return typing.cast(typing.Any, jsii.sinvoke(cls, "returnAnonymous", [])) - @jsii.member(jsii_name="returnReturn") # type: ignore[misc] + @jsii.member(jsii_name="returnReturn") @builtins.classmethod def return_return(cls) -> IReturnJsii976: return typing.cast(IReturnJsii976, jsii.sinvoke(cls, "returnReturn", [])) @@ -8341,12 +8330,12 @@ class StableClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StableClass"): def method(self) -> None: return typing.cast(None, jsii.invoke(self, "method", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readonlyProperty") def readonly_property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "readonlyProperty")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="mutableProperty") def mutable_property(self) -> typing.Optional[jsii.Number]: return typing.cast(typing.Optional[jsii.Number], jsii.get(self, "mutableProperty")) @@ -8400,12 +8389,12 @@ class StaticContext(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StaticContext" https://github.com/awslabs/aws-cdk/issues/2304 ''' - @jsii.member(jsii_name="canAccessStaticContext") # type: ignore[misc] + @jsii.member(jsii_name="canAccessStaticContext") @builtins.classmethod def can_access_static_context(cls) -> builtins.bool: return typing.cast(builtins.bool, jsii.sinvoke(cls, "canAccessStaticContext", [])) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="staticVariable") def static_variable(cls) -> builtins.bool: return typing.cast(builtins.bool, jsii.sget(cls, "staticVariable")) @@ -8429,12 +8418,12 @@ class StaticHelloParent( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="method") # type: ignore[misc] + @jsii.member(jsii_name="method") @builtins.classmethod def method(cls) -> None: return typing.cast(None, jsii.sinvoke(cls, "method", [])) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="property") def property(cls) -> jsii.Number: return typing.cast(jsii.Number, jsii.sget(cls, "property")) @@ -8447,7 +8436,7 @@ class Statics(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Statics"): ''' jsii.create(self.__class__, self, [value]) - @jsii.member(jsii_name="staticMethod") # type: ignore[misc] + @jsii.member(jsii_name="staticMethod") @builtins.classmethod def static_method(cls, name: builtins.str) -> builtins.str: '''Jsdocs for static method. @@ -8460,30 +8449,30 @@ class Statics(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Statics"): def just_method(self) -> builtins.str: return typing.cast(builtins.str, jsii.invoke(self, "justMethod", [])) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="BAR") def BAR(cls) -> jsii.Number: '''Constants may also use all-caps.''' return typing.cast(jsii.Number, jsii.sget(cls, "BAR")) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="ConstObj") def CONST_OBJ(cls) -> "DoubleTrouble": return typing.cast("DoubleTrouble", jsii.sget(cls, "ConstObj")) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="Foo") def FOO(cls) -> builtins.str: '''Jsdocs for static property.''' return typing.cast(builtins.str, jsii.sget(cls, "Foo")) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="zooBar") def ZOO_BAR(cls) -> typing.Mapping[builtins.str, builtins.str]: '''Constants can also use camelCase.''' return typing.cast(typing.Mapping[builtins.str, builtins.str], jsii.sget(cls, "zooBar")) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="instance") def instance(cls) -> "Statics": '''Jsdocs for static getter. @@ -8496,7 +8485,7 @@ class Statics(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Statics"): def instance(cls, value: "Statics") -> None: jsii.sset(cls, "instance", value) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="nonConstStatic") def non_const_static(cls) -> jsii.Number: return typing.cast(jsii.Number, jsii.sget(cls, "nonConstStatic")) @@ -8505,7 +8494,7 @@ class Statics(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Statics"): def non_const_static(cls, value: jsii.Number) -> None: jsii.sset(cls, "nonConstStatic", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") def value(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "value")) @@ -8522,7 +8511,7 @@ class StripInternal(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StripInternal" def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="youSeeMe") def you_see_me(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "youSeeMe")) @@ -8706,7 +8695,7 @@ class StructPassing(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StructPassing" def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="howManyVarArgsDidIPass") # type: ignore[misc] + @jsii.member(jsii_name="howManyVarArgsDidIPass") @builtins.classmethod def how_many_var_args_did_i_pass( cls, @@ -8719,7 +8708,7 @@ class StructPassing(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StructPassing" ''' return typing.cast(jsii.Number, jsii.sinvoke(cls, "howManyVarArgsDidIPass", [_positional, *inputs])) - @jsii.member(jsii_name="roundTrip") # type: ignore[misc] + @jsii.member(jsii_name="roundTrip") @builtins.classmethod def round_trip( cls, @@ -8746,7 +8735,7 @@ class StructUnionConsumer( metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StructUnionConsumer", ): - @jsii.member(jsii_name="isStructA") # type: ignore[misc] + @jsii.member(jsii_name="isStructA") @builtins.classmethod def is_struct_a(cls, struct: typing.Union[StructA, StructB]) -> builtins.bool: ''' @@ -8754,7 +8743,7 @@ class StructUnionConsumer( ''' return typing.cast(builtins.bool, jsii.sinvoke(cls, "isStructA", [struct])) - @jsii.member(jsii_name="isStructB") # type: ignore[misc] + @jsii.member(jsii_name="isStructB") @builtins.classmethod def is_struct_b(cls, struct: typing.Union[StructA, StructB]) -> builtins.bool: ''' @@ -8891,7 +8880,7 @@ class Sum( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="expression") def expression(self) -> scope.jsii_calc_lib.NumericValue: '''The expression that this operation consists of. @@ -8900,7 +8889,7 @@ class Sum( ''' return typing.cast(scope.jsii_calc_lib.NumericValue, jsii.get(self, "expression")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="parts") def parts(self) -> typing.List[scope.jsii_calc_lib.NumericValue]: '''The parts to sum.''' @@ -8983,18 +8972,18 @@ class SupportsNiceJavaBuilderWithRequiredProps( jsii.create(self.__class__, self, [id_, props]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="bar") def bar(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "bar")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="id") def id(self) -> jsii.Number: '''some identifier of your choice.''' return typing.cast(jsii.Number, jsii.get(self, "id")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="propId") def prop_id(self) -> typing.Optional[builtins.str]: return typing.cast(typing.Optional[builtins.str], jsii.get(self, "propId")) @@ -9059,12 +9048,12 @@ class SyncVirtualMethods( ''' return typing.cast(None, jsii.invoke(self, "writeA", [value])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readonlyProperty") def readonly_property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "readonlyProperty")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="a") def a(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "a")) @@ -9073,7 +9062,7 @@ class SyncVirtualMethods( def a(self, value: jsii.Number) -> None: jsii.set(self, "a", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="callerIsProperty") def caller_is_property(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "callerIsProperty")) @@ -9082,7 +9071,7 @@ class SyncVirtualMethods( def caller_is_property(self, value: jsii.Number) -> None: jsii.set(self, "callerIsProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="otherProperty") def other_property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "otherProperty")) @@ -9091,7 +9080,7 @@ class SyncVirtualMethods( def other_property(self, value: builtins.str) -> None: jsii.set(self, "otherProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="theProperty") def the_property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "theProperty")) @@ -9100,7 +9089,7 @@ class SyncVirtualMethods( def the_property(self, value: builtins.str) -> None: jsii.set(self, "theProperty", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="valueOfOtherProperty") def value_of_other_property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "valueOfOtherProperty")) @@ -9149,13 +9138,13 @@ class TestStructWithEnum( return typing.cast(builtins.bool, jsii.invoke(self, "isStringEnumB", [input])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="structWithFoo") def struct_with_foo(self) -> StructWithEnum: '''Returns \`\`foo: StringEnum.A\`\`.''' return typing.cast(StructWithEnum, jsii.get(self, "structWithFoo")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="structWithFooBar") def struct_with_foo_bar(self) -> StructWithEnum: '''Returns \`\`foo: StringEnum.C\`\` and \`\`bar: AllTypesEnum.MY_ENUM_VALUE\`\`.''' @@ -9257,7 +9246,7 @@ class TwoMethodsWithSimilarCapitalization( ''' return typing.cast(builtins.str, jsii.invoke(self, "toIsOString", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="fooBar") def foo_bar(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "fooBar")) @@ -9269,7 +9258,7 @@ class UmaskCheck(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.UmaskCheck"): :see: https://github.com/aws/jsii/issues/1765 ''' - @jsii.member(jsii_name="mode") # type: ignore[misc] + @jsii.member(jsii_name="mode") @builtins.classmethod def mode(cls) -> jsii.Number: '''This should return 0o644 (-rw-r--r--).''' @@ -9289,14 +9278,15 @@ class UnaryOperation( ''' jsii.create(self.__class__, self, [operand]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="operand") def operand(self) -> scope.jsii_calc_lib.NumericValue: return typing.cast(scope.jsii_calc_lib.NumericValue, jsii.get(self, "operand")) class _UnaryOperationProxy( - UnaryOperation, jsii.proxy_for(scope.jsii_calc_lib.Operation) # type: ignore[misc] + UnaryOperation, + jsii.proxy_for(scope.jsii_calc_lib.Operation), ): pass @@ -9362,12 +9352,12 @@ class UpcasingReflectable( ''' jsii.create(self.__class__, self, [delegate]) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="reflector") def REFLECTOR(cls) -> scope.jsii_calc_lib.custom_submodule_name.Reflector: return typing.cast(scope.jsii_calc_lib.custom_submodule_name.Reflector, jsii.sget(cls, "reflector")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="entries") def entries( self, @@ -9429,7 +9419,7 @@ class UsesInterfaceWithProperties( ''' return typing.cast(builtins.str, jsii.invoke(self, "writeAndRead", [value])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="obj") def obj(self) -> IInterfaceWithProperties: return typing.cast(IInterfaceWithProperties, jsii.get(self, "obj")) @@ -9531,12 +9521,12 @@ class VoidCallback( def call_me(self) -> None: return typing.cast(None, jsii.invoke(self, "callMe", [])) - @jsii.member(jsii_name="overrideMe") # type: ignore[misc] + @jsii.member(jsii_name="overrideMe") @abc.abstractmethod def _override_me(self) -> None: ... - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="methodWasCalled") def method_was_called(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "methodWasCalled")) @@ -9563,7 +9553,7 @@ class WithPrivatePropertyInConstructor( ''' jsii.create(self.__class__, self, [private_field]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="success") def success(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "success")) @@ -9578,7 +9568,7 @@ class AbstractClass( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.member(jsii_name="abstractMethod") # type: ignore[misc] + @jsii.member(jsii_name="abstractMethod") @abc.abstractmethod def abstract_method(self, name: builtins.str) -> builtins.str: ''' @@ -9590,15 +9580,13 @@ class AbstractClass( def non_abstract_method(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.invoke(self, "nonAbstractMethod", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="propFromInterface") def prop_from_interface(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "propFromInterface")) -class _AbstractClassProxy( - AbstractClass, jsii.proxy_for(AbstractClassBase) # type: ignore[misc] -): +class _AbstractClassProxy(AbstractClass, jsii.proxy_for(AbstractClassBase)): @jsii.member(jsii_name="abstractMethod") def abstract_method(self, name: builtins.str) -> builtins.str: ''' @@ -9630,7 +9618,7 @@ class Add(BinaryOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Add"): '''(deprecated) String representation of the value.''' return typing.cast(builtins.str, jsii.invoke(self, "toString", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") def value(self) -> jsii.Number: '''(deprecated) The value.''' @@ -9662,7 +9650,7 @@ class Bell(IBell, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Bell"): def ring(self) -> None: return typing.cast(None, jsii.invoke(self, "ring", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="rung") def rung(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "rung")) @@ -9720,7 +9708,7 @@ class ClassThatImplementsTheInternalInterface( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="a") def a(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "a")) @@ -9729,7 +9717,7 @@ class ClassThatImplementsTheInternalInterface( def a(self, value: builtins.str) -> None: jsii.set(self, "a", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="b") def b(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "b")) @@ -9738,7 +9726,7 @@ class ClassThatImplementsTheInternalInterface( def b(self, value: builtins.str) -> None: jsii.set(self, "b", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="c") def c(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "c")) @@ -9747,7 +9735,7 @@ class ClassThatImplementsTheInternalInterface( def c(self, value: builtins.str) -> None: jsii.set(self, "c", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="d") def d(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "d")) @@ -9765,7 +9753,7 @@ class ClassThatImplementsThePrivateInterface( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="a") def a(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "a")) @@ -9774,7 +9762,7 @@ class ClassThatImplementsThePrivateInterface( def a(self, value: builtins.str) -> None: jsii.set(self, "a", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="b") def b(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "b")) @@ -9783,7 +9771,7 @@ class ClassThatImplementsThePrivateInterface( def b(self, value: builtins.str) -> None: jsii.set(self, "b", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="c") def c(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "c")) @@ -9792,7 +9780,7 @@ class ClassThatImplementsThePrivateInterface( def c(self, value: builtins.str) -> None: jsii.set(self, "c", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="e") def e(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "e")) @@ -9809,7 +9797,7 @@ class ClassWithPrivateConstructorAndAutomaticProperties( ): '''Class that implements interface properties automatically, but using a private constructor.''' - @jsii.member(jsii_name="create") # type: ignore[misc] + @jsii.member(jsii_name="create") @builtins.classmethod def create( cls, @@ -9822,12 +9810,12 @@ class ClassWithPrivateConstructorAndAutomaticProperties( ''' return typing.cast("ClassWithPrivateConstructorAndAutomaticProperties", jsii.sinvoke(cls, "create", [read_only_string, read_write_string])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readOnlyString") def read_only_string(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "readOnlyString")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="readWriteString") def read_write_string(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "readWriteString")) @@ -9848,8 +9836,8 @@ class IFriendlyRandomGenerator( class _IFriendlyRandomGeneratorProxy( - jsii.proxy_for(IRandomNumberGenerator), # type: ignore[misc] - jsii.proxy_for(scope.jsii_calc_lib.IFriendly), # type: ignore[misc] + jsii.proxy_for(IRandomNumberGenerator), + jsii.proxy_for(scope.jsii_calc_lib.IFriendly), ): __jsii_type__: typing.ClassVar[str] = "jsii-calc.IFriendlyRandomGenerator" pass @@ -9865,21 +9853,19 @@ class IInterfaceThatShouldNotBeADataType( ): '''Even though this interface has only properties, it is disqualified from being a datatype because it inherits from an interface that is not a datatype.''' - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="otherValue") @abc.abstractmethod def other_value(self) -> builtins.str: ... -class _IInterfaceThatShouldNotBeADataTypeProxy( - jsii.proxy_for(IInterfaceWithMethods) # type: ignore[misc] -): +class _IInterfaceThatShouldNotBeADataTypeProxy(jsii.proxy_for(IInterfaceWithMethods)): '''Even though this interface has only properties, it is disqualified from being a datatype because it inherits from an interface that is not a datatype.''' __jsii_type__: typing.ClassVar[str] = "jsii-calc.IInterfaceThatShouldNotBeADataType" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="otherValue") def other_value(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "otherValue")) @@ -9890,29 +9876,27 @@ typing.cast(typing.Any, IInterfaceThatShouldNotBeADataType).__jsii_proxy_class__ @jsii.interface(jsii_type="jsii-calc.IJSII417Derived") class IJSII417Derived(IJSII417PublicBaseOfBase, metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="property") @abc.abstractmethod def property(self) -> builtins.str: ... - @jsii.member(jsii_name="bar") # type: ignore[misc] + @jsii.member(jsii_name="bar") @abc.abstractmethod def bar(self) -> None: ... - @jsii.member(jsii_name="baz") # type: ignore[misc] + @jsii.member(jsii_name="baz") @abc.abstractmethod def baz(self) -> None: ... -class _IJSII417DerivedProxy( - jsii.proxy_for(IJSII417PublicBaseOfBase) # type: ignore[misc] -): +class _IJSII417DerivedProxy(jsii.proxy_for(IJSII417PublicBaseOfBase)): __jsii_type__: typing.ClassVar[str] = "jsii-calc.IJSII417Derived" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="property") def property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "property")) @@ -9962,7 +9946,7 @@ class JSII417Derived( def baz(self) -> None: return typing.cast(None, jsii.invoke(self, "baz", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="property") def _property(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "property")) @@ -10002,7 +9986,7 @@ class Negate( '''(deprecated) String representation of the value.''' return typing.cast(builtins.str, jsii.invoke(self, "toString", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") def value(self) -> jsii.Number: '''(deprecated) The value.''' @@ -10014,12 +9998,12 @@ class StaticHelloChild( metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StaticHelloChild", ): - @jsii.member(jsii_name="method") # type: ignore[misc] + @jsii.member(jsii_name="method") @builtins.classmethod def method(cls) -> None: return typing.cast(None, jsii.sinvoke(cls, "method", [])) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="property") def property(cls) -> jsii.Number: return typing.cast(jsii.Number, jsii.sget(cls, "property")) @@ -10045,13 +10029,13 @@ class SupportsNiceJavaBuilder( ''' jsii.create(self.__class__, self, [id, default_bar, props, *rest]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="id") def id(self) -> jsii.Number: '''some identifier.''' return typing.cast(jsii.Number, jsii.get(self, "id")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="rest") def rest(self) -> typing.List[builtins.str]: return typing.cast(typing.List[builtins.str], jsii.get(self, "rest")) @@ -10396,7 +10380,7 @@ class Cdk16625( '''Run this function to verify that everything is working as it should.''' return typing.cast(None, jsii.invoke(self, "test", [])) - @jsii.member(jsii_name="unwrap") # type: ignore[misc] + @jsii.member(jsii_name="unwrap") @abc.abstractmethod def _unwrap(self, gen: _IRandomNumberGenerator_9643a8b9) -> jsii.Number: '''Implement this functin to return \`\`gen.next()\`\`. It is extremely important that the \`\`donotimport\`\` submodule is NEVER explicitly loaded in the testing application (otherwise this test is void). @@ -10511,7 +10495,7 @@ class CompositeOperation( '''(deprecated) String representation of the value.''' return typing.cast(builtins.str, jsii.invoke(self, "toString", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="expression") @abc.abstractmethod def expression(self) -> scope.jsii_calc_lib.NumericValue: @@ -10521,13 +10505,13 @@ class CompositeOperation( ''' ... - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="value") def value(self) -> jsii.Number: '''(deprecated) The value.''' return typing.cast(jsii.Number, jsii.get(self, "value")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="decorationPostfixes") def decoration_postfixes(self) -> typing.List[builtins.str]: '''A set of postfixes to include in a decorated .toString().''' @@ -10537,7 +10521,7 @@ class CompositeOperation( def decoration_postfixes(self, value: typing.List[builtins.str]) -> None: jsii.set(self, "decorationPostfixes", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="decorationPrefixes") def decoration_prefixes(self) -> typing.List[builtins.str]: '''A set of prefixes to include in a decorated .toString().''' @@ -10547,7 +10531,7 @@ class CompositeOperation( def decoration_prefixes(self, value: typing.List[builtins.str]) -> None: jsii.set(self, "decorationPrefixes", value) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="stringStyle") def string_style(self) -> "CompositeOperation.CompositionStringStyle": '''The .toString() style.''' @@ -10571,9 +10555,9 @@ class CompositeOperation( class _CompositeOperationProxy( CompositeOperation, - jsii.proxy_for(scope.jsii_calc_lib.Operation), # type: ignore[misc] + jsii.proxy_for(scope.jsii_calc_lib.Operation), ): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="expression") def expression(self) -> scope.jsii_calc_lib.NumericValue: '''The expression that this operation consists of. @@ -10615,7 +10599,7 @@ class Base( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="prop") def prop(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "prop")) @@ -10664,7 +10648,7 @@ class Foo( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="bar") def bar(self) -> typing.Optional[builtins.str]: return typing.cast(typing.Optional[builtins.str], jsii.get(self, "bar")) @@ -10795,7 +10779,7 @@ class MyClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2530.MyClass") ''' jsii.create(self.__class__, self, [_]) - @jsii.member(jsii_name="bar") # type: ignore[misc] + @jsii.member(jsii_name="bar") @builtins.classmethod def bar(cls, _: builtins.bool) -> None: ''' @@ -10837,12 +10821,12 @@ class OnlyStatics( metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2617.OnlyStatics", ): - @jsii.member(jsii_name="bar") # type: ignore[misc] + @jsii.member(jsii_name="bar") @builtins.classmethod def bar(cls) -> None: return typing.cast(None, jsii.sinvoke(cls, "bar", [])) - @jsii.member(jsii_name="foo") # type: ignore[misc] + @jsii.member(jsii_name="foo") @builtins.classmethod def foo(cls) -> None: return typing.cast(None, jsii.sinvoke(cls, "foo", [])) @@ -11000,12 +10984,12 @@ class MyClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2689.props.MyC def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="bar") def bar(self) -> typing.Mapping[builtins.str, scope.jsii_calc_base.BaseProps]: return typing.cast(typing.Mapping[builtins.str, scope.jsii_calc_base.BaseProps], jsii.get(self, "bar")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="foo") def foo(self) -> typing.List[scope.jsii_calc_lib.Number]: return typing.cast(typing.List[scope.jsii_calc_lib.Number], jsii.get(self, "foo")) @@ -11327,13 +11311,13 @@ from .._jsii import * @jsii.interface(jsii_type="jsii-calc.module2700.IFoo") class IFoo(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="baz") @abc.abstractmethod def baz(self) -> jsii.Number: ... - @jsii.member(jsii_name="bar") # type: ignore[misc] + @jsii.member(jsii_name="bar") @abc.abstractmethod def bar(self) -> builtins.str: ... @@ -11342,7 +11326,7 @@ class IFoo(metaclass = jsii.JSIIAbstractClass): class _IFooProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.module2700.IFoo" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="baz") def baz(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "baz")) @@ -11363,7 +11347,7 @@ class Base(IFoo, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2700.Base") def bar(self) -> builtins.str: return typing.cast(builtins.str, jsii.invoke(self, "bar", [])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="baz") def baz(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "baz")) @@ -11425,7 +11409,7 @@ class Class2( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="base") def base(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "base")) @@ -11458,15 +11442,13 @@ class IBaz( *(() if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): - @jsii.member(jsii_name="bazMethod") # type: ignore[misc] + @jsii.member(jsii_name="bazMethod") @abc.abstractmethod def baz_method(self) -> None: ... -class _IBazProxy( - jsii.proxy_for(scope.jsii_calc_base.IBaseInterface) # type: ignore[misc] -): +class _IBazProxy(jsii.proxy_for(scope.jsii_calc_base.IBaseInterface)): __jsii_type__: typing.ClassVar[str] = "jsii-calc.module2702.IBaz" @jsii.member(jsii_name="bazMethod") @@ -11479,7 +11461,7 @@ typing.cast(typing.Any, IBaz).__jsii_proxy_class__ = lambda : _IBazProxy @jsii.interface(jsii_type="jsii-calc.module2702.IConstruct") class IConstruct(metaclass = jsii.JSIIAbstractClass): - @jsii.member(jsii_name="constructMethod") # type: ignore[misc] + @jsii.member(jsii_name="constructMethod") @abc.abstractmethod def construct_method(self) -> None: ... @@ -11502,19 +11484,17 @@ class IFoo( *(() if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, ): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="iBaseInterface") @abc.abstractmethod def i_base_interface(self) -> builtins.str: ... -class _IFooProxy( - jsii.proxy_for(scope.jsii_calc_base.IBaseInterface) # type: ignore[misc] -): +class _IFooProxy(jsii.proxy_for(scope.jsii_calc_base.IBaseInterface)): __jsii_type__: typing.ClassVar[str] = "jsii-calc.module2702.IFoo" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="iBaseInterface") def i_base_interface(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "iBaseInterface")) @@ -11525,15 +11505,13 @@ typing.cast(typing.Any, IFoo).__jsii_proxy_class__ = lambda : _IFooProxy @jsii.interface(jsii_type="jsii-calc.module2702.IResource") class IResource(IConstruct, metaclass = jsii.JSIIAbstractClass): - @jsii.member(jsii_name="resourceMethod") # type: ignore[misc] + @jsii.member(jsii_name="resourceMethod") @abc.abstractmethod def resource_method(self) -> None: ... -class _IResourceProxy( - jsii.proxy_for(IConstruct) # type: ignore[misc] -): +class _IResourceProxy(jsii.proxy_for(IConstruct)): __jsii_type__: typing.ClassVar[str] = "jsii-calc.module2702.IResource" @jsii.member(jsii_name="resourceMethod") @@ -11546,15 +11524,13 @@ typing.cast(typing.Any, IResource).__jsii_proxy_class__ = lambda : _IResourcePro @jsii.interface(jsii_type="jsii-calc.module2702.IVpc") class IVpc(IResource, metaclass = jsii.JSIIAbstractClass): - @jsii.member(jsii_name="vpcMethod") # type: ignore[misc] + @jsii.member(jsii_name="vpcMethod") @abc.abstractmethod def vpc_method(self) -> None: ... -class _IVpcProxy( - jsii.proxy_for(IResource) # type: ignore[misc] -): +class _IVpcProxy(jsii.proxy_for(IResource)): __jsii_type__: typing.ClassVar[str] = "jsii-calc.module2702.IVpc" @jsii.member(jsii_name="vpcMethod") @@ -11748,7 +11724,7 @@ class OnlyStaticMethods( ): '''Test for https://github.com/aws/jsii/issues/2617.''' - @jsii.member(jsii_name="staticMethod") # type: ignore[misc] + @jsii.member(jsii_name="staticMethod") @builtins.classmethod def static_method(cls) -> builtins.str: return typing.cast(builtins.str, jsii.sinvoke(cls, "staticMethod", [])) @@ -11798,7 +11774,7 @@ class ClassWithSelf( ''' return typing.cast(builtins.str, jsii.invoke(self_, "method", [self])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="self") def self(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "self")) @@ -11816,7 +11792,7 @@ class ClassWithSelfKwarg( jsii.create(self_.__class__, self_, [props]) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="props") def props(self) -> "StructWithSelf": return typing.cast("StructWithSelf", jsii.get(self, "props")) @@ -11824,7 +11800,7 @@ class ClassWithSelfKwarg( @jsii.interface(jsii_type="jsii-calc.PythonSelf.IInterfaceWithSelf") class IInterfaceWithSelf(metaclass = jsii.JSIIAbstractClass): - @jsii.member(jsii_name="method") # type: ignore[misc] + @jsii.member(jsii_name="method") @abc.abstractmethod def method(self_, self: jsii.Number) -> builtins.str: ''' @@ -11976,27 +11952,27 @@ class MyClass( return typing.cast(builtins.str, jsii.invoke(self, "methodWithSpecialParam", [param])) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="awesomeness") def awesomeness(self) -> _Awesomeness_d37a24df: return typing.cast(_Awesomeness_d37a24df, jsii.get(self, "awesomeness")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="definedAt") def defined_at(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "definedAt")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="goodness") def goodness(self) -> _Goodness_2df26737: return typing.cast(_Goodness_2df26737, jsii.get(self, "goodness")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="props") def props(self) -> _SomeStruct_91627123: return typing.cast(_SomeStruct_91627123, jsii.get(self, "props")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="allTypes") def all_types(self) -> typing.Optional[_AllTypes_b08307c5]: return typing.cast(typing.Optional[_AllTypes_b08307c5], jsii.get(self, "allTypes")) @@ -12108,7 +12084,7 @@ class InnerClass( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.python.classproperty # type: ignore[misc] + @jsii.python.classproperty @jsii.member(jsii_name="staticProp") def STATIC_PROP(cls) -> "SomeStruct": return typing.cast("SomeStruct", jsii.sget(cls, "staticProp")) @@ -12126,7 +12102,7 @@ class OuterClass( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="innerClass") def inner_class(self) -> InnerClass: return typing.cast(InnerClass, jsii.get(self, "innerClass")) @@ -12287,7 +12263,7 @@ from ..child import ( class Kwargs(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.submodule.isolated.Kwargs"): '''Ensures imports are correctly registered for kwargs lifted properties from super-structs.''' - @jsii.member(jsii_name="method") # type: ignore[misc] + @jsii.member(jsii_name="method") @builtins.classmethod def method( cls, @@ -12334,12 +12310,12 @@ class Namespaced( metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.submodule.nested_submodule.Namespaced", ): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="definedAt") def defined_at(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "definedAt")) - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="goodness") @abc.abstractmethod def goodness(self) -> _Goodness_2df26737: @@ -12347,7 +12323,7 @@ class Namespaced( class _NamespacedProxy(Namespaced): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="goodness") def goodness(self) -> _Goodness_2df26737: return typing.cast(_Goodness_2df26737, jsii.get(self, "goodness")) @@ -12382,7 +12358,7 @@ from ...._jsii import * jsii_type="jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced" ) class INamespaced(metaclass = jsii.JSIIAbstractClass): - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="definedAt") @abc.abstractmethod def defined_at(self) -> builtins.str: @@ -12392,7 +12368,7 @@ class INamespaced(metaclass = jsii.JSIIAbstractClass): class _INamespacedProxy: __jsii_type__: typing.ClassVar[str] = "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced" - @builtins.property # type: ignore[misc] + @builtins.property @jsii.member(jsii_name="definedAt") def defined_at(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "definedAt")) From 261f2046bb243e1974d0d33dc4fba6bafcde012d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Fri, 28 Jan 2022 13:53:18 +0100 Subject: [PATCH 14/18] add imssing required imports --- packages/jsii-pacmak/lib/targets/python.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 405afc380b..aaf8b793ff 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -374,7 +374,9 @@ abstract class BasePythonClassType implements PythonType, ISortableType { public requiredImports(context: EmitContext): PythonImports { return mergePythonImports( - ...this.bases.map((base) => toTypeName(base).requiredImports(context)), + ...[...this.bases, ...this.interfaces].map((base) => + toTypeName(base).requiredImports(context), + ), ...this.members.map((mem) => mem.requiredImports(context)), ); } @@ -1363,15 +1365,6 @@ class Class extends BasePythonClassType implements ISortableType { return dependencies; } - public requiredImports(context: EmitContext): PythonImports { - return mergePythonImports( - super.requiredImports(context), // Takes care of base & members - ...this.interfaces.map((base) => - toTypeName(base).requiredImports(context), - ), - ); - } - public emit(code: CodeMaker, context: EmitContext) { // Then we do our normal class logic for emitting our members. super.emit(code, context); From e96331c1dec96c6806f13264c67124630420190e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Fri, 28 Jan 2022 14:35:16 +0100 Subject: [PATCH 15/18] fix duplicate type variable issue --- packages/@jsii/python-runtime/src/jsii/_runtime.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/@jsii/python-runtime/src/jsii/_runtime.py b/packages/@jsii/python-runtime/src/jsii/_runtime.py index 67ba12a7ec..22bafe7651 100644 --- a/packages/@jsii/python-runtime/src/jsii/_runtime.py +++ b/packages/@jsii/python-runtime/src/jsii/_runtime.py @@ -151,10 +151,7 @@ def deco(iface): return deco -T = TypeVar("T") - - -def proxy_for(abstract_class: Type[T]) -> Type[T]: +def proxy_for(abstract_class: T) -> T: if not hasattr(abstract_class, "__jsii_proxy_class__"): raise TypeError(f"{abstract_class} is not a JSII Abstract class.") From aa4af367c0b1fccd591981a42ed6c9ad4b177d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Fri, 28 Jan 2022 16:38:16 +0100 Subject: [PATCH 16/18] be friendlier with PyCharm --- .../@jsii/python-runtime/src/jsii/python.py | 12 +++++-- packages/jsii-pacmak/lib/targets/python.ts | 2 +- .../__snapshots__/target-python.test.ts.snap | 32 +++++++++---------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/@jsii/python-runtime/src/jsii/python.py b/packages/@jsii/python-runtime/src/jsii/python.py index 123a4daf54..a61beddb6f 100644 --- a/packages/@jsii/python-runtime/src/jsii/python.py +++ b/packages/@jsii/python-runtime/src/jsii/python.py @@ -1,5 +1,5 @@ class _ClassProperty: - def __init__(self, fget, fset=None): + def __init__(self, fget: property, fset=None) -> None: self.fget = fget self.fset = fset @@ -24,12 +24,18 @@ def setter(self, func): return self -def classproperty(func): +# The name `class_property` with the underscore is used because this is what +# will be causing PyCharm to consider the annotated member as a property. +def class_property(func: property) -> _ClassProperty: return _ClassProperty(func) +# Aliased to maintain backwards compatibility with code generated with <=1.52.2 +classproperty = class_property + + class _ClassPropertyMeta(type): - def __setattr__(self, key, value): + def __setattr__(self, key, value) -> None: obj = getattr(self, key, None) if isinstance(obj, _ClassProperty): return obj.__set__(self, value) diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index aaf8b793ff..22ad70f5fd 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -1475,7 +1475,7 @@ class AsyncMethod extends BaseMethod { } class StaticProperty extends BaseProperty { - protected readonly decorator: string = 'jsii.python.classproperty'; + protected readonly decorator: string = 'jsii.python.class_property'; protected readonly implicitParameter: string = 'cls'; protected readonly jsiiGetMethod: string = 'sget'; protected readonly jsiiSetMethod: string = 'sset'; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index 9c5a175b76..dcd87abee2 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -3323,7 +3323,7 @@ class ClassWithCollections( def create_a_map(cls) -> typing.Mapping[builtins.str, builtins.str]: return typing.cast(typing.Mapping[builtins.str, builtins.str], jsii.sinvoke(cls, "createAMap", [])) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="staticArray") def static_array(cls) -> typing.List[builtins.str]: return typing.cast(typing.List[builtins.str], jsii.sget(cls, "staticArray")) @@ -3332,7 +3332,7 @@ class ClassWithCollections( def static_array(cls, value: typing.List[builtins.str]) -> None: jsii.sset(cls, "staticArray", value) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="staticMap") def static_map(cls) -> typing.Mapping[builtins.str, builtins.str]: return typing.cast(typing.Mapping[builtins.str, builtins.str], jsii.sget(cls, "staticMap")) @@ -4448,7 +4448,7 @@ class DisappointingCollectionSource( This source of collections is disappointing - it'll always give you nothing :( ''' - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="maybeList") def MAYBE_LIST(cls) -> typing.Optional[typing.List[builtins.str]]: '''Some List of strings, maybe? @@ -4457,7 +4457,7 @@ class DisappointingCollectionSource( ''' return typing.cast(typing.Optional[typing.List[builtins.str]], jsii.sget(cls, "maybeList")) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="maybeMap") def MAYBE_MAP(cls) -> typing.Optional[typing.Mapping[builtins.str, jsii.Number]]: '''Some Map of strings to numbers, maybe? @@ -6842,7 +6842,7 @@ class JsiiAgent(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.JsiiAgent"): def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="value") def value(cls) -> typing.Optional[builtins.str]: '''Returns the value of the JSII_AGENT environment variable.''' @@ -8394,7 +8394,7 @@ class StaticContext(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StaticContext" def can_access_static_context(cls) -> builtins.bool: return typing.cast(builtins.bool, jsii.sinvoke(cls, "canAccessStaticContext", [])) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="staticVariable") def static_variable(cls) -> builtins.bool: return typing.cast(builtins.bool, jsii.sget(cls, "staticVariable")) @@ -8423,7 +8423,7 @@ class StaticHelloParent( def method(cls) -> None: return typing.cast(None, jsii.sinvoke(cls, "method", [])) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="property") def property(cls) -> jsii.Number: return typing.cast(jsii.Number, jsii.sget(cls, "property")) @@ -8449,30 +8449,30 @@ class Statics(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Statics"): def just_method(self) -> builtins.str: return typing.cast(builtins.str, jsii.invoke(self, "justMethod", [])) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="BAR") def BAR(cls) -> jsii.Number: '''Constants may also use all-caps.''' return typing.cast(jsii.Number, jsii.sget(cls, "BAR")) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="ConstObj") def CONST_OBJ(cls) -> "DoubleTrouble": return typing.cast("DoubleTrouble", jsii.sget(cls, "ConstObj")) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="Foo") def FOO(cls) -> builtins.str: '''Jsdocs for static property.''' return typing.cast(builtins.str, jsii.sget(cls, "Foo")) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="zooBar") def ZOO_BAR(cls) -> typing.Mapping[builtins.str, builtins.str]: '''Constants can also use camelCase.''' return typing.cast(typing.Mapping[builtins.str, builtins.str], jsii.sget(cls, "zooBar")) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="instance") def instance(cls) -> "Statics": '''Jsdocs for static getter. @@ -8485,7 +8485,7 @@ class Statics(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Statics"): def instance(cls, value: "Statics") -> None: jsii.sset(cls, "instance", value) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="nonConstStatic") def non_const_static(cls) -> jsii.Number: return typing.cast(jsii.Number, jsii.sget(cls, "nonConstStatic")) @@ -9352,7 +9352,7 @@ class UpcasingReflectable( ''' jsii.create(self.__class__, self, [delegate]) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="reflector") def REFLECTOR(cls) -> scope.jsii_calc_lib.custom_submodule_name.Reflector: return typing.cast(scope.jsii_calc_lib.custom_submodule_name.Reflector, jsii.sget(cls, "reflector")) @@ -10003,7 +10003,7 @@ class StaticHelloChild( def method(cls) -> None: return typing.cast(None, jsii.sinvoke(cls, "method", [])) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="property") def property(cls) -> jsii.Number: return typing.cast(jsii.Number, jsii.sget(cls, "property")) @@ -12084,7 +12084,7 @@ class InnerClass( def __init__(self) -> None: jsii.create(self.__class__, self, []) - @jsii.python.classproperty + @jsii.python.class_property @jsii.member(jsii_name="staticProp") def STATIC_PROP(cls) -> "SomeStruct": return typing.cast("SomeStruct", jsii.sget(cls, "staticProp")) From 3d471d88ee279282ba3b7023a0664f646ee73577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Mon, 31 Jan 2022 10:34:18 +0100 Subject: [PATCH 17/18] remove excess type annotations on python.py (not sure how to do this right) --- .../@jsii/python-runtime/src/jsii/python.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/@jsii/python-runtime/src/jsii/python.py b/packages/@jsii/python-runtime/src/jsii/python.py index a61beddb6f..183e5569f3 100644 --- a/packages/@jsii/python-runtime/src/jsii/python.py +++ b/packages/@jsii/python-runtime/src/jsii/python.py @@ -1,21 +1,32 @@ +from typing import Any + + class _ClassProperty: - def __init__(self, fget: property, fset=None) -> None: + def __init__( + self, + fget, + fset=None, + ) -> None: self.fget = fget - self.fset = fset + if fset is not None: + self.setter(fset) - def __get__(self, obj, klass=None): + def __get__(self, obj, klass=None) -> Any: if klass is None: klass = type(obj) return self.fget.__get__(obj, klass)(klass) - def __set__(self, obj, value): + def __set__(self, obj, value) -> None: if not self.fset: raise AttributeError("Can't set attribute.") klass = type(obj) return self.fset.__get__(obj, klass)(value) - def setter(self, func): + def setter( + self, + func, + ) -> "_ClassProperty": if not isinstance(func, (classmethod, staticmethod)): func = classmethod(func) @@ -26,7 +37,7 @@ def setter(self, func): # The name `class_property` with the underscore is used because this is what # will be causing PyCharm to consider the annotated member as a property. -def class_property(func: property) -> _ClassProperty: +def class_property(func) -> _ClassProperty: return _ClassProperty(func) From 342b5c4f1e6b02aa83ef24cb415f34f718ebdbb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Tue, 8 Feb 2022 12:48:42 +0100 Subject: [PATCH 18/18] Emit warning when `@jsii.implements` is used but considered legacy form --- .../src/jsii/_kernel/__init__.py | 20 ++++++----- .../@jsii/python-runtime/src/jsii/_runtime.py | 30 ++++++++++------ .../python-runtime/tests/test_compliance.py | 34 ++++++------------- packages/jsii-pacmak/lib/targets/python.ts | 11 +++++- .../__snapshots__/target-python.test.ts.snap | 24 +++++++++---- 5 files changed, 70 insertions(+), 49 deletions(-) diff --git a/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py b/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py index 86ec57fade..c47c066777 100644 --- a/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py +++ b/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py @@ -12,9 +12,7 @@ from ..errors import JSIIError from .. import _reference_map -from .._utils import Singleton from .providers import BaseProvider, ProcessProvider -from .types import Callback from .types import ( EnumRef, LoadRequest, @@ -63,7 +61,7 @@ def _get_overides(klass: Type, obj: Any) -> List[Override]: # We need to inspect each item in the MRO, until we get to our Type, at that # point we'll bail, because those methods are not the overriden methods, but the # "real" methods. - jsii_name = getattr(klass, "__jsii_type__", "Object") + jsii_name = getattr(klass, "__jsii_class__", None) or "Object" jsii_classes = [ next( ( @@ -124,7 +122,7 @@ def _get_overides(klass: Type, obj: Any) -> List[Override]: return overrides -def _recursize_dereference(kernel, d): +def _recursize_dereference(kernel: "Kernel", d): if isinstance(d, dict): return {k: _recursize_dereference(kernel, v) for k, v in d.items()} elif isinstance(d, list): @@ -147,7 +145,7 @@ def wrapped(kernel, *args, **kwargs): # We need to recurse through our data structure and look for anything that the JSII # doesn't natively handle. These items will be created as "Object" types in the JSII. -def _make_reference_for_native(kernel, d): +def _make_reference_for_native(kernel: "Kernel", d): if isinstance(d, dict): return { "$jsii.map": { @@ -181,6 +179,12 @@ def _make_reference_for_native(kernel, d): }, } } + + if not hasattr(d, "__jsii_ref__"): + # This is a user-defined interface implementation. It hasn't been registered with the JS kernel just yet, so + # we need to create a JS proxy for this value before we can send it across the wire. + kernel.create(d.__class__, d) + return d elif isinstance(d, (int, type(None), str, float, bool, datetime.datetime)): @@ -201,7 +205,7 @@ def _make_reference_for_native(kernel, d): return d -def _handle_callback(kernel, callback): +def _handle_callback(kernel: "Kernel", callback): # need to handle get, set requests here as well as invoke requests if callback.invoke: obj = _reference_map.resolve_id(callback.invoke.objref.ref) @@ -222,7 +226,7 @@ def _handle_callback(kernel, callback): def _callback_till_result( - kernel, response: Callback, response_type: Type[KernelResponse] + kernel: "Kernel", response: Callback, response_type: Type[KernelResponse] ) -> Any: current: Any = response while isinstance(current, Callback): @@ -288,7 +292,7 @@ def create(self, klass: Type, obj: Any, args: Optional[List[Any]] = None) -> Obj response = self.provider.create( CreateRequest( - fqn=klass.__jsii_type__ or "Object", + fqn=getattr(klass, "__jsii_class__", None) or "Object", args=_make_reference_for_native(self, args), overrides=_get_overides(klass, obj), interfaces=[ diff --git a/packages/@jsii/python-runtime/src/jsii/_runtime.py b/packages/@jsii/python-runtime/src/jsii/_runtime.py index 22bafe7651..4aba11da11 100644 --- a/packages/@jsii/python-runtime/src/jsii/_runtime.py +++ b/packages/@jsii/python-runtime/src/jsii/_runtime.py @@ -1,9 +1,11 @@ import abc import os +import warnings import attr -from typing import cast, Any, Callable, List, Optional, Mapping, Type, TypeVar +from typing import cast, Any, Callable, List, Mapping, Optional, Type, TypeVar +from typing_extensions import Protocol from . import _reference_map from ._compat import importlib_resources @@ -66,7 +68,7 @@ def __new__( # Since their parent class will have the __jsii_type__ variable defined, they # will as well anyways. if jsii_type is not None: - attrs["__jsii_type__"] = jsii_type + attrs["__jsii_class__"] = attrs["__jsii_type__"] = jsii_type # The declared type should NOT be inherited by subclasses. This way we can identify whether # an MRO entry corresponds to a possible overrides contributor or not. attrs["__jsii_declared_type__"] = jsii_type @@ -81,14 +83,6 @@ def __new__( return cast("JSIIMeta", obj) - def __call__(cls: Type[Any], *args: Any, **kwargs) -> Any: - inst = super().__call__(*args, **kwargs) - - # Register this instance with our reference map. - _reference_map.register_reference(inst) - - return inst - class JSIIAbstractClass(abc.ABCMeta, JSIIMeta): pass @@ -132,7 +126,19 @@ def deco(fn): def implements(*interfaces: Type[Any]) -> Callable[[T], T]: - def deco(cls): + def deco(cls: T) -> T: + # In the past, interfaces were rendered as Protocols, so they could not + # be directly extended. The @jsii.implements annotation was created to + # register the nominal type relationship. Now, interfaces are rendered + # as fully abstract base classes, and they should simply be extended. We + # emit a warning when the legacy usage is detected. + for interface in interfaces: + if type(interface) is not type(Protocol): + warnings.warn( + f"{interface.__name__} is no longer a Protocol. Use of @jsii.implements with it is deprecated. Move this interface to the class' inhertiance list of {cls.__name__} instead!", + stacklevel=2, + ) + cls.__jsii_type__ = getattr(cls, "__jsii_type__", None) cls.__jsii_ifaces__ = getattr(cls, "__jsii_ifaces__", []) + list(interfaces) return cls @@ -142,6 +148,8 @@ def deco(cls): def interface(*, jsii_type: str) -> Callable[[T], T]: def deco(iface): + # Un-set __jsii_class__ as this is an interface, and not a class. + iface.__jsii_class__ = None iface.__jsii_type__ = jsii_type # This interface "implements itself" - this is a trick to ease up implementation discovery. iface.__jsii_ifaces__ = [iface] + getattr(iface, "__jsii_ifaces__", []) diff --git a/packages/@jsii/python-runtime/tests/test_compliance.py b/packages/@jsii/python-runtime/tests/test_compliance.py index b8f7f0e881..c566e269be 100644 --- a/packages/@jsii/python-runtime/tests/test_compliance.py +++ b/packages/@jsii/python-runtime/tests/test_compliance.py @@ -153,9 +153,7 @@ def the_property(self, value): self.another_the_property = value -@jsii.implements(IFriendly) -@jsii.implements(IRandomNumberGenerator) -class SubclassNativeFriendlyRandom(Number): +class SubclassNativeFriendlyRandom(Number, IFriendly, IRandomNumberGenerator): def __init__(self): super().__init__(908) self.next_number = 100 @@ -185,8 +183,7 @@ def next(self): return next_ -@jsii.implements(IFriendlyRandomGenerator) -class PureNativeFriendlyRandom: +class PureNativeFriendlyRandom(IFriendlyRandomGenerator): """ In this case, the class does not derive from the JsiiObject hierarchy. It means that when we pass it along to javascript, we won't have an objref. This should @@ -654,8 +651,7 @@ def the_property(self, value): def test_propertyOverrides_interfaces(): - @jsii.implements(IInterfaceWithProperties) - class TInterfaceWithProperties: + class TInterfaceWithProperties(IInterfaceWithProperties): x = None @@ -679,8 +675,7 @@ def read_write_string(self, value): def test_interfaceBuilder(): - @jsii.implements(IInterfaceWithProperties) - class TInterfaceWithProperties: + class TInterfaceWithProperties(IInterfaceWithProperties): x = "READ_WRITE" @@ -1140,14 +1135,12 @@ def test_structs_can_be_downcasted_to_parent_type(): assert Demonstrate982.take_this_too() is not None -@jsii.implements(IBellRinger) -class PythonBellRinger: +class PythonBellRinger(IBellRinger): def your_turn(self, bell): bell.ring() -@jsii.implements(IConcreteBellRinger) -class PythonConcreteBellRinger: +class PythonConcreteBellRinger(IConcreteBellRinger): def your_turn(self, bell): bell.ring() @@ -1184,8 +1177,7 @@ def test_can_obtain_struct_reference_with_overloaded_setter(): def test_pure_interfaces_can_be_used_transparently(): expected = StructB(required_string="It's Britney b**ch!") - @jsii.implements(IStructReturningDelegate) - class StructReturningDelegate: + class StructReturningDelegate(IStructReturningDelegate): def return_struct(self): return expected @@ -1197,8 +1189,7 @@ def return_struct(self): def test_pure_interfaces_can_be_used_transparently_when_transitively_implementing(): expected = StructB(required_string="It's Britney b**ch!") - @jsii.implements(IStructReturningDelegate) - class ImplementsStructReturningDelegate: + class ImplementsStructReturningDelegate(IStructReturningDelegate): def return_struct(self): return expected @@ -1215,8 +1206,7 @@ class IndirectlyImplementsStructReturningDelegate( def test_pure_interfaces_can_be_used_transparently_when_added_to_jsii_type(): expected = StructB(required_string="It's Britney b**ch!") - @jsii.implements(IStructReturningDelegate) - class ImplementsAdditionalInterface(AllTypes): + class ImplementsAdditionalInterface(AllTypes, IStructReturningDelegate): def return_struct(self): return expected @@ -1306,8 +1296,7 @@ def test_kwargs_from_superinterface_are_working(): def test_iso8601_does_not_deserialize_to_date(): - @jsii.implements(IWallClock) - class WallClock: + class WallClock(IWallClock): def __init__(self, now: str): self.now = now @@ -1335,8 +1324,7 @@ def test_class_can_extend_and_implement_from_jsii(): See also https://github.com/aws/jsii/issues/2963 """ - @jsii.implements(IWallClock) - class WallClock(ClassWithSelf): + class WallClock(ClassWithSelf, IWallClock): def __init__(self, now: str): super().__init__(now) self.now = now diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 22ad70f5fd..fc54be5e72 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -961,7 +961,16 @@ class Interface extends BasePythonClassType { .map((iface) => toTypeName(iface).pythonType(context)); // If we have anything, emit an `@jsii.implements` declaration. if (interfaces.length > 0) { - code.line(`@jsii.implements(${interfaces.join(', ')})`); + emitList( + code, + '@jsii.implements(', + interfaces.map( + (iface) => + // Only list the interface if it's a Protocol, as otherwise this will trigger a warning. + `*((${iface},) if type(${iface}) is type(typing_extensions.Protocol) else ())`, + ), + ')', + ); } // First we do our normal class logic for emitting our members. diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index dcd87abee2..fdad5a9879 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -397,7 +397,9 @@ class BaseProps(scope.jsii_calc_base_of_base.VeryBaseProps): @jsii.interface(jsii_type="@scope/jsii-calc-base.IBaseInterface") -@jsii.implements(scope.jsii_calc_base_of_base.IVeryBaseInterface) +@jsii.implements( + *((scope.jsii_calc_base_of_base.IVeryBaseInterface,) if type(scope.jsii_calc_base_of_base.IVeryBaseInterface) is type(typing_extensions.Protocol) else ()) +) class IBaseInterface( *(() if type(scope.jsii_calc_base_of_base.IVeryBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base_of_base.IVeryBaseInterface,)), metaclass = jsii.JSIIAbstractClass, @@ -1506,7 +1508,9 @@ typing.cast(typing.Any, IFriendly).__jsii_proxy_class__ = lambda : _IFriendlyPro @jsii.interface(jsii_type="@scope/jsii-calc-lib.IThreeLevelsInterface") -@jsii.implements(scope.jsii_calc_base.IBaseInterface) +@jsii.implements( + *((scope.jsii_calc_base.IBaseInterface,) if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else ()) +) class IThreeLevelsInterface( *(() if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, @@ -5628,7 +5632,9 @@ typing.cast(typing.Any, IExternalInterface).__jsii_proxy_class__ = lambda : _IEx @jsii.interface(jsii_type="jsii-calc.IFriendlier") -@jsii.implements(scope.jsii_calc_lib.IFriendly) +@jsii.implements( + *((scope.jsii_calc_lib.IFriendly,) if type(scope.jsii_calc_lib.IFriendly) is type(typing_extensions.Protocol) else ()) +) class IFriendlier( *(() if type(scope.jsii_calc_lib.IFriendly) is type(typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), metaclass = jsii.JSIIAbstractClass, @@ -9826,7 +9832,9 @@ class ClassWithPrivateConstructorAndAutomaticProperties( @jsii.interface(jsii_type="jsii-calc.IFriendlyRandomGenerator") -@jsii.implements(scope.jsii_calc_lib.IFriendly) +@jsii.implements( + *((scope.jsii_calc_lib.IFriendly,) if type(scope.jsii_calc_lib.IFriendly) is type(typing_extensions.Protocol) else ()) +) class IFriendlyRandomGenerator( IRandomNumberGenerator, *(() if type(scope.jsii_calc_lib.IFriendly) is type(typing_extensions.Protocol) else (scope.jsii_calc_lib.IFriendly,)), @@ -11437,7 +11445,9 @@ class Class3( @jsii.interface(jsii_type="jsii-calc.module2702.IBaz") -@jsii.implements(scope.jsii_calc_base.IBaseInterface) +@jsii.implements( + *((scope.jsii_calc_base.IBaseInterface,) if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else ()) +) class IBaz( *(() if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass, @@ -11479,7 +11489,9 @@ typing.cast(typing.Any, IConstruct).__jsii_proxy_class__ = lambda : _IConstructP @jsii.interface(jsii_type="jsii-calc.module2702.IFoo") -@jsii.implements(scope.jsii_calc_base.IBaseInterface) +@jsii.implements( + *((scope.jsii_calc_base.IBaseInterface,) if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else ()) +) class IFoo( *(() if type(scope.jsii_calc_base.IBaseInterface) is type(typing_extensions.Protocol) else (scope.jsii_calc_base.IBaseInterface,)), metaclass = jsii.JSIIAbstractClass,