diff --git a/src/prefect/flow_engine.py b/src/prefect/flow_engine.py index 57788d6c9ab0..7efe33cb8055 100644 --- a/src/prefect/flow_engine.py +++ b/src/prefect/flow_engine.py @@ -613,11 +613,12 @@ def setup_run_context(self, client: Optional[SyncPrefectClient] = None): self.flow_run.name = flow_run_name self._flow_run_name_set = True - _logger, run_type = ( - (get_run_logger(FlowRunContext.get()), "subflow") - if self.flow_run.parent_task_run_id - else (self.logger, "flow") - ) + if self.flow_run.parent_task_run_id: + _logger = get_run_logger(FlowRunContext.get()) + run_type = "subflow" + else: + _logger = self.logger + run_type = "flow" _logger.info( f"Beginning {run_type} run {self.flow_run.name!r} for flow {self.flow.name!r}"