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

Does Ruff fail to format parts of a file when syntax errors are present? #15166

Open
work4lazy opened this issue Dec 28, 2024 · 1 comment
Open
Labels
formatter Related to the formatter question Asking for support or clarification

Comments

@work4lazy
Copy link

Hello,

I am using the Ruff extension in VSCode to automatically format Python files. However, I have noticed that when I encounter a severe syntax error while writing code, Ruff is unable to properly format any part of this file.

I would like to ask if this behavior is expected: that a severe syntax error in one place prevents Ruff from formatting all other parts of the file correctly?

Thank you for your assistance!

@AlexWaygood AlexWaygood added question Asking for support or clarification formatter Related to the formatter labels Dec 28, 2024
@MichaReiser
Copy link
Member

Yes, this is the expected behavior. We may explore formatting files with syntax errors in the future but it isn't on our immediate roadmap.

Formatting files with syntax errors comes with its own challenges because the formatter should avoid changing your code to something you didn't intend. But we could try to at least format blocks that contain no syntax errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

3 participants