def import_from_string(
import_str: str,
*,
is_factory: bool = False,
) -> Tuple[Path, "Application"]:
module_path, instance = _import_obj_or_factory(import_str)
if is_factory:
if callable(instance):
instance = instance()
else:
raise typer.BadParameter(f'"{instance}" is not a factory')
if callable(instance) and not is_factory and not isinstance(instance, Application):
raise typer.BadParameter("Please, use --factory option for callable object")
return module_path, instance