How to use the jsii._kernel.types.Override function in jsii

To help you get started, we’ve selected a few jsii examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / jsii / packages / @jsii / python-runtime / src / jsii / _kernel / __init__.py View on Github external
def _get_overides(klass: JSClass, obj: Any) -> List[Override]:
    overrides: List[Override] = []

    # We need to inspect each item in the MRO, until we get to our JSClass, at that
    # point we'll bail, because those methods are not the overriden methods, but the
    # "real" methods.
    jsii_classes = [klass] + list(
        itertools.chain.from_iterable(
            (getattr(m, "__jsii_ifaces__", []) for m in type(obj).mro())
        )
    )
    for mro_klass in type(obj).mro():
        if mro_klass is klass and getattr(mro_klass, "__jsii_type__", "Object") is not None:
            break
        if mro_klass is Object:
            break

        for name, item in mro_klass.__dict__.items():
github aws / jsii / packages / @jsii / python-runtime / src / jsii / _kernel / __init__.py View on Github external
if original is not _nothing:
                    if inspect.isfunction(item) and hasattr(original, "__jsii_name__"):
                        if any(entry.method == original.__jsii_name__ for entry in overrides):
                            # Don't re-register an override we already discovered through a previous type
                            continue
                        overrides.append(
                            Override(method=original.__jsii_name__, cookie=name)
                        )
                    elif inspect.isdatadescriptor(item) and hasattr(
                        getattr(original, "fget", None), "__jsii_name__"
                    ):
                        if any(entry.property == original.fget.__jsii_name__ for entry in overrides):
                            # Don't re-register an override we already discovered through a previous type
                            continue
                        overrides.append(
                            Override(property=original.fget.__jsii_name__, cookie=name)
                        )

    return overrides
github aws / jsii / packages / @jsii / python-runtime / src / jsii / _kernel / __init__.py View on Github external
break
        if mro_klass is Object:
            break

        for name, item in mro_klass.__dict__.items():
            # We're only interested in things that also exist on the JSII class or
            # interfaces, and which are themselves, jsii members.
            for jsii_class in jsii_classes:
                original = getattr(jsii_class, name, _nothing)
                if original is not _nothing:
                    if inspect.isfunction(item) and hasattr(original, "__jsii_name__"):
                        if any(entry.method == original.__jsii_name__ for entry in overrides):
                            # Don't re-register an override we already discovered through a previous type
                            continue
                        overrides.append(
                            Override(method=original.__jsii_name__, cookie=name)
                        )
                    elif inspect.isdatadescriptor(item) and hasattr(
                        getattr(original, "fget", None), "__jsii_name__"
                    ):
                        if any(entry.property == original.fget.__jsii_name__ for entry in overrides):
                            # Don't re-register an override we already discovered through a previous type
                            continue
                        overrides.append(
                            Override(property=original.fget.__jsii_name__, cookie=name)
                        )

    return overrides
github aws / jsii / packages / @jsii / python-runtime / src / jsii / _kernel / providers / process.py View on Github external
EndRequest, _with_api_key("end", self._serializer.unstructure_attrs_asdict)
        )
        self._serializer.register_unstructure_hook(
            CallbacksRequest,
            _with_api_key("callbacks", self._serializer.unstructure_attrs_asdict),
        )
        self._serializer.register_unstructure_hook(
            CompleteRequest,
            _with_api_key("complete", self._serializer.unstructure_attrs_asdict),
        )
        self._serializer.register_unstructure_hook(
            StatsRequest,
            _with_api_key("stats", self._serializer.unstructure_attrs_asdict),
        )
        self._serializer.register_unstructure_hook(
            Override, self._serializer.unstructure_attrs_asdict
        )
        self._serializer.register_unstructure_hook(ObjRef, _unstructure_ref)
        self._serializer.register_structure_hook(ObjRef, _with_reference)

        self._ctx_stack = contextlib.ExitStack()