Open rijobro opened 3 years ago
I'm not sure if this can be solved with --pipe-fmt
. I can't see a list of arguments for this option, I've only seen auto:percent
and py:percent
. I'm not sure what the latter does, but it doesn't solve my problem.
Hi @rijobro , thanks for sharing your use case!
This is removing spaces from the end of markdown lines, where a double space is needed to add a paragraph break.
Very interesting! Yes sure the Python-oriented tools don't know that the comment is written in Markdown, and thus they don't respect this specificity.
Is there any way to prevent these autofixes from being applied to anything other than python cells?
Not at the moment. --pipe
runs the selected tool on the text representation of the full notebook (in the format --pipe-fmt
, which as you saw defaults to the percent format, i.e. the one with explicit # %%
cell markers - probably the most robust format for this use case).
But I agree, most of the tools above will only act on the code, so it would make sense to allow running them only on the code cells. Would a --pipe-code
option be what you're after? If you are open to making a PR, here a a few pointers. I think we could:
--pipe-code
mode), make a copy of the original notebook that contain only the code cells before exporting it to the text buffer:
https://github.com/mwouts/jupytext/blob/41b7e9c93b50da1d6feb486aceb2c4d534374090/jupytext/cli.py#L922combine_inputs_with_outputs
function that we want to preserve the non-code cells. Thanks for the quick reply!
Your suggested solution certainly looks like it would solve the problem. Unfortunately, I don't think I'll have time to implement it. In the meantime I've opted for a quick-and-easy fix: --pipe "autopep8 - --ignore W291"
.
This won't remove any EOL spaces for comments, which will include markdown and non-markdown, but it's a liveable solution for the time being.
To autofix notebooks, I run a command like this:
This is removing spaces from the end of markdown lines, where a double space is needed to add a paragraph break.
Is there any way to prevent these autofixes from being applied to anything other than python cells?