From 4d6a19cd99f2dcf377ff0ed483ab59d9b7153c5f Mon Sep 17 00:00:00 2001 From: checktheroads Date: Thu, 17 Dec 2020 13:52:12 -0700 Subject: [PATCH] fix parsing exception handling issue --- hyperglass/exceptions.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hyperglass/exceptions.py b/hyperglass/exceptions.py index 105c7fc..16a46d7 100644 --- a/hyperglass/exceptions.py +++ b/hyperglass/exceptions.py @@ -3,7 +3,7 @@ # Standard Library import sys import json as _json -from typing import Dict, List, Union, Optional, Sequence +from typing import Dict, List, Union, Optional # Third Party from rich.console import Console @@ -190,18 +190,13 @@ class ParsingError(_UnformattedHyperglassError): """Raised when there is a problem parsing a structured response.""" def __init__( - self, - unformatted_msg: Union[Sequence[Dict], str], - level: str = "danger", - **kwargs, + self, unformatted_msg: Union[List[Dict], str], level: str = "danger", **kwargs, ) -> None: """Format error message with keyword arguments.""" - if isinstance(unformatted_msg, Sequence): + if isinstance(unformatted_msg, list): self._message = validation_error_message(*unformatted_msg) else: self._message = unformatted_msg.format(**kwargs) self._level = level or self._level self._keywords = list(kwargs.values()) - super().__init__( - message=self._message, level=self._level, keywords=self._keywords - ) + super().__init__(self._message, level=self._level, keywords=self._keywords)