[REF-2602] Do not suppress import errors in rxconfig (#3434)
This commit is contained in:
parent
1c29bff998
commit
a3cbfefb22
@ -352,11 +352,14 @@ def get_config(reload: bool = False) -> Config:
|
|||||||
The app config.
|
The app config.
|
||||||
"""
|
"""
|
||||||
sys.path.insert(0, os.getcwd())
|
sys.path.insert(0, os.getcwd())
|
||||||
try:
|
# only import the module if it exists. If a module spec exists then
|
||||||
rxconfig = __import__(constants.Config.MODULE)
|
# the module exists.
|
||||||
if reload:
|
spec = importlib.util.find_spec(constants.Config.MODULE) # type: ignore
|
||||||
importlib.reload(rxconfig)
|
if not spec:
|
||||||
return rxconfig.config
|
# we need this condition to ensure that a ModuleNotFound error is not thrown when
|
||||||
|
# running unit/integration tests.
|
||||||
except ImportError:
|
return Config(app_name="")
|
||||||
return Config(app_name="") # type: ignore
|
rxconfig = importlib.import_module(constants.Config.MODULE)
|
||||||
|
if reload:
|
||||||
|
importlib.reload(rxconfig)
|
||||||
|
return rxconfig.config
|
||||||
|
Loading…
Reference in New Issue
Block a user