-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
The Jupyter formatter has a couple of issues when running on notebooks.
One is it removes semicolons at the end of lines. black[jupyter] does not remove semicolons at the end of lines when running on a notebook, since it's used to mark output as hidden, for example when plotting. plt.plot(); will show the plot but not print out the repr for the Artists that the plot method returns.
Edit: On the last line of a cell. Related: #7300 which is for the linter. But that's rule based, so it's easy to turn it off for *.ipynb files, while there isn't a workaround for the formatter, making it a blocker.
(Fixed in main) The other is that it can't read a notebook that black and ruff-lint are able to read. The error is:
error: Failed to format docs/examples/HistDemo.ipynb: source contains syntax errors: ParseError { error: UnrecognizedToken(Percent, None), offset: 0, source_path: "<filename>" }
I'm guessing it's choking on a line magic, perhaps? The file does have this line:
%config InteractiveShell.ast_node_interactivity="last_expr_or_assign"Which is the only % in the file.