0

I don't see the same results between running pre-commit locally and pre-commit.ci in github.

However, if I read the documentation of pre-commit.ci correctly, the configuration files used are the same.

Locally:

% git commit -m "pre-commit run --all-files"
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/econdami/.cache/pre-commit/patch1678211848-117234.
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...........................................(no files to check)Skipped
check xml............................................(no files to check)Skipped
check yaml...........................................(no files to check)Skipped
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....................................................................Passed
isort (python)...........................................................Passed
interrogate..............................................................Passed
flake8 under python3.....................................................Passed
[INFO] Restored changes from /home/econdami/.cache/pre-commit/patch1678211848-117234.
[master ec627fd2] pre-commit run --all-files
 1 file changed, 1 insertion(+), 2 deletions(-)

After a git push, I observe this result for pre-commit.ci. Locally we do not observe any issue with isort ... I suspect a configuration issue and I have read the documentation but I can't find what is wrong!

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
servoz
  • 606
  • 9
  • 22

1 Answers1

1

for what it's worth, I get what pre-commit.ci gets locally

isort seems to sort your repository differently based on what you check out the repo as -- probably a quirk / bug in isort -- if I clone your repo as populse_mia instead of src or code then it sorts differently

you can also reproduce this using the pre-commit.ci docker image

-- for example:

$ docker run -v $PWD:/src:rw --workdir /src --rm -ti ghcr.io/pre-commit-ci/runner-image pre-commit run isort --all-files
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/pycqa/isort.
[INFO] Initializing environment for https://github.com/econchick/interrogate.
[INFO] Initializing environment for https://github.com/PyCQA/flake8.
[INFO] Installing environment for https://github.com/pycqa/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
isort (python)...........................................................Failed
- hook id: isort
- files were modified by this hook

Fixing /src/python/populse_mia/data_manager/data_history_inspect.py
Fixing /src/python/populse_mia/data_manager/data_loader.py
Fixing /src/python/populse_mia/data_manager/project.py
Fixing /src/python/populse_mia/main.py
Fixing /src/python/populse_mia/test.py
Fixing /src/python/populse_mia/user_interface/data_browser/advanced_search.py
Fixing /src/python/populse_mia/user_interface/data_browser/count_table.py
Fixing /src/python/populse_mia/user_interface/data_browser/data_browser.py
Fixing /src/python/populse_mia/user_interface/data_browser/mini_viewer.py
Fixing /src/python/populse_mia/user_interface/data_browser/modify_table.py
Fixing /src/python/populse_mia/user_interface/data_browser/rapid_search.py
Fixing /src/python/populse_mia/user_interface/data_viewer/anatomist/mia_anatomist.py
Fixing /src/python/populse_mia/user_interface/data_viewer/anatomist_2/anasimpleviewer2.py
Fixing /src/python/populse_mia/user_interface/data_viewer/anatomist_2/mia_anatomist.py
Fixing /src/python/populse_mia/user_interface/main_window.py
Fixing /src/python/populse_mia/user_interface/pipeline_manager/iteration_table.py
Fixing /src/python/populse_mia/user_interface/pipeline_manager/node_controller.py
Fixing /src/python/populse_mia/user_interface/pipeline_manager/pipeline_editor.py
Fixing /src/python/populse_mia/user_interface/pipeline_manager/pipeline_manager_tab.py
Fixing /src/python/populse_mia/user_interface/pipeline_manager/process_library.py
Fixing /src/python/populse_mia/user_interface/pipeline_manager/process_mia.py
Fixing /src/python/populse_mia/user_interface/pop_ups.py
Fixing /src/python/populse_mia/utils/utils.py

note that the diffs seem to move the PyQT imports down:

$ git diff -- python/populse_mia/main.py
diff --git a/python/populse_mia/main.py b/python/populse_mia/main.py
index c9c2357..21f8ceb 100644
--- a/python/populse_mia/main.py
+++ b/python/populse_mia/main.py
@@ -367,10 +367,6 @@ import capsul.api as capsul_api
 
 # capsul imports
 from capsul.api import get_process_instance
-
-# soma-base imports
-from soma.qt_gui.qtThread import QtThreadCall
-
 from populse_mia.data_manager.project import Project
 from populse_mia.data_manager.project_properties import SavedProjects
 from populse_mia.software_properties import Config
@@ -379,6 +375,9 @@ from populse_mia.software_properties import Config
 from populse_mia.user_interface.main_window import MainWindow
 from populse_mia.utils.utils import check_python_version
 
+# soma-base imports
+from soma.qt_gui.qtThread import QtThreadCall
+
 main_window = None
 
 

disclaimer: I created pre-commit and pre-commit.ci

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
  • Thank you very much @anthony-sottile for your help and the information you give me. The good news is that the issue is not due to an error on my part. The bad news is that fixing the problem is not really up to me. Maybe I will open a ticket in the isort project. In the meantime, I'm thinking of running isort locally and commenting on github. – servoz Mar 08 '23 at 12:26
  • you can probably use `known_first_party` to hack around it -- or use a more standard repository layout rather than a `python` subdir – anthony sottile Mar 08 '23 at 14:09