-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
As per the title, if the rule with code E999 is not included in the configuration, then ruff will terminate successfully even if there's a SyntaxError. So, for example, if one wanted to run ruff against only the Pylfakes rules, the logical configuration for the rules would be --select F, but this doesn't work as expected.
Specifically, running ruff --select F <filename.py> exits with code 0 even if there's a SyntaxError - it does print error: Failed to parse but it doesn't raise an error. I believe this shouldn't be the default behavior as it would allow ruff to succeed in automated pipelines even with a SyntaxError (and possibly other F code errors). As a workaround for the mentioned use-case, one can also include E999 in the selected rules. However, this isn't very intuitive since having a SyntaxError means that an AST can't be generated and so, even if E999 isn't really a Pyflakes error, the python code can't be run.
FWIW, ruff rules list E999 as a pycodestyle error code, while in reality it's a code returned by flake8 when it can't generate an AST for a given file. The equivalent pycodestyle code is E901 SyntaxError or IndentationError as listed here.