Skip to content

Add rule to use sys.exit() instead of exit() #787

@JonathanPlasse

Description

@JonathanPlasse

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 #776

Fixed, thanks. (Ruff should have a rule for this!)

Originally posted by @andersk in #776 (comment)


I would like to implement it.
In which rule group would this be added?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions