if I use pre-commit I can see the files that should be modified, but they are not modified.
More exactly:
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
$ pre-commit run --all-files
check for added large files..............................................Passed
check python ast.........................................................Passed
check for case conflicts.................................................Passed
check docstring is first.................................................Passed
check json...........................................(no files to check)Skipped
check for merge conflicts................................................Passed
check toml...............................................................Passed
check xml................................................................Passed
check yaml...............................................................Passed
debug statements (python)................................................Passed
fix end of files.........................................................Passed
fix python encoding pragma...............................................Passed
python tests naming..................................(no files to check)Skipped
trim trailing whitespace.................................................Passed
black....................................................................Failed
- hook id: black
- files were modified by this hook
reformatted python/populse_mia/data_manager/database_mia.py
reformatted python/populse_mia/user_interface/data_browser/modify_table.py
reformatted python/populse_mia/user_interface/data_viewer/anatomist/mia_anatomist.py
reformatted python/populse_mia/data_manager/data_loader.py
reformatted python/populse_mia/user_interface/data_browser/count_table.py
reformatted python/populse_mia/data_manager/data_history_inspect.py
reformatted python/populse_mia/user_interface/data_browser/advanced_search.py
reformatted python/populse_mia/user_interface/data_viewer/anatomist_2/mia_anatomist.py
reformatted python/populse_mia/user_interface/pipeline_manager/iteration_table.py
reformatted python/populse_mia/user_interface/data_browser/mini_viewer.py
reformatted python/populse_mia/software_properties.py
reformatted python/populse_mia/user_interface/pipeline_manager/type_editors.py
reformatted python/populse_mia/main.py
reformatted python/populse_mia/user_interface/pipeline_manager/process_mia.py
reformatted python/populse_mia/data_manager/project.py
reformatted python/populse_mia/utils/utils.py
reformatted python/populse_mia/user_interface/data_viewer/anatomist_2/anasimpleviewer2.py
reformatted python/populse_mia/user_interface/pipeline_manager/node_controller.py
reformatted python/populse_mia/user_interface/main_window.py
reformatted python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py
reformatted python/populse_mia/user_interface/data_browser/data_browser.py
reformatted python/populse_mia/user_interface/pipeline_manager/process_library.py
reformatted python/populse_mia/user_interface/pipeline_manager/pipeline_manager_tab.py
reformatted python/populse_mia/user_interface/pop_ups.py
reformatted python/populse_mia/test.py
All done! ✨ 🍰 ✨
25 files reformatted, 24 files left unchanged.
interrogate..............................................................Passed
isort (python)...........................................................Failed
- hook id: isort
- files were modified by this hook
Fixing /data/Git_Projects/populse_mia/python/populse_mia/data_manager/data_history_inspect.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/software_properties.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/data_browser/mini_viewer.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/pipeline_manager/process_library.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/data_browser/modify_table.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/pipeline_manager/iteration_table.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/data_browser/advanced_search.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/pipeline_manager/type_editors.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/data_manager/data_loader.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/pipeline_manager/process_mia.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/utils/utils.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/data_viewer/anatomist_2/anasimpleviewer2.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/data_manager/project.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/test.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/pop_ups.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/data_viewer/anatomist/mia_anatomist.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/data_manager/database_mia.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/pipeline_manager/pipeline_manager_tab.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/data_browser/data_browser.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/data_browser/count_table.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/main.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/pipeline_manager/node_controller.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/data_viewer/anatomist_2/mia_anatomist.py
Fixing /data/Git_Projects/populse_mia/python/populse_mia/user_interface/main_window.py
flake8 under python3.....................................................Failed
- hook id: flake8
- exit code: 1
python/populse_mia/user_interface/pipeline_manager/iteration_table.py:284:80: E501 line too long (102 > 79 characters)
python/populse_mia/user_interface/pipeline_manager/iteration_table.py:291:80: E501 line too long (106 > 79 characters)
python/populse_mia/user_interface/pipeline_manager/iteration_table.py:300:80: E501 line too long (98 > 79 characters)
python/populse_mia/user_interface/pipeline_manager/iteration_table.py:303:80: E501 line too long (105 > 79 characters)
python/populse_mia/user_interface/pipeline_manager/iteration_table.py:310:80: E501 line too long (105 > 79 characters)
python/populse_mia/user_interface/pipeline_manager/iteration_table.py:361:80: E501 line too long (109 > 79 characters)
python/populse_mia/user_interface/pipeline_manager/process_mia.py:575:80: E501 line too long (80 > 79 characters)
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:26:1: F401 'json' imported but unused
python/populse_mia/#install_mia.py:74:80: E501 line too long (83 > 79 characters)
python/populse_mia/#install_mia.py:75:80: E501 line too long (80 > 79 characters)
python/populse_mia/#install_mia.py:86:80: E501 line too long (92 > 79 characters)
python/populse_mia/#install_mia.py:127:80: E501 line too long (120 > 79 characters)
python/populse_mia/#install_mia.py:133:80: E501 line too long (97 > 79 characters)
python/populse_mia/#install_mia.py:144:80: E501 line too long (86 > 79 characters)
python/populse_mia/#install_mia.py:157:80: E501 line too long (97 > 79 characters)
python/populse_mia/#install_mia.py:169:80: E501 line too long (98 > 79 characters)
python/populse_mia/#install_mia.py:174:80: E501 line too long (98 > 79 characters)
python/populse_mia/data_manager/project.py:22:1: F401 'datetime.timedelta' imported but unused
python/populse_mia/data_manager/project.py:729:9: F841 local variable 'procs' is assigned to but never used
python/populse_mia/data_manager/project.py:813:9: F401 'soma_workflow.client as swclient' imported but unused
python/populse_mia/data_manager/project.py:814:9: F401 'soma_workflow.constants' imported but unused
python/populse_mia/data_manager/project.py:1245:80: E501 line too long (80 > 79 characters)
python/populse_mia/data_manager/project.py:1385:24: E711 comparison to None should be 'if cond is not None:'
python/populse_mia/data_manager/project.py:1569:80: E501 line too long (80 > 79 characters)
python/populse_mia/test.py:24:1: E266 too many leading '#' for block comment
python/populse_mia/test.py:159:1: E266 too many leading '#' for block comment
python/populse_mia/test.py:259:80: E501 line too long (80 > 79 characters)
python/populse_mia/test.py:497:80: E501 line too long (80 > 79 characters)
python/populse_mia/test.py:583:80: E501 line too l python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:28:1: F401 're' imported but unused
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:34:1: F401 'capsul.api.capsul_engine' imported but unused
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:42:1: F401 'PyQt5.QtGui' imported but unused
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:43:1: F401 'PyQt5.QtWidgets.QLineEdit' imported but unused
python/populse_mia/test.py:4510:9: E265 block comment should start with '# '
python/populse_mia/test.py:4511:9: E265 block comment should start with '# '
python/populse_mia/test.py:4511:80: E501 line too long (144 > 79 characters)
python/populse_mia/test.py:4512:9: E265 block comment should start with '# '
python/populse_mia/test.py:4513:9: E265 block comment should start with '# '
python/populse_mia/test.py:4513:80: E501 line too long (113 > 79 characters)
python/populse_mia/test.py:4514:9: E265 block comment should start with '# ' python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:28:1: F401 're' imported but unused
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:34:1: F401 'capsul.api.capsul_engine' imported but unused
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:42:1: F401 'PyQt5.QtGui' imported but unused
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:43:1: F401 'PyQt5.QtWidgets.QLineEdit' imported but unused
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:169:80: E501 line too long (82 > 79 characters)
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:259:33: E713 test for membership should be 'not in'
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:318:80: E501 line too long (85 > 79 characters)
python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py:545:80: E501 line too long (82 > 79 characters)
python/populse_mia/user_interface/data_viewer/anatomist_2/anasimpleviewer2.py:39:1: F401 'optparse.OptionParser' imported but unused
python/populse_mia/user_interface/data_viewer/anatomist_2/anasimpleviewer2.py:50:1: E402 module level import not at top of file
python/populse_mia/user_interface/data_viewer/anatomist_2/__init__.py:3:1: F401 '.mia_anatomist.MiaViewer' imported but unused
python/populse_mia/data_manager/project_properties.py:24:1: F401 'populse_mia.software_properties.verCmp' imported but unused
python/populse_mia/data_manager/project_properties.py:116:9: F841 local variable 'exc' is assigned to but never used
python/populse_mia/#install_mia.py:33:80: E501 line too long (115 > 79 characters)
python/populse_mia/#install_mia.py:44:80: E501 line too long (96 > 79 characters)
python/populse_mia/#install_mia.py:46:80: E501 line too long (82 > 79 characters)
python/populse_mia/#install_mia.py:58:80: E501 line too long (112 > 79 characters)
python/populse_mia/#install_mia.py:59:80: E501 line too long (112 > 79 characters)
python/populse_mia/#install_mia.py:72:80: E501 line too long (81 > 79 characters)
python/populse_mia/test.py:4515:9: E265 block comment should start with '# '
python/populse_mia/test.py:4515:80: E501 line too long (118 > 79 characters)
python/populse_mia/test.py:4516:9: E265 block comment should start with '# '
python/populse_mia/test.py:4517:9: E265 block comment should start with '# '
python/populse_mia/test.py:4517:80: E501 line too long (115 > 79 characters)
python/populse_mia/test.py:4518:9: E265 block comment should start with '# '
python/populse_mia/test.py:4519:9: E265 block comment should start with '# '
python/populse_mia/test.py:4524:80: E501 line too long (92 > 79 characters)
python/populse_mia/test.py:4653:80: E501 line too long (80 > 79 characters)
python/populse_mia/test.py:4658:80: E501 line too long (80 > 79 characters)
python/populse_mia/test.py:4666:80: E501 line too long (92 > 79 characters)
python/populse_mia/test.py:4668:80: E501 line too long (93 > 79 characters)
python/populse_mia/test.py:4669:80: E501 line too long (88 > 79 characters)
python/populse_mia/test.py:4670:80: E501 line too long (93 > 79 characters)
python/populse_mia/test.py:4671:80: E501 line too long (80 > 79 characters)
python/populse_mia/test.py:4673:80: E501 line too long (94 > 79 characters)
python/populse_mia/test.py:4676:80: E501 line too long (80 > 79 characters)
python/populse_mia/test.py:4890:36: E262 inline comment should start with '# '
python/populse_mia/test.py:5218:80: E501 line too long (81 > 79 characters)
python/populse_mia/test.py:5384:80: E501 line too long (82 > 79 characters)
python/populse_mia/test.py:5397:80: E501 line too long (82 > 79 characters)
python/populse_mia/test.py:5422:80: E501 line too long (86 > 79 characters)
python/populse_mia/test.py:5425:80: E501 line too long (83 > 79 characters)
python/populse_mia/test.py:5515:49: E231 missing whitespace after ','
python/populse_mia/test.py:5520:49: E231 missing whitespace after ','
python/populse_mia/test.py:5528:49: E231 missing whitespace after ','
python/populse_mia/test.py:5580:80: E501 line too long (81 > 79 characters)
python/populse_mia/test.py:5649:9: E731 do not assign a lambda expression, use a def
python/populse_mia/test.py:5943:80: E501 line too long (81 > 79 characters)
python/populse_mia/test.py:6017:80: E501 line too long (81 > 79 characters)
python/populse_mia/test.py:6024:80: E501 line too long (83 > 79 characters)
python/populse_mia/test.py:6118:80: E501 line too long (83 > 79 characters)
python/populse_mia/test.py:6140:80: E501 line too long (83 > 79 characters)
python/populse_mia/test.py:6180:9: E266 too many leading '#' for block comment
python/populse_mia/test.py:6217:9: E266 too many leading '#' for block comment
python/populse_mia/test.py:6338:80: E501 line too long (81 > 79 characters)
python/populse_mia/test.py:6674:9: F841 local variable 'index_DOCUMENT_2' is assigned to but never used
python/populse_mia/test.py:6695:80: E501 line too long (80 > 79 characters)
python/populse_mia/test.py:7456:80: E501 line too long (82 > 79 characters)
python/populse_mia/test.py:7519:80: E501 line too long (87 > 79 characters)
python/populse_mia/test.py:7522:80: E501 line too long (83 > 79 characters)
python/populse_mia/test.py:8091:80: E501 line too long (80 > 79 characters)
python/populse_mia/test.py:8098:80: E501 line too long (80 > 79 characters)
python/populse_mia/test.py:8816:80: E501 line too long (102 > 79 characters)
python/populse_mia/user_interface/pop_ups.py:2032:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2049:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2063:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2077:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2091:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2094:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2104:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2115:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2138:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2143:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2153:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2167:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2172:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:2181:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/pop_ups.py:3451:59: E713 test for membership should be 'not in'
python/populse_mia/user_interface/pop_ups.py:3522:80: E501 line too long (80 > 79 characters)
python/populse_mia/user_interface/pop_ups.py:3536:80: E501 line too long (80 > 79 characters)
python/populse_mia/user_interface/pop_ups.py:3575:25: F841 local variable 'e' is assigned to but never used
python/populse_mia/user_interface/pop_ups.py:3676:21: F523 '...'.format(...) has unused arguments at position(s): 0
python/populse_mia/user_interface/pop_ups.py:3961:80: E501 line too long (81 > 79 characters)
python/populse_mia/user_interface/pop_ups.py:3977:80: E501 line too long (80 > 79 characters)
python/populse_mia/user_interface/pop_ups.py:4021:80: E501 line too long (80 > 79 characters)
python/populse_mia/user_interface/pop_ups.py:4158:16: E713 test for membership should be 'not in'
python/populse_mia/user_interface/pop_ups.py:4200:16: E713 test for membership should be 'not in'
python/populse_mia/user_interface/pop_ups.py:4681:9: F841 local variable 'h_box' is assigned to but never used
python/populse_mia/user_interface/pop_ups.py:5333:17: F841 local variable 'e' is assigned to but never used
python/populse_mia/user_interface/pop_ups.py:5348:80: E501 line too long (95 > 79 characters)
python/populse_mia/user_interface/pop_ups.py:5385:21: E722 do not use bare 'except'
python/populse_mia/user_interface/pop_ups.py:5387:80: E501 line too long (95 > 79 characters)
python/populse_mia/user_interface/pop_ups.py:5883:80: E501 line too long (82 > 79 characters)
python/populse_mia/user_interface/data_viewer/anatomist/mia_anatomist.py:4:80: E501 line too long (106 > 79 characters)
python/populse_mia/user_interface/data_viewer/anatomist/mia_anatomist.py:23:80: E501 line too long (92 > 79 characters)
python/populse_mia/user_interface/data_viewer/anatomist/mia_anatomist.py:24:80: E501 line too long (96 > 79 characters)
python/populse_mia/user_interface/data_viewer/anatomist/mia_anatomist.py:38:9: E731 do not assign a lambda expression, use a def
python/populse_mia/user_interface/data_viewer/anatomist/__init__.py:3:1: F401 '.mia_anatomist.MiaViewer' imported but unused
python/populse_mia/data_manager/database_mia.py:22:1: F401
python/populse_mia/user_interface/pipeline_manager/pipeline_manager_tab.py:3311:9: F841 local variable 'timer' is assigned to but never used
python/populse_mia/user_interface/pipeline_manager/pipeline_manager_tab.py:3367:9: F841 local variable 'capsul_config' is assigned to but never used
python/populse_mia/user_interface/pipeline_manager/pipeline_manager_tab.py:3486:13: F401 'soma_workflow.gui.workflowGui.SomaWorkflowWidget' imported but unused
python/populse_mia/user_interface/data_browser/data_browser.py:743:80: E501 line too long (81 > 79 characters)
python/populse_mia/user_interface/data_browser/data_browser.py:756:80: E501 line too long (81 > 79 characters)
python/populse_mia/user_interface/data_browser/data_browser.py:769:80: E501 line too long (81 > 79 characters)
python/populse_mia/user_interface/data_browser/data_browser.py:1047:25: E713 test for membership should be 'not in'
python/populse_mia/user_interface/data_browser/data_browser.py:1755:9: E266 too many leading '#' for block comment
python/populse_mia/user_interface/data_browser/data_browser.py:2633:9: F841 local variable 'collection_init' is assigned to but never used
python/populse_mia/user_interface/data_browser/data_browser.py:2634:9: F841 local variable 'primary_key_init' is assigned to but never used
python/populse_mia/user_interface/data_browser/data_browser.py:2808:16: E713 test for membership should be 'not in'
python/populse_mia/main.py:350:1: E402 module level import not at top of file
python/populse_mia/main.py:352:1: E402 module level import not at top of file
python/populse_mia/main.py:354:1: E402 module level import not at top of file
python/populse_mia/main.py:356:1: E402 module level import not at top of file
python/populse_mia/main.py:357:1: E402 module level import not at top of file
python/populse_mia/user_interface/main_window.py:1436:80: E501 line too long (80 > 79 characters)
python/populse_mia/user_interface/main_window.py:1702:80: E501 line too long (90 > 79 characters)
python/populse_mia/user_interface/main_window.py:1705:80: E501 line too long (94 > 79 characters)
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: properties/config.yml
no changes added to commit (use "git add" and/or "git commit -a")
Maybe I did the configuration wrong?
This is the .pre-commit-config.yaml:
$ more .pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks: # general hooks
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: name-tests-test
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.1.0
hooks: # code formatter
- id: black
language: python
args: ["--line-length=79"]
- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks: # documentation checker
- id: interrogate
args: [--fail-under=80, -vv]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks: # imports sorting
- id: isort
name: isort (python)
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
name: flake8 under python3
language_version: python3
I really don't understand what I did wrong!
What should we do to use pre-commit and have a real modification of the files rather than just an indication of which files should be modified ?
EDIT:
Thanks to Anthony Sottile answer I was able to correct the configuration to avoid conflicts between black and isort. This is the config files that i use now:
$ more .pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks: # general hooks
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: name-tests-test
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.1.0
hooks: # code formatter
- id: black
language: python
args: ["--line-length=79"]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
name: flake8 under python3
language_version: python3
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks: # imports sorting
- id: isort
name: isort (python)
- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks: # documentation checker
- id: interrogate
args: [--fail-under=80, -vv]
$ more pyproject.toml
[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''
#[tool.flake8]
#max-line-length = 79
#exclude = [".git", "__pycache__", "dist"]
#extend-ignore = ["E203", "E266", "E501", "W503", "F403", "F401"]
#max-complexity = 10
[tool.isort]
atomic = true
profile = "black"
line_length = 79
skip_gitignore = true
you have two tools which are conflicting on style -- likely black
wants it one way and isort
wants it another way
you'll need to configure isort
with profile = black
such that they don't conflict