Formatting with black doesn't update the file in-place
See original GitHub issueEnvironment data
- VS Code version: 1.56.2
- Extension version (available under the Extensions sidebar): v2021.5.842923320
- OS and version: Arch Linux 5.12.5
- Python version (& distribution if applicable, e.g. Anaconda): 3.6.8, using pyenv
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): pyenv. I think it’s virtualenv under the hood?
- Value of the
python.languageServer
setting: Pylance
Expected behaviour
When formatting a python file with black, from the palette, right clicking, or format-on-save, the file should be updated with the changes.
Actual behaviour
The black process can be seen running, but the file does not get updated.
Steps to reproduce:
- Write a python file with a
''
wrapped string (black should convert this to""
) - set up black as formatter
- format the file
Logs
> ~/.pyenv/versions/shiphero-shipping/bin/python ~/.vscode/extensions/ms-python.python-2021.5.842923320/pythonFiles/pyvsc-run-isolated.py black --diff --quiet ~/workspace/shiphero/Shiphero-API/shipping/shipping/application/quoting.py.43d88024a1c151b0045448c575b5425b.tmp
cwd: ~/workspace/shiphero/Shiphero-API
> ~/.pyenv/versions/shiphero-shipping/bin/python ~/.vscode/extensions/ms-python.python-2021.5.842923320/pythonFiles/pyvsc-run-isolated.py black --diff --quiet ~/workspace/shiphero/Shiphero-API/shipping/shipping/application/quoting.py.43d88024a1c151b0045448c575b5425b.tmp
cwd: ~/workspace/shiphero/Shiphero-API
Formatting with black failed.
Error: Invalid patch string: [1;37m--- /home/lacrymology/workspace/shiphero/Shiphero-API/shipping/shipping/application/quoting.py.43d88024a1c151b0045448c575b5425b.tmp 2021-05-28 17:46:43.167718 +0000[0m
Issue Analytics
- State:
- Created 2 years ago
- Comments:12
Top Results From Across the Web
The basics - Black 22.12.0 documentation
You can run Black as a package if running it as a script doesn't work: ... By default Black reformats the files given...
Read more >How to Auto-Format Your Python Code with Black
black --check . : This will check which python file(s) can be formatted in the current folder (but doesn't actually modify the python...
Read more >Formatter black is not working on my VSCode...but why?
Just run from the command line if you need to format a lot of files at once. First, check if you have this...
Read more >black · PyPI
Black is a PEP 8 compliant opinionated formatter. Black reformats entire files in place. Style configuration options are deliberately limited and rarely added....
Read more >Stylising your Python code: An introduction to linting and ...
Black reformats entire files in place, applying its own PEP8-compliant coding style which is detailed here. Examples. Formatting a Python script.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@karrtikr issue was that someone added the
color = true
option to the project’spyproject.toml
file, so the diff contained color markers and it didn’t apply. Sorry@Lacrymology Glad you were able to diagnose that🎉
@CalebEverett Your issue seems different, please open a new issue.