Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop in auto-fix between E203/E275 #12094

Closed
dhruvmanila opened this issue Jun 28, 2024 · 2 comments · Fixed by #12095
Closed

Infinite loop in auto-fix between E203/E275 #12094

dhruvmanila opened this issue Jun 28, 2024 · 2 comments · Fixed by #12095
Labels
bug Something isn't working fixes Related to suggested fixes for violations fuzzer Surfaced via fuzzing.

Comments

@dhruvmanila
Copy link
Member

Example code:

pass;

The E275 rule tries to add a whitespace after pass keyword but the E203 tries to remove the whitespace before ;.

@dhruvmanila dhruvmanila added bug Something isn't working fixes Related to suggested fixes for violations fuzzer Surfaced via fuzzing. labels Jun 28, 2024
@dhruvmanila
Copy link
Member Author

Although, if you add in E703 (useless-semicolon), there won't be an infinite loop because it would remove the semicolon.

@AlexWaygood
Copy link
Member

If we're picking sides, I think E203 is correct on this one and E275 has it wrong

dhruvmanila added a commit that referenced this issue Jul 2, 2024
## Summary

This PR updates Ruff to **not** generate auto-fixes if the source code
contains syntax errors as determined by the parser.

The main motivation behind this is to avoid infinite autofix loop when
the token-based rules are run over any source with syntax errors in
#11950.

Although even after this, it's not certain that there won't be an
infinite autofix loop because the logic might be incorrect. For example,
#12094 and
#12136.

This requires updating the test infrastructure to not validate for fix
availability status when the source contained syntax errors. This is
required because otherwise the fuzzer might fail as it uses the test
function to run the linter and validate the source code.

resolves: #11455 

## Test Plan

`cargo insta test`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixes Related to suggested fixes for violations fuzzer Surfaced via fuzzing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants