Skip to content

Commit

Permalink
fixup metaclass typing
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller committed Jul 18, 2023
1 parent 7db10d2 commit ab1c9e5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/@jsii/python-runtime/src/jsii/_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ def __new__(
return cast("JSIIMeta", obj)

def __call__(cls: Type[M], *args: Any, **kwargs) -> M:
inst = super().__call__(*args, **kwargs)
# There is no way to constrain the metaclass of a `Type[M]` hint today, so we have to
# perform a `cast` trick here in order for MyPy to accept this code as valid... The implicit
# arguments to `super()` otherwise are `super(__class__, cls)`, which results in an error.
inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)

# Register this instance with our reference map.
_reference_map.register_reference(inst)
Expand Down

0 comments on commit ab1c9e5

Please sign in to comment.