-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
F504: Carriage return prevents expression extraction #4899
Comments
Perhaps a bug in LibCST, which is failing to parse it? |
I'm not so clear on that. Is this because libCST is used to parse the expression for repair? |
Yeah |
The LibCST parse call throws an error, but it could be our fault, not theirs. We may need to wrap the expression in parentheses before parsing. |
I did a quick experiment and this doesn't help either, it still throws an error: libcst_native::parse_expression(&format!("({})", &contents))
|
This is a bug in LibCST. It seems they don't support mixed newlines: Changing the For example: |
Upstream fix in LibCST Instagram/LibCST#1007 |
The upstream fix is merged. All that we need to do now is to update libcst 🫣 |
## Summary This PR updates the revision of `LibCST` dependency to Instagram/LibCST@9c263aa inorder to fix #4899 ## Test Plan The test case including the carriage return (`\r`) character was added for `F504` and then `cargo test`. fixes: #4899
In Python, a standalone carriage return character (0xd or
\r
) is considered whitespace. One could easily argue that this is quite problematic, given that carriage returns can potentially be used to hide parts of source code. That said, it does trigger a failure in F504 (\r
replaced literally):And a downloadable version to test against.
I would simply mark F504 as sometimes fixable, but this solution doesn't feel right. Instead, this feels indicative of incorrect handling of carriage returns as plain whitespace. At the same time, standalone carriage returns should probably be marked as invalid anyways.
I leave this to the discretion of the developers of Ruff 🙂 We should find a fix one way or another to avoid future issues with this being marked as a failure case in the fuzzer.
Discovered by #4822.
The text was updated successfully, but these errors were encountered: