From 7dc5420548824a3131e4a7d138de952bc4a24c29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Tue, 23 Nov 2021 12:17:25 +0545 Subject: [PATCH] metrics/params diff: catch NoSCMError instead of a broad exception instead of catching broad exception, NoSCMError should work here. --- dvc/repo/metrics/show.py | 6 +++--- dvc/repo/params/show.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dvc/repo/metrics/show.py b/dvc/repo/metrics/show.py index 6e8cd953a..7bd4153b7 100644 --- a/dvc/repo/metrics/show.py +++ b/dvc/repo/metrics/show.py @@ -7,7 +7,7 @@ from dvc.output import Output from dvc.repo import locked from dvc.repo.collect import StrPaths, collect from dvc.repo.live import summary_fs_path -from dvc.scm.base import SCMError +from dvc.scm.base import NoSCMError from dvc.utils import error_handler, errored_revisions, onerror_collect from dvc.utils.serialize import load_yaml @@ -121,9 +121,9 @@ def show( # Hide workspace metrics if they are the same as in the active branch try: active_branch = repo.scm.active_branch() - except (TypeError, SCMError): + except (TypeError, NoSCMError): # TypeError - detached head - # SCMError - no repo case + # NoSCMError - no repo case pass else: if res.get("workspace") == res.get(active_branch): diff --git a/dvc/repo/params/show.py b/dvc/repo/params/show.py index e0cc7bbf5..1df4be838 100644 --- a/dvc/repo/params/show.py +++ b/dvc/repo/params/show.py @@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple from dvc.dependency.param import ParamsDependency from dvc.repo import locked from dvc.repo.collect import collect -from dvc.scm.base import SCMError +from dvc.scm.base import NoSCMError from dvc.stage import PipelineStage from dvc.ui import ui from dvc.utils import error_handler, errored_revisions, onerror_collect @@ -113,9 +113,9 @@ def show(repo, revs=None, targets=None, deps=False, onerror: Callable = None): # Hide workspace params if they are the same as in the active branch try: active_branch = repo.scm.active_branch() - except (TypeError, SCMError): + except (TypeError, NoSCMError): # TypeError - detached head - # SCMError - no repo case + # NoSCMError - no repo case pass else: if res.get("workspace") == res.get(active_branch):