def str_is_empty(s: str) -> bool: """Check if a string is empty or contains only whitespace.""" if s is None: return True stripped = s.replace(" ", " ") return not bool(stripped)