diff options
author | Wolfgang Müller | 2024-11-06 12:34:48 +0100 |
---|---|---|
committer | Wolfgang Müller | 2024-11-06 12:34:48 +0100 |
commit | 9e7ede5afcbc99a3670ee8232ecfbce79da0dde8 (patch) | |
tree | 92b782d654c2f88511f189d7e86b7f9af8eb4017 | |
parent | 9ecf39499a70f7d1e8977aed66fd041356bd9b58 (diff) | |
download | later-9e7ede5afcbc99a3670ee8232ecfbce79da0dde8.tar.gz |
Avoid shadowing builtins
This will hopefully avoid nasty surprises in the future. It's easy to
check since there is already a ruff linter [1] for it which this commit
also enables. Make sure not to complain about exit() [2] since that is
only for interactive use and shouldn't be called in programs anyway.
[1] https://docs.astral.sh/ruff/rules/builtin-attribute-shadowing/
[2] https://docs.python.org/3.12/library/constants.html#exit
-rwxr-xr-x | later | 4 | ||||
-rw-r--r-- | ruff.toml | 4 |
2 files changed, 6 insertions, 2 deletions
@@ -25,8 +25,8 @@ def exit(message=""): sys.exit(f"later: {message}" if message else 0) -def get_xdg(type, fallback): - env = f"XDG_{type.upper()}_HOME" +def get_xdg(directory, fallback): + env = f"XDG_{directory.upper()}_HOME" if env in os.environ: return os.environ[env] return os.path.expanduser(fallback) @@ -8,7 +8,11 @@ select = [ "W", # pycodestyle "I", # isort "UP", # pyupgrade + "A", # flake8-builtins "B", # flake8-bugbear "SIM", # flake8-simplify "FURB" # refurb ] + +[lint.flake8-builtins] +builtins-ignorelist = ["exit"] |