diff --git a/dvc/exceptions.py b/dvc/exceptions.py index 7568ebc8e..d92b23761 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -7,6 +7,7 @@ class DvcException(Exception): def __init__(self, msg, *args): assert msg + self.msg = msg super().__init__(msg, *args) diff --git a/dvc/stage/exceptions.py b/dvc/stage/exceptions.py index 1f180b2c6..c842a08d3 100644 --- a/dvc/stage/exceptions.py +++ b/dvc/stage/exceptions.py @@ -80,9 +80,7 @@ class MissingDataSource(DvcException): super().__init__(msg) -class StageNotFound(KeyError, DvcException): - __str__ = DvcException.__str__ - +class StageNotFound(DvcException, KeyError): def __init__(self, file, name): self.file = file.relpath self.name = name @@ -90,6 +88,11 @@ class StageNotFound(KeyError, DvcException): f"Stage '{self.name}' not found inside '{self.file}' file" ) + def __str__(self): + # `KeyError` quotes the message + # see: https://bugs.python.org/issue2651 + return self.msg + class StageNameUnspecified(DvcException): def __init__(self, file):