mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
fix: Cleanup serialization and hashing code (#14317)
This commit is contained in:
@@ -15,14 +15,20 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import hashlib
|
||||
import json
|
||||
from typing import Any, Dict
|
||||
from typing import Any, Callable, Dict, Optional
|
||||
|
||||
import simplejson as json
|
||||
|
||||
|
||||
def md5_sha_from_str(val: str) -> str:
|
||||
return hashlib.md5(val.encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
def md5_sha_from_dict(opts: Dict[Any, Any]) -> str:
|
||||
json_data = json.dumps(opts, sort_keys=True)
|
||||
def md5_sha_from_dict(
|
||||
obj: Dict[Any, Any],
|
||||
ignore_nan: bool = False,
|
||||
default: Optional[Callable[[Any], Any]] = None,
|
||||
) -> str:
|
||||
json_data = json.dumps(obj, sort_keys=True, ignore_nan=ignore_nan, default=default)
|
||||
|
||||
return md5_sha_from_str(json_data)
|
||||
|
||||
Reference in New Issue
Block a user