1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-03 19:10:58 +08:00

Make __getattr__ to raise AttributeError instead of return it.Avoid using try except.

This commit is contained in:
hadrianl
2020-12-17 09:47:25 +08:00
committed by you-n-g
parent 7d40ba753a
commit 3f84c3768a

View File

@@ -27,10 +27,10 @@ class Config:
return self.__dict__["_config"][key]
def __getattr__(self, attr):
try:
if attr in self.__dict__["_config"]:
return self.__dict__["_config"][attr]
except KeyError:
return AttributeError(f"No such {attr} in self._config")
raise AttributeError(f"No such {attr} in self._config")
def __setitem__(self, key, value):
self.__dict__["_config"][key] = value