1import re 2 3def sanitize_username(username: str) -> str: 4 """Remove illegal characters from a username: allow [a-zA-Z0-9-_@].""" 5 return re.sub(r"[^a-zA-Z0-9-_@]", "", username or "")