def __init__(
        self,
        app,
        modules=[],
        injector=None,
        request_scope_class=RequestScope,
        use_annotations=None,
    ):
        """Initializes Injector for the application.

        .. note::

            Needs to be called *after* all views, signal handlers, template globals
            and context processors are registered.

        :param app: Application to configure
        :param modules: Configuration for newly created :class:`injector.Injector`
        :param injector: Injector to initialize app with, if not provided
            a new instance will be created.
        :type app: :class:`flask.Flask`
        :type modules: Iterable of configuration modules
        :param use_annotations: Enables Python 3 annotation support, see Injector
                                documentation for details.
        :type use_annotations: bool
        :rtype: :class:`injector.Injector`
        """
        if injector and use_annotations is not None:
            raise AssertionError(
                'You cannot set use_annotations and pass Injector instance '
                'at the same time',
            )
        if not injector:
            kwargs = {}
            if use_annotations is not None:
                kwargs['use_annotations'] = use_annotations
            injector = Injector(**kwargs)

        for module in (
                [FlaskModule(app=app, request_scope_class=request_scope_class)] +
                list(modules)):
            injector.binder.install(module)

        for container in (
                app.view_functions,
                app.before_request_funcs,
                app.after_request_funcs,
                app.teardown_request_funcs,
                app.template_context_processors,
                app.jinja_env.globals,
        ):
            process_dict(container, injector)

        process_error_handler_spec(app.error_handler_spec, injector)

        def reset_request_scope_before(*args, **kwargs):
            injector.get(request_scope_class).prepare()

        def reset_request_scope_after(*args, **kwargs):
            injector.get(request_scope_class).cleanup()

        app.before_request_funcs.setdefault(
            None, []).insert(0, reset_request_scope_before)
        app.teardown_request(reset_request_scope_after)

        self.injector = injector
        self.app = app
dataset/ETHPy150Open alecthomas/flask_injector/flask_injector.py/FlaskInjector.__init__/original