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

Support formatting of all cells in notebook #1187

Closed
DonJayamanne opened this issue Aug 6, 2020 · 11 comments
Closed

Support formatting of all cells in notebook #1187

DonJayamanne opened this issue Aug 6, 2020 · 11 comments
Labels
notebook-intellisense Intellisense & other language features in notebook cells for any language verified Verification succeeded
Milestone

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Aug 6, 2020

Currently we have support for formatting individual cells
However formatting entire document does not seem to work (VSC Has a specific command for this)

Note: black supports ipynb out of the box

See #1187 (comment)

@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 13, 2020
@greazer greazer added enhancement notebook-intellisense Intellisense & other language features in notebook cells for any language and removed internal-contributor labels Aug 7, 2021
@nickeubank
Copy link

For what it's worth, I'm not actually sure this is feasible -- notebook cells are often run and written out of sequence, and I'm not sure if a formatter like black would be able to parse out-of-execution-order cells effectively, could it? I think a better solutions might be #7058

@MarcoGorelli
Copy link

For what it's worth, I'm not actually sure this is feasible -- notebook cells are often run and written out of sequence, and I'm not sure if a formatter like black would be able to parse out-of-execution-order cells effectively, could it? I think a better solutions might be #7058

Not sure I see what the issue is, but black's current way of running Jupyter Notebooks doesn't require cells to have been executed in order

@nickeubank
Copy link

Oh great! Right, I guess black doesn't care about syntax stuff like running undefined vars. Nevermind!

@jucor
Copy link

jucor commented Oct 9, 2021

@DonJayamanne as workaround, since two months ago black supports formating .ipynb files :)

@greazer greazer added this to the October 2021 milestone Oct 10, 2021
@rchiodo
Copy link
Contributor

rchiodo commented Oct 13, 2021

This will be fixed in the next release of the python extension. See this issue here:
microsoft/vscode#130719

@rchiodo rchiodo closed this as completed Oct 13, 2021
@rchiodo rchiodo added the verified Verification succeeded label Nov 1, 2021
@nickeubank
Copy link

@rchiodo Is it? I'm not seeing where this has been fixed...

@rchiodo
Copy link
Contributor

rchiodo commented Nov 15, 2021

Right click on a cell and pick format notebook:

image

@nickeubank
Copy link

Ah, nice! Is there a way to get this respect the usual "format on save" option for VS Code? And/or should that be a separate issue?

@rchiodo
Copy link
Contributor

rchiodo commented Nov 15, 2021

Format on save is actually this issue here. Please upvote it:
microsoft/vscode#120432

@nickeubank
Copy link

Perfect, thanks so much! Appreciate the handholding. :)

@nickeubank
Copy link

(Sharing with my students too, so if you see a flurry of upvotes, it's not spam. :) They're tired of getting points off for bad formatting)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
notebook-intellisense Intellisense & other language features in notebook cells for any language verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants