mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-07-24 18:58:12 +00:00
fix: bare except (#1159)
Bare `except:` catches SystemExit and KeyboardInterrupt, which can: - Mask Ctrl+C handling during long optimization runs - Hide critical system signals - Make debugging harder Replacement by `except Exception:` preserves the same error handling while respecting system-level exceptions. Co-authored-by: Milo @KeloYuan Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -250,7 +250,7 @@ class DataRecord(DataABC, MutableMapping):
|
||||
try:
|
||||
# Let getattr do the work
|
||||
return self.__getattr__(key)
|
||||
except:
|
||||
except AttributeError:
|
||||
raise KeyError(f"'{key}' not found in the record fields.")
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
@@ -266,7 +266,7 @@ class DataRecord(DataABC, MutableMapping):
|
||||
try:
|
||||
# Let setattr do the work
|
||||
self.__setattr__(key, value)
|
||||
except:
|
||||
except AttributeError:
|
||||
raise KeyError(f"'{key}' is not a recognized field.")
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
@@ -280,7 +280,7 @@ class DataRecord(DataABC, MutableMapping):
|
||||
"""
|
||||
try:
|
||||
self.__delattr__(key)
|
||||
except:
|
||||
except AttributeError:
|
||||
raise KeyError(f"'{key}' is not a recognized field.")
|
||||
|
||||
def __iter__(self) -> Iterator[str]:
|
||||
|
||||
@@ -809,7 +809,7 @@ class DatabaseRecordProtocolMixin(
|
||||
self._db_load_phase = DatabaseRecordProtocolLoadPhase.NONE
|
||||
try:
|
||||
del self._db_initialized
|
||||
except:
|
||||
except Exception:
|
||||
logger.debug("_db_reset_state called on uninitialized sequence")
|
||||
|
||||
def _db_clone_empty(self: T_DatabaseRecordProtocol) -> T_DatabaseRecordProtocol:
|
||||
|
||||
@@ -37,7 +37,7 @@ class LoggingCommonSettings(SettingsBaseModel):
|
||||
"""Computed log file path based on data output path."""
|
||||
try:
|
||||
path = SettingsBaseModel.config.general.data_output_path / "eos.log"
|
||||
except:
|
||||
except Exception:
|
||||
# Config may not be fully set up
|
||||
path = None
|
||||
return path
|
||||
|
||||
@@ -133,8 +133,8 @@ class PydanticModelNestedValueMixin:
|
||||
try:
|
||||
self._validate_path_structure(path)
|
||||
pass
|
||||
except:
|
||||
raise ValueError(f"Path '{path}' is invalid")
|
||||
except Exception as e:
|
||||
raise ValueError(f"Path '{path}' is invalid: {e}")
|
||||
path = path.strip("/")
|
||||
# Use private data workaround
|
||||
# Should be:
|
||||
|
||||
Reference in New Issue
Block a user