Swallowed Exception (ARCH2151)
Key python.logging.swallowed-exception · Severity warning · Category logging
Handlers that catch and silently discard an exception (returning None/False or a default) hide failures. Unlike empty blocks they have a body, yet still provide no diagnostic information.
Incorrect
Section titled “Incorrect”def load_config(path): try: return parse(path) except Exception: return NoneCorrect
Section titled “Correct”import logging
logger = logging.getLogger(__name__)
def load_config(path): try: return parse(path) except Exception: logger.exception("Failed to load config: %s", path) raiseLog the exception and re-raise where possible; do not silently return a fallback.