From 2aa934875983ab334e596a1852e9071ca6a55988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20Tr=E1=BB=8Dng=20H=E1=BA=A3i?= <41283691+hainenber@users.noreply.github.com> Date: Fri, 4 Oct 2024 04:58:32 +0700 Subject: [PATCH] feat(be/cfg): replace deprecated imp.load_source with importlib.util (#30390) --- superset/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/superset/config.py b/superset/config.py index eeb4ded6c..0234c0deb 100644 --- a/superset/config.py +++ b/superset/config.py @@ -25,7 +25,6 @@ at the end of this file. # pylint: disable=too-many-lines from __future__ import annotations -import imp # pylint: disable=deprecated-module import importlib.util import json import logging @@ -1885,7 +1884,9 @@ if CONFIG_PATH_ENV_VAR in os.environ: cfg_path = os.environ[CONFIG_PATH_ENV_VAR] try: module = sys.modules[__name__] - override_conf = imp.load_source("superset_config", cfg_path) + spec = importlib.util.spec_from_file_location("superset_config", cfg_path) + override_conf = importlib.util.module_from_spec(spec) + spec.loader.exec_module(override_conf) for key in dir(override_conf): if key.isupper(): setattr(module, key, getattr(override_conf, key))