Skip to content

Format on save doesn't work for black when using conda run #9487

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

Closed
Gonzalo933 opened this issue Jan 9, 2020 · 5 comments
Closed

Format on save doesn't work for black when using conda run #9487

Gonzalo933 opened this issue Jan 9, 2020 · 5 comments
Labels
area-formatting bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on

Comments

@Gonzalo933
Copy link

Environment data

  • VS Code version: 1.41.1
  • Extension version (available under the Extensions sidebar): 2020.1.57204
  • OS and version: Windows 10 / CentOS 7.5 (tried on both)
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.3.final.0 (Anaconda3)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): jediEnabled set to true

Steps to Reproduce:

  1. Install Black for Python pip install black:
  2. Edit the following settings in settings.json:
"python.formatting.blackArgs": [
        "--line-length",
        "100"
    ],
"editor.formatOnSave": true,
"python.formatting.provider": "black",
  1. Create a file with the following content:
dict(
    foo="bar",
    foo4="bar",foo5="bar"
)
  1. Save the file (name it: black_bug.py). The file contents do not change, but the expected results was for the file to be changed to:
dict(foo="bar", foo4="bar", foo5="bar")

(the same as executing black --line-length 100 black_bug.py)

I do see that the following command has been executed in the console (output > Python)

conda run -n base python -m black --line-length 100 --diff --quiet ~/black_bug.py
cwd: ~

The same problem happens when using autopep8 or other formatter

@Gonzalo933 Gonzalo933 added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Jan 9, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jan 9, 2020
@karrtikr
Copy link

I am able to reproduce the issue, thanks. The issue happens only with the conda interpreter, so you can select some other interpreter as a workaround.

It will be fixed along with #9490.

@karrtikr karrtikr changed the title Format on save stopped working Format on save doesn't work for black when using conda run Jan 10, 2020
@karrtikr karrtikr removed their assignment Jan 10, 2020
@Gonzalo933
Copy link
Author

Another workaround is to use the previous version (2019.11.50794)

@FeryET
Copy link

FeryET commented Apr 27, 2020

This still happens. Any updates on this?

@karrtikr
Copy link

Please open up a new issue, your issue is likely different. conda run is no longer used with the latest version of the extension.

@karrtikr karrtikr self-assigned this Oct 22, 2021
@karrtikr karrtikr added the investigating We are looking into the cause of the issue label Oct 22, 2021
@karrtikr karrtikr removed their assignment Nov 4, 2021
@karrtikr karrtikr removed the investigating We are looking into the cause of the issue label Nov 4, 2021
@github-actions github-actions bot removed the needs PR label Aug 9, 2022
@karrtikr karrtikr added the needs PR Ready to be worked on label Aug 9, 2022
@karrtikr
Copy link

Closing as fixed according to #9487 (comment)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-formatting bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on
Projects
None yet
Development

No branches or pull requests

5 participants