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

Jupyter Notebook outputs raw source code upon fixing via stdin #7747

Closed
charliermarsh opened this issue Oct 1, 2023 · 0 comments · Fixed by #7748
Closed

Jupyter Notebook outputs raw source code upon fixing via stdin #7747

charliermarsh opened this issue Oct 1, 2023 · 0 comments · Fixed by #7748
Assignees
Labels
bug Something isn't working cli Related to the command-line interface

Comments

@charliermarsh
Copy link
Member

If you run, e.g., cat Untitled.ipynb | cargo run -p ruff_cli -- check --stdin-filename Untitled.ipynb -n --fix, then the content we write to stdout is the fixed source code. Writing this back to the notebook will leave you with an invalid notebook! Instead, we need to write back the entire JSON structure, including the fixed content.

@charliermarsh charliermarsh added bug Something isn't working cli Related to the command-line interface labels Oct 1, 2023
@charliermarsh charliermarsh self-assigned this Oct 1, 2023
charliermarsh added a commit that referenced this issue Oct 2, 2023
## Summary

When writing back notebooks via `stdout`, we need to write back the
entire JSON content, not _just_ the fixed source code. Otherwise,
writing the output _back_ to the file will yield an invalid notebook.

Closes #7747

## Test Plan

`cargo test`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to the command-line interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant