Skip to content

Commit

Permalink
Updated model's helper - added specific exception for adding extra js…
Browse files Browse the repository at this point in the history
…on column. Removed disabled pylint rule.
  • Loading branch information
kkucharc committed Sep 18, 2020
1 parent 4632bb3 commit 422c026
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions superset/models/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import logging
import re
from datetime import datetime, timedelta
from json.decoder import JSONDecodeError
from typing import Any, Dict, List, Optional, Set, Union

import humanize
Expand All @@ -43,9 +44,7 @@
def json_to_dict(json_str: str) -> Dict[Any, Any]:
if json_str:
val = re.sub(",[ \t\r\n]+}", "}", json_str)
val = re.sub(
",[ \t\r\n]+\]", "]", val # pylint: disable=anomalous-backslash-in-string
)
val = re.sub(",[ \t\r\n]+\\]", "]", val)
return json.loads(val)

return {}
Expand Down Expand Up @@ -426,7 +425,10 @@ class ExtraJSONMixin:
def extra(self) -> Dict[str, Any]:
try:
return json.loads(self.extra_json)
except Exception: # pylint: disable=broad-except
except (TypeError, JSONDecodeError) as exc:
logger.error(
"Unable to load an extra json: %r. Leaving empty.", exc, exc_info=True
)
return {}

def set_extra_json(self, extras: Dict[str, Any]) -> None:
Expand Down

0 comments on commit 422c026

Please sign in to comment.