Jupytext in a pre-commit disagreement with trailing-whitespace and prettier
See original GitHub issueHi,
I am trying to run jupytext
as a first step in pre-commit
, before running among others trailing-whitespace
and prettier
.
My goal is for jupytext to generate .md
files based on .ipynb
files, since these are easier to version control than .ipynb
.
The idea is that pre-commit will pass if no new .md
file is added, and if no existing .md
file is changed by jupytext.
The way I implemented this seems to cause a problem with two other hooks, trailing-whitespace
and prettier
. The way jupytext formats the .md
files cause trailing-whitespace
and prettier
to fail and adjusting the code.
Is there any way to adjust jupytext
or the way I use it, so that these other hooks do not fail?
This is my file .pre-commit-config.yaml
which lives in the root directory:
# NOTE: The versions can be updated by calling
# pre-commit autoupdate
repos:
- repo: local
hooks:
- id: jupytext
name: jupytext
entry: jupytext --to .md notebooks/*.ipynb
files: .ipynb
language: python
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-docstrings
- repo: https://github.com/prettier/prettier
rev: 2.0.5
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
additional_dependencies: ["-r requirements.txt"]
If I update an .ipynb
file and run pre-commit, this happens:
Immediately re-running pre-commit causes all other notebooks to be updated by jupytext,.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (10 by maintainers)
Top GitHub Comments
Oh, that would be awesome!
@mwouts Yeah, but my pre-commit hook downloads from pip so until it’s published I can’t remove that workaround. 👍 I do experience issues like #553, but it hasn’t broken anything, yet. Also waiting for that fix to be merged.