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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]聽Support for black in Jupyter Notebooks #87

Open
vancromy opened this issue Jun 30, 2022 · 6 comments
Open

[Feature Request]聽Support for black in Jupyter Notebooks #87

vancromy opened this issue Jun 30, 2022 · 6 comments
Labels
feature-request Request for new features or functionality needs community feedback

Comments

@vancromy
Copy link

Hello 馃憢,

First of all thanks for your hard work for bringing black to VSCode. My autoformatting has become so much more seamless now that I don't need to worry about having it installed in all of my envs/projects.

I was wondering whether you have looked into (apologies if this has been asked before - I did a quick scan but didn't find anything) enabling the use of black in jupyter notebooks. The isort plugin for VSCode has done this and black do mention in their docs that it can be enabled by pip installing black[jupyter] (https://black.readthedocs.io/en/stable/getting_started.html). Perhaps this could be a user enabled feature if it is not desired to have this by default? :)

@github-actions github-actions bot added the triage-needed Issue is not triaged. label Jun 30, 2022
@karthiknadig karthiknadig added feature-request Request for new features or functionality needs community feedback and removed triage-needed Issue is not triaged. labels Jun 30, 2022
@karthiknadig
Copy link
Member

@vancromy We currently support formatting individual python cells in a notebook. Since the Language Server Protocol (v3.16) treats each cell as a document. To support the document as a whole, we will need to upgrade to LSP v3.17 which allows us to look at notebooks as a whole document. Currently there is a technical limitation because the library that we use (pygls) is still on v3.16 of LSP. Once that is upgraded this should be fairly easy to do and entirely in python. We are happy to take any PRs if the community wants to get to this before we do.

@vancromy
Copy link
Author

@karthiknadig while we wait for this feature, could you elaborate on how individual cells can be formatted using the black plugin? Is it a command from the control palette?

@vancromy
Copy link
Author

vancromy commented Nov 23, 2022

Apologies for the spam but I discovered the answer to my own question and thought it would help others to document it here. This can be achieved either via right-clicking on the cell and selecting "Format Cell" or by using the dedicated shortcut for that control (via the Control Palette or keyboard shortcut).

@danieltomasz
Copy link

Sorry for spam; as the other issue was closed in the favour of this one, are there any progress with leaving the semi-colon in jupyter notebooks? It keeps to be removed

@karthiknadig
Copy link
Member

@danieltomasz pygls merged the notebook support last week. Waiting for a release to start work on this.

@ankostis
Copy link

Maybe it psf/black#4025 it relevant about dealing with notebook syntax from hydrogen .py files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality needs community feedback
Projects
None yet
Development

No branches or pull requests

4 participants