question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jupytext in a pre-commit disagreement with trailing-whitespace and prettier

See original GitHub issue

Hi,

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:

image

Immediately re-running pre-commit causes all other notebooks to be updated by jupytext,.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
mwoutscommented, Aug 30, 2020

I would like to code up a simple pre-commit yaml for the repo

Oh, that would be awesome!

1reaction
Skylion007commented, Aug 18, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using as a pre-commit hook - Jupytext documentation
Jupytext works well with the pre-commit framework. You can add the following to your .pre-commit-config.yaml file to sync all staged notebooks:.
Read more >
Jupyter Tutorial - ResearchGate
The `ipython` argument is the currently active `InteractiveShell` ... for example pre-commit run trailing-whitespace.
Read more >
Jupytext pre-commit config when notebooks are ignored in git
I have *.ipynb in my .gitignore file, which means that notebooks are ignored (because of git size issues), but I want pre-commit ......
Read more >
21c49e38985ea9c4.txt
shellFor: add a doBenchmark argument for enabling benchmarks deps ... driver nixos/tests/fctix: remove trailing whitespace nixosTests.ferm: fix network ...
Read more >
Pdf/Acyclic.1.Pdf - DocsLib
Provides argument autocompletion to shell commands. ... docker secret inspect --pretty {{secret_name1 secret_name2 ...}} ... grumphp git:pre-commit.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found