Skip to content

Implement formatting using Language Server Protocol #17918

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
1 of 3 tasks
karthiknadig opened this issue Nov 3, 2021 · 4 comments
Closed
1 of 3 tasks

Implement formatting using Language Server Protocol #17918

karthiknadig opened this issue Nov 3, 2021 · 4 comments
Assignees
Labels
feature-request Request for new features or functionality meta Issue that is tracking an overall project verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@karthiknadig
Copy link
Member

karthiknadig commented Nov 3, 2021

Implement following formatters using LSP:

  • black
  • autopep8
  • yapf
@karthiknadig karthiknadig added feature-request Request for new features or functionality meta Issue that is tracking an overall project triage-needed Needs assignment to the proper sub-team labels Nov 3, 2021
@karthiknadig karthiknadig removed the triage-needed Needs assignment to the proper sub-team label Nov 3, 2021
@memeplex
Copy link

memeplex commented Dec 6, 2021

#18121 was closed in favor of this. Ok, but I'm not sure that moving formatting to LSP will automatically work without quirks inside notebook cells. For example, black works at the file level, some criteria that is sensible at that level isn't at the cell level. I reckon that Jupyter Lab extensions that do black formatting use specific heuristics to deal with these issues.

@breathe
Copy link

breathe commented Apr 11, 2022

Any update on this -- trying to decide if its worth it to file a bug about the existing formatting behaviors ...

For example -- it doesn't seem to be possible to force the yapf extension to use one specific yapf implementation for a python mono-repo ... The extension won't expand variables in the path arguments provided to yapf and will always choose the python environment associated with the file as the root path from which to search for python ... This forces you to install yapf in every virtual env within a monorepo -- which is highly undesirable.

With below for example: trying to point the extension at the yapf installed in the venv associated with the 'iac' workspace:

  "python.formatting.provider": "yapf",
  "python.formatting.yapfArgs": [
    "--style",
    "${workspaceFolder:iac}/.style.yapf"
  ],
  "python.formatting.yapfPath": "${workspaceFolder:iac}/.venv/bin/yapf"
Error: spawn /path/to/some/python/workspace/${workspaceFolder:iac}/blah/.venv/bin/yapf ENOENT

@karthiknadig karthiknadig self-assigned this Apr 11, 2022
@karthiknadig karthiknadig added this to the April 2022 milestone Apr 11, 2022
@karthiknadig
Copy link
Member Author

${workspaceFolder:iac} this type of expansion is not support. Actually VS Code itself does not support expanding variables in settings. This was something that python extension added. We do expand it but in limited scenarios, so ${workspaceFolder} should work for now, but ${workspaceFolder:iac} won't.

I am currently working on this for this milestone.

@karthiknadig
Copy link
Member Author

karthiknadig commented Apr 20, 2022

Black formatter (pre-release) now available here: https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter

@karthiknadig karthiknadig modified the milestones: April 2022, May 2022 Apr 25, 2022
@karthiknadig karthiknadig added the verified Verification succeeded label May 31, 2022
@joaomoreno joaomoreno added the verification-needed Verification of issue is requested label Jun 1, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality meta Issue that is tracking an overall project verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants