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

Notebook JSON inconsistency for Google Colab #8370

Open
dhruvmanila opened this issue Oct 31, 2023 · 0 comments
Open

Notebook JSON inconsistency for Google Colab #8370

dhruvmanila opened this issue Oct 31, 2023 · 0 comments
Labels
notebook Related to (Jupyter) notebooks wish Not on the current roadmap; maybe in the future

Comments

@dhruvmanila
Copy link
Member

I'm not sure if this deserves its own issue, but: Would it be possible to use extend-include = ["*.ipynb"] and ruff format to only re-format the Python code in cells, and not the ipynb file itself?

My users typically edit notebooks in Google Colab. Google Colab uses two-space indentation in the ipynb file, instead of the typical one-space indentation. ruff format currently re-indents with one space. As such, edit history becomes difficult/impossible to track, because effectively every line gets rewritten between the user saving from Google Colab (changing to 2 spaces) and CI running ruff format (changing to 1 space).

Google Colab also puts keys like metadata, nbformat, nbformat_minor at the top of the file, but ruff format moves these to the bottom. ruff format also changes the order of execution_count, outputs, etc.

I would love to be able to opt out of ipynb formatting, so that only the Python code inside cells is reformatted.

Originally posted by @jpmckinney in #5188 (comment)

@MichaReiser MichaReiser added the formatter Related to the formatter label Oct 31, 2023
@MichaReiser MichaReiser added the wish Not on the current roadmap; maybe in the future label Dec 22, 2023
@dhruvmanila dhruvmanila added notebook Related to (Jupyter) notebooks and removed formatter Related to the formatter labels Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notebook Related to (Jupyter) notebooks wish Not on the current roadmap; maybe in the future
Projects
None yet
Development

No branches or pull requests

2 participants