diff --git a/.gitignore b/.gitignore index 0a71eccf..2ac52fce 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.pyc *.swp *.egg +.idea/* env/ .venv/ .eggs/ @@ -16,4 +17,4 @@ __pycache__/ .coverage htmlcov/ Pipfile* -hold \ No newline at end of file +hold diff --git a/src/falconpy/_util/_functions.py b/src/falconpy/_util/_functions.py index 5912ee69..83477ace 100644 --- a/src/falconpy/_util/_functions.py +++ b/src/falconpy/_util/_functions.py @@ -41,9 +41,10 @@ from warnings import warn from json import loads try: - from simplejson import JSONDecodeError -except (ImportError, ModuleNotFoundError): # Support import as a module - from json.decoder import JSONDecodeError + from simplejson import JSONDecodeError as SimplejsonJSONDecodeError +except (ImportError, ModuleNotFoundError): + SimplejsonJSONDecodeError = None # Support import as a module +from json.decoder import JSONDecodeError as StdJSONDecodeError from typing import Dict, Any, Union, Optional, List, TYPE_CHECKING from copy import deepcopy from logging import Logger @@ -85,6 +86,9 @@ urllib3.disable_warnings(InsecureRequestWarning) +# create a tuple of all possible JSONDecodeError types for exception handling +JSONDecodeError = (SimplejsonJSONDecodeError, StdJSONDecodeError) if SimplejsonJSONDecodeError else (StdJSONDecodeError,) + def validate_payload(validator: Dict[str, Any], payload: Dict[str, Union[str, int, dict, list, bytes]],