-
-
Notifications
You must be signed in to change notification settings - Fork 46
Support for running nbqa on quatro format (.qmd) markdown files #881
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
base: main
Are you sure you want to change the base?
Conversation
…on't get turned into cell options
…on't get turned into cell options
|
@MarcoGorelli PR should be ready for another round of workflow runs by the testsuite. Logic has also been simplified. |
|
I've been following this, but I noticed while playing with the current implementation that it adds a bunch of metadata to the file's yaml, e.g., in the case of the example in the PR jupyter:
jupytext:
text_representation:
extension: .qmd
format_name: quarto
format_version: '1.0'
jupytext_version: 1.16.7
kernelspec:
display_name: Python 3
language: python
name: python3Would that be possible to avoid? I don't know how useful it is for the underlying tools, but it certainly takes up a lot of space in an area that often contains important information |
|
That is actually not being done by
And then converts back to The jupytext conversion back to qmd - https://github.com/mwouts/jupytext/blob/main/src/jupytext/jupytext.py#L238. The |
|
Yes, it seems unavoidable without modifying the upstream processes. Thanks for the info! |
Thanks for running the suite. It looks my test case was not robust to changing jupytext version. I have now fixed that. |
|
Sure thanks - if you want to make a separate pr which just fixes a typo or something then after that ci will run without needing approval |
Fortunately, I think we are all passing now? Ready to merge? The current failure with docs seems to be related to |
|
thanks @hguturu ! i don't use nbqa anymore (haven't in years), so I'd just like to please ask:
if so, happy to ship it and make a new release |
|
The code lgtm. As for maintenance of the feature, I do think the best outcome is native support for That's my 2 cents as to whether it's worth maintaining. I have a limited use case (applying ruff to Quarto files), so maybe other users will find this useful for applying other tools to Quarto files. edit: I am still interested in using it in the short term while I wait out a hopefully native implementation in ruff, but I also have another temporary workaround (convert to Jupyter, apply ruff, convert back to Quarto) that works fine but with the same limitations |
|
Yes, I will be available to fix issues if the are reported. I agree with Malcolm on having the other tools support qmd files natively would be ideal, but this will be a good workaround until that happens. I figure I also believe the concerns about metadata changes already effect other markdown formats supported? Since myst would also go through jupytext. Also since quarto recognizes jupytext as a valid way to run quarto notebooks (https://quarto.org/docs/tools/jupyter-lab.html#jupytext), I figure they will work together to ensure the compatibility doesn't break. |
Closes #880
Two main changes:
.qmdwhen using JupytextAdded conversion of leading quartro cell options#|that get changed to# |by black/ruff back to#|(
_restore_quarto_cell_options) - in theory this can be dropped ifblackandruffnatively support this format#|and# |for python due to formatters - Quarto Cell Options Specification quarto-dev/quarto-cli#12364 (comment)test_jupytext.test_qmdand supporting resourcetests/data/notebook_for_testing.qmdto test new functionalityREADME.mdwith.qmdsupport featurerequirements-dev.txtandsetup.cfgwithquarto-clidependency20250324:
Refactored usage of_restore_quarto_cell_optionsso other formats don't break#|and# |are supportedquartoteam if valid behavior or bug inquarto- Quarto Cell Options Specification quarto-dev/quarto-cli#12363PR simplified to just checking
.qmdextension since special handling logic for quarto#|are no longer needed. Authors also confirm{python}is required for runable code blocks (the same ones we format) quarto-dev/quarto-cli#12364 (reply in thread). All other cases of references to python are test with syntax highlighting.Code tested locally with
tox -e pyand all tests passing, so should be ready for another round of github actions.