ruff
ruff copied to clipboard
Add rule to use sys.exit() instead of exit()
exit() is not a built-in function and is only defined if the site module is imported during Python's initialization (which, for example, can be disabled with -S option passed to the interpreter). You should use sys.exit() instead:
sys.exit(os.spawnv(os.P_WAIT, ruff, [ruff, *sys.argv[1:]]))
_Originally posted by @jack1142 in https://github.com/charliermarsh/ruff/pull/776#
Fixed, thanks. (Ruff should have a rule for this!)
Originally posted by @andersk in https://github.com/charliermarsh/ruff/pull/776#discussion_r1024474885
I would like to implement it. In which rule group would this be added?
Awesome! This should go in the RUF group since it's new / custom to Ruff.
How can I check if exit() has not been overridden?
Which, in this case, should not trigger an error.
We have to resolve that for https://github.com/charliermarsh/ruff/issues/780. We need to check if the BindingKind on the identifier is still BindingKind::Builtin. You could omit it for now if you'd rather wait until it's solved for #780.