Skip to content

try_import_app

faststream.cli.utils.imports.try_import_app #

try_import_app(module, app)

Tries to import a FastStream app from a module.

Source code in faststream/cli/utils/imports.py
def try_import_app(module: Path, app: str) -> "FastStream":
    """Tries to import a FastStream app from a module."""
    try:
        app_object = import_object(module, app)

    except FileNotFoundError as e:
        typer.echo(e, err=True)
        raise typer.BadParameter(
            "Please, input module like [python_file:faststream_app_name] or [module:attribute]"
        ) from e

    else:
        return app_object  # type: ignore