-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Black formatter doesn't do anything #7645
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
Comments
Hi @dfarley1. Thanks for letting us know about this problem. The information you've provided is helpful. The It's just a hunch, but this may be related to #6911. |
I just tried it with a saved file and I'm getting the same results: "Format Document" ran, there was no suffix on the filename, but the file didn't change. |
@dfarley1, sorry for the delay. I'm still looking into it, but haven't been able to reproduce the problem so far. I'll keep investigating and let you know if I have any questions. |
I have the same issue, and I guess the problem lies in the parameter |
Everything works fine after upgrading vscode to |
I'm running 1.39.1 and it's still not working for me. Same behavior: python output shows black running but the file itself isn't changing at all. Tried with an already saved and an unsaved file. |
@dfarley1, thanks for the update. I'm guessing that updating to the latest version of the extension hasn't helped either. You mentioned before that you have a custom PYTHONPATH from a .env file. Do you have the problem if you remove the "python.envFile" setting? Also, do you have any python-related settings in your user settings.json? |
Yup, I'm on version 2019.10.44104. I tried removing the
|
Let's try simplifying. What happens if you using the following workspace settings.json? {
"python.pythonPath": "/usr/bin/python3",
"python.linting.enabled": false,
"python.formatting.provider": "black",
"[python]": {
"editor.formatOnSave": true,
"editor.formatOnSaveTimeout": 5000,
}
} Also, what is the command that the extension runs? (check the "Python" output panel) |
Here's the output I got when hitting Save on a badly formatted file, the file did not get fixed
Here's the output when I hit Format on an already saved file, the file did not get fixed
Here's the output if I run the command in the VSCode terminal (inside the container), the file did not get fixed (due to
|
@dfarley1, I may have been able to reproduce the problem. Here's what I did:
import sys, \
os
... At this point So it sounds like the failure I ran into isn't the same as yours. From what you have indicated, you do not have any bad syntax and you are actually getting a diff when running the command manually. Is that correct? Here are a couple more questions:
|
I followed your steps using a new folder and I'm getting the same behavior. Black runs but does not fix the file.
Correct, linting works and a real diff appears.
No, I did the same steps without a container and formatting via VSCode works as expected. |
So following the steps I enumerated above, you were able to reproduce the problem? If so then there is something funny going on. What version of docker are you using? |
I've updated VSCode and extensions to the latest versions, respawned my container, and rebooted my host PC a number of times while testing so there's something systemic going on. |
Until we can reproduce this there isn't a lot we can do, unfortunately. Do you see anything out of the ordinary in any of the output panels (not just the Python-related ones)? Which output panels can you see? |
I can see Tasks, Extensions, Python, Git, Python Test Log, Gitlens, and logs for Extension Host, Remote Server, Window, Main, Shared, and Remote Extension Host. All of the panels look OK to me, the only error even during a
|
Yeah, that doesn't look related. |
Is this a container that you created via VS Code (command For my example code I picked the "Python 3" (python:3) configuration. That created a container with Python 3.8 ready to go. I installed black (18.6v2) there and triggered formatting. It correctly re-formatted the file. I also tried it with the latest release of black, which also worked. |
Also, I made sure add |
And just to be clear, when you ran my example code, you did it in a new folder (ergo a new container), right? I've noticed that it's tricky to get a fresh container when using VS Code to create it. |
I did not create the container using VSCode, I've been trying to "integrate" VSCode with a pre-existing build system that lives inside a container based on Gentoo. I figured if VSCode can edit files, run flake8, and do everything else then it should be fine to run black as well.
I've never touched anything related to Jedi, why do you say I'm using it and why would it affect anything?
No, I did not create a new container. I only created a new workspace inside the container that our build spawns. |
Regarding Jedi, the "python.jediEnabled" setting controls whether the extension uses Jedi or the language server. By default it is set to "true". Just to be sure, I set it explicitly. I'm not sure it would have any effect, but I'm trying to get everything exactly the same. :) |
Do you have the same problem in a container that VS Code creates? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I haven't had the chance to try out my own container. I'm not sure what caused it but at some point over the last week formatting started working. I know VSCode itself had an update, did the extension? I don't think anything in our container environment changed. |
The last extension release was in November. So is everything working for you now? If so, feel free to close this issue. |
Environment data
I'm using Remote-Containers to work inside a docker container.
Here's my
/depot/.vscode/settings.json
:Expected behaviour
Saving a Python file or using "Format Document" command should format the document
Actual behaviour
Nothing happens to the file when saving or using the "Format Document" command.
If I manually run the command inside the container there's a fairly large diff output so black appears to be worked as expected and finding changes to make.
Running without
--diff --quiet
reformats the file and is reflected in VSCode.Steps to reproduce:
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
; turn on source maps to make any tracebacks be useful by runningEnable source map support for extension debugging
)The text was updated successfully, but these errors were encountered: