-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable integration with pre-commit (#698)
* Add .pre-commit-hooks.yaml * Use files instead of types * Rename main hook to jupytext * Remove extra hooks * Add default --from * Update docs * Add --add-untracked for pre-commit compatibility * Flip boolean * Update docs * Exit nonzero if a new file is added to the index with --add-untracked A pre-commit hook should fail if anything in the index is modified. By adding the new untracked file ourselves, we circumvent pre-commit, which means it won't have the chance to run other configured hooks against the new file. Exiting non-zero in this case ensures that the commit will fail, forcing the user to commit again. This time, the new file will be in the index from the start, so other hooks will run against it. * Remove accidental changes * Remove accidental changes * Clarify help * Strip for safety * Add tests for --add-untracked * Fix pre-commit hooks * Fix tests for windows * Add tests for pre-commit integration * Run pre-commit tests in ci * Retry running pre-commit tests in ci * Refactor to better align with pre-commit * Update tests for precommit * Update hook description Co-authored-by: Aaron Gokaslan <[email protected]> * Log output files that are untracked * Update examples * Fixed examples pre-commit documentation * Fix trailing whitespace * Ensure hooks runs in serial Prevents race condition during sync * Fix typo * Clarify log message * Convert test to --sync * args should be array * Ignore unmatched inputs also when using --sync * add notebook types following https://github.com/pre-commit/identify/blob/master/identify/extensions.py * Test & fix 'alert_untracked' in the --sync mode * Add .pre-commit-hooks.yaml * Use files instead of types * Rename main hook to jupytext * Remove extra hooks * Add default --from * Update docs * Add --add-untracked for pre-commit compatibility * Flip boolean * Update docs * Exit nonzero if a new file is added to the index with --add-untracked A pre-commit hook should fail if anything in the index is modified. By adding the new untracked file ourselves, we circumvent pre-commit, which means it won't have the chance to run other configured hooks against the new file. Exiting non-zero in this case ensures that the commit will fail, forcing the user to commit again. This time, the new file will be in the index from the start, so other hooks will run against it. * Remove accidental changes * Remove accidental changes * Clarify help * Strip for safety * Add tests for --add-untracked * Fix pre-commit hooks * Fix tests for windows * Add tests for pre-commit integration * Run pre-commit tests in ci * Retry running pre-commit tests in ci * Refactor to better align with pre-commit * Update tests for precommit * Update hook description Co-authored-by: Aaron Gokaslan <[email protected]> * Log output files that are untracked * Update examples * Fixed examples pre-commit documentation * Fix trailing whitespace * Ensure hooks runs in serial Prevents race condition during sync * Fix typo * Clarify log message * Convert test to --sync * args should be array * Remove types * Try calling pre_comit directly * When in doubt, return False * Fix exisiting file test * Only update the timestamp (not the content) of the text input file * Only run on notebooks * use arrays * Only run on notebooks * Handle pre-commit not being installed Relevant tests will be skipped in that case * Handle right exception Co-authored-by: Aaron Gokaslan <[email protected]> Co-authored-by: Aaron Gokaslan <[email protected]> Co-authored-by: Marc Wouts <[email protected]>
- Loading branch information
1 parent
d2898da
commit 41b7e9c
Showing
8 changed files
with
334 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- id: jupytext | ||
name: jupytext | ||
description: Runs jupytext on all notebooks and paired files. | ||
language: python | ||
entry: jupytext --ignore-unmatched --alert-untracked | ||
pass_filenames: true | ||
require_serial: true | ||
types: [jupyter] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ setuptools | |
toml | ||
jupyterlab==3.0.0 | ||
jupyter-packaging | ||
pre-commit | ||
|
||
# Python 2 | ||
pathlib | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.