You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want the Python code in notebooks to get auto-formatted.
At the moment, we're using jupytext --pipe black as a pre-commit hook, which does the job but is not configured quite correctly. The way it works is a bit complex:
The main issue is that the piping process causes code-cell language info to be removed and that breaks pygments lexing in VSCode. In order to retain that, we need to the notebooks to include language-info notebook metadata, which jupyter adds but is not retained in the minimal filtered Myst notebook metadata when it passes through jupytext.
It is possible that in the future we might be able to use ruff to do this job but at present only the .ipynb format for notebooks is supported by ruff-format and it's a pain to have to convert all our '.mdfiles to.ipynband then back again (usingjupytext`) just to format the Python.
Describe the bug
We want the Python code in notebooks to get auto-formatted.
At the moment, we're using
jupytext --pipe black
as apre-commit
hook, which does the job but is not configured quite correctly. The way it works is a bit complex:mwouts/jupytext#1267
The main issue is that the piping process causes
code-cell
language info to be removed and that breakspygments
lexing in VSCode. In order to retain that, we need to the notebooks to includelanguage-info
notebook metadata, whichjupyter
adds but is not retained in the minimal filtered Myst notebook metadata when it passes throughjupytext
.It is possible that in the future we might be able to use
ruff
to do this job but at present only the.ipynb
format for notebooks is supported byruff-format
and it's a pain to have to convert all our '.mdfiles to
.ipynband then back again (using
jupytext`) just to format the Python.astral-sh/ruff#8800 (comment)
So:
language_info
notebook metadata to the project settings.language_info
metadata to the files (at the moment this is manual or open and save injupyter
after step 1){code-cell} ipython3
to code cells.The text was updated successfully, but these errors were encountered: