-
Notifications
You must be signed in to change notification settings - Fork 921
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
Ruff added extra string to code when formating #11801
Comments
Uff, that's not good. Do you roughly remember what you were adding when this happened? I suspect that this is an issue with range formatting because this isn't happening when I paste your example into the playground. |
I didn't add anything to Ruff, rather I replaced the black formatter with Ruff's. In addition to the usual Ruff setup, I also added Jupiter Notebook support (it's in the settings). And that's pretty much it. I don't remember any other additions. Here is the list of extensions that I have installed in VS Code:
|
Thanks for sharing the additional data. Do you remember the changes you made to that file? I assume you made some edits, hit save and VS code formatted the code. @charliermarsh I think there have been instances where Ruff and the isort extension don't get along. Any chance that might be related? |
It could. If you have both extensions installed, code is often repeated at the bottom of the file. It's a bug in VS Code itself: microsoft/vscode#174295 |
Yes, it is. I copied that code, pasted it and pressed CTRL + S (save file) and since I have it set to format on save, it formatted itself. I thought I had described it explicitly, sorry |
Yeah, I think you either need to uninstall isort or disable Ruff's import formatting. This issue arises when you have multiple extensions installed that want to handle import formatting. In that case, VS Code ends up running them over one another, leading to contents duplicated like this. |
This bug was on Ruff version ruff 0.4.7 and also on ruff 0.4.8
When I format this code:
Ruff makes this:
He is adding new (extra)
return
:My VS code settings (settings.json):
The text was updated successfully, but these errors were encountered: