Catch errors when running --pipe black
See original GitHub issueIf you try to run the --pipe black
command over a set of notebooks in one or more directories, and black fails for some reason, the pipe fails at that point.
Non-runnable illustrative fragment:
jupytext --sync --pipe black Part*/*.ipynb
---
[jupytext] Executing black -
reformatted -
All done! ✨ 🍰 ✨
1 file reformatted.
[jupytext] Updating 'Part 03 Notebooks/03.2 Selecting and projecting, sorting and limiting.ipynb'
[jupytext] Updating 'Part 03 Notebooks/.md/03.2 Selecting and projecting, sorting and limiting.md'
[jupytext] Reading Part 03 Notebooks/03.3 Combining data from multiple datasets.ipynb in format ipynb
[jupytext] Loading 'Part 03 Notebooks/.md/03.3 Combining data from multiple datasets.md'
[jupytext] Executing black -
error: cannot format -: Cannot parse: 156:9: result = %sql SELECT * FROM quickdemo WHERE value > 25
Oh no! 💥 💔 💥
1 file failed to reformat.
In the above case, black failed trying to parse a line that assigned the result of a line magic call to a variable.
It would be useful if the Jupytext pipe did not fail, but did perhaps warn that a file could not be parsed.
Another solution might be to allow a cell to be tagged as no-black
or similar and be ignored somehow (--ignore-tag no-black
?) (I’m not sure if you apply the formatter at the cell level?)
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Node.js: Error handling when using pipe with streams
The pipeline handles errors and closes streams correctly. Using a pipeline, the example ... catch( error ){ console.log('error.....'); }.
Read more >Global Error Handling in Angular - Philipp Kief
In this article you will learn how to catch various errors in Angular — one of the world's most popular front end frameworks...
Read more >Catching Multiple Exception Types and Rethrowing ...
The catch clause specifies the types of exceptions that the block can handle, and each exception type is separated with a vertical bar...
Read more >about Try Catch Finally - PowerShell | Microsoft Learn
A try statement can include multiple catch blocks for the different specified error types. The finally keyword is followed by a statement list ......
Read more >Angular error handling best practices - YouTube
In todays angular 4/5/6 error handling best practices tutorial session I will demonstrate the best possible ways to handle angular http ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @psychemedia , I expect to have fixed both issues in the development version. Feel free to give it a try, cf. https://jupytext.readthedocs.io/en/latest/developing.html
Suggestion for how to do this:
Then, using
ast.parse
, detect lines withget_ipython().run_line_magic
(and other functions which magics would get transformed to) and comment them out (e.g. of what I’m referring to: https://github.com/psf/black/pull/2357 , wherejupytext
has been mentioned)