Skip to content

Commit

Permalink
Add a NotebookError type to avoid returning Diagnostics on error (#…
Browse files Browse the repository at this point in the history
…7035)

## Summary

This PR refactors the error-handling cases around Jupyter notebooks to
use errors rather than `Box<Diagnostics>`, which creates some oddities
in the downstream handling. So, instead of formatting errors as
diagnostics _eagerly_ (in the notebook methods), we now return errors
and convert those errors to diagnostics at the last possible moment (in
`diagnostics.rs`). This is more ergonomic, as errors can be composed and
reported-on in different ways, whereas diagnostics require a `Printer`,
etc.

See, e.g.,
#7013 (comment).

## Test Plan

Ran `cargo run` over a Python file labeled with a `.ipynb` suffix, and
saw:

```
foo.ipynb:1:1: E999 SyntaxError: Expected a Jupyter Notebook, which must be internally stored as JSON, but found a Python source file: expected value at line 1 column 1
```
  • Loading branch information
charliermarsh committed Sep 1, 2023
1 parent 17a44c0 commit 60132da
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 334 deletions.
Loading

0 comments on commit 60132da

Please sign in to comment.