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

Extension 'Black Formatter' is configured as formatter but it cannot format 'Python'-files #307

Closed
SingL3 opened this issue Sep 7, 2023 · 5 comments
Assignees
Labels
triage-needed Issue is not triaged.

Comments

@SingL3
Copy link

SingL3 commented Sep 7, 2023

Vscode info:

Version: 1.81.1 (Universal)
Commit: 6c3e3dba23e8fadc360aed75ce363ba185c49794
Date: 2023-08-09T22:20:33.924Z
Electron: 22.3.18
ElectronBuildId: 22689846
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin x64 21.6.0

I am using this extension in remote machine with Remote extension, I install this extension and it work well the first time. However now it just doesnt work. I have checked the console output and there is only log from connecting remote.
Here is the console in dev tools:
image

@github-actions github-actions bot added the triage-needed Issue is not triaged. label Sep 7, 2023
@karthiknadig
Copy link
Member

karthiknadig commented Sep 7, 2023

@SingL3 Are you using format on save or did you have a portion of the text selected when trying to format? Are you using some shortcut to format?

@karthiknadig
Copy link
Member

Please share your workspace and user settings.

@SingL3
Copy link
Author

SingL3 commented Sep 7, 2023

@karthiknadig
I am using format by selecting code and Command+K Command+F(or right click and format selected text)
Selected code:

def get_prompt(
    message: str, chat_history: list[tuple[str, str]], system_prompt: str
) -> str:
    texts = [f'<s>[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\n']
    # The first user input is _not_ stripped
    do_strip = False
    for user_input, response in chat_history:
        user_input = user_input.strip() if do_strip else user_input
        do_strip = True
        texts.append(f'{user_input} [/INST] {response.strip()} </s><s>[INST] ')
    message = message.strip() if do_strip else message
    texts.append(f'{message} [/INST]')
    return ''.join(texts)

User setting(remote):

{
    "python.defaultInterpreterPath": "/mnt/data/conda/envs/oasst/bin/python",
    "python.analysis.extraPaths": [
        "${python.pythonPath}/../../lib/python3.(8|9|10|11)/site-packages",
    ],
    "python.experiments.enabled": false,
    "editor.formatOnType": true,
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnType": true
    },
    "python.formatting.provider": "none",
}

@karthiknadig karthiknadig self-assigned this Sep 7, 2023
@karthiknadig
Copy link
Member

@SingL3 black itself does not support format selection. Please use format document command instead.

This would be a feature request on black here: https://github.com/psf/black/issues

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Sep 7, 2023
@karthiknadig karthiknadig pinned this issue Sep 7, 2023
@karthiknadig karthiknadig changed the title Configure Default Formatter: Extension 'Black Formatter' is configured as formatter but it cannot format 'Python'-files Extension 'Black Formatter' is configured as formatter but it cannot format 'Python'-files Sep 7, 2023
@karthiknadig
Copy link
Member

Notes for anyone else running into this issue:
Use format document:
image

Format selection is not supported by black tool itself, hence the extension doesn't support it:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Issue is not triaged.
Projects
None yet
Development

No branches or pull requests

2 participants