Magic number (ARCH2182)
Key python.quality.magic-number · Severity info · Category quality
Bare numbers embedded in code hide their meaning and force a hunt across the codebase when they change. Move them into named constants.
Incorrect
Section titled “Incorrect”def session_expired(last_seen): return time.time() - last_seen > 1800Correct
Section titled “Correct”SESSION_TIMEOUT_SECONDS = 1800
def session_expired(last_seen): return time.time() - last_seen > SESSION_TIMEOUT_SECONDSExtract meaningful numeric literals into clearly named module constants.