How to use the punq.__init__.Empty function in punq

To help you get started, we’ve selected a few punq 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 bobthemighty / punq / punq / __init__.py View on Github external
singleton = 1


class Registration(NamedTuple):
    service: str
    scope: Scope
    builder: Callable[[], Any]
    needs: Any
    args: List[Any]


class Empty:
    pass


empty = Empty()


class Registry:
    def __init__(self):
        self.__registrations = defaultdict(list)
        self._localns = dict()

    def _get_needs_for_ctor(self, cls):
        try:
            return get_type_hints(cls.__init__, None, self._localns)
        except NameError as e:
            raise InvalidForwardReferenceException(str(e))

    def register_service_and_impl(self, service, scope, impl, resolve_args):
        """Registers a concrete implementation of an abstract service.