I have a Python
project that when I try to commit (through miniconda) with:
$ git add -A && git commit -m `test`
I get the following failure:
(base) D:\machinelearning.com-python>git commit -m 'test'
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to C:\Users\anon/.cache\pre-commit\patch1570560215.
Trim Trailing Whitespace.................................................Passed
Check for added large files..............................................Passed
Check python ast.........................................................Passed
Check JSON...........................................(no files to check)Skipped
Check for merge conflicts................................................Passed
Check Xml............................................(no files to check)Skipped
Check Yaml...........................................(no files to check)Skipped
Debug Statements (Python)................................................Passed
Fix End of Files.........................................................Passed
Fix requirements.txt.................................(no files to check)Skipped
Mixed line ending........................................................Passed
Flake8...................................................................Passed
isort....................................................................Failed
hookid: isort
Files were modified by this hook. Additional output:
Fixing D:\machinelearning.com-python\scripts\train_model.py
[INFO] Restored changes from C:\Users\anon/.cache\pre-commit\patch1570560215.
The last line failed.
Any idea on how to solve this issue?
Thanks!
Given the output, it looks like the imports in that file aren't sorted properly -- it should have fixed them automatically for you. If you run git status
and/or git diff
it'll show what is not staged and what changed
You'll then git add
those changes and then commit again
Note that generally when working with isort
via pre-commit
you'll also want to include seed-isort-config
such that third party imports are detected properly
disclosure: I am the author of pre-commit
and seed-isort-config
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With