pre-commit-ci / issues

public issues for https://pre-commit.ci
16 stars 3 forks source link

Inconsistency between local run, CI and autofixes #125

Closed fepegar closed 2 years ago

fepegar commented 2 years ago

This is an issue discovered in

  1. I created the branch and ran pre-commit run --all-files (with this config). All hooks passed
  2. I committed the changes and pushed
  3. The CI check failed with flake8 issues that didn't happen locally
  4. The bot autofixed many files that are not mentioned in the CI check, apparently ignoring the flake8 config files specified in the YAML

Do you know what might be going on?

asottile commented 2 years ago

fwiw, when I run it locally I get:

$ pre-commit  run --all-files
check python ast.........................................................Passed
check yaml...............................................................Passed
check for added large files..............................................Passed
check docstring is first.................................................Passed
check for merge conflicts................................................Passed
check vcs permalinks.....................................................Passed
detect private key.......................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
mixed line ending........................................................Passed
check that scripts with shebangs are executable..........................Passed
flake8 ./hi-ml/..........................................................Failed
- hook id: flake8
- exit code: 1

hi-ml/testhiml/testhiml/test_runner.py:282:68: W504 line break after binary operator
hi-ml/other/image_loading/profile_image_loading.py:106:57: W504 line break after binary operator
hi-ml/other/image_loading/profile_image_loading.py:132:57: W504 line break after binary operator
hi-ml/src/health_ml/utils/common_utils.py:25:1: E704 multiple statements on one line (def)
hi-ml/src/health_ml/utils/common_utils.py:29:1: E704 multiple statements on one line (def)
hi-ml/src/health_ml/utils/split_dataset.py:329:9: E704 multiple statements on one line (def)

flake8 ./hi-ml-azure/....................................................Failed
- hook id: flake8
- exit code: 1

hi-ml-azure/run_pytest.py:19:39: W504 line break after binary operator
hi-ml-azure/testazure/testazure/test_azure_util.py:2281:5: E704 multiple statements on one line (def)
hi-ml-azure/testazure/testazure/test_azure_util.py:2344:56: W504 line break after binary operator
hi-ml-azure/src/health_azure/utils.py:242:13: E704 multiple statements on one line (def)
hi-ml-azure/src/health_azure/utils.py:244:13: E704 multiple statements on one line (def)
hi-ml-azure/src/health_azure/utils.py:248:13: E704 multiple statements on one line (def)
hi-ml-azure/src/health_azure/utils.py:251:13: E704 multiple statements on one line (def)
hi-ml-azure/src/health_azure/utils.py:253:13: E704 multiple statements on one line (def)

flake8 ./hi-ml-histopathology/...........................................Failed
- hook id: flake8
- exit code: 1

hi-ml-histopathology/testhisto/testhisto/datamodules/test_slides_datamodule.py:113:35: W504 line break after binary operator
hi-ml-histopathology/src/histopathology/utils/output_utils.py:257:46: W504 line break after binary operator
hi-ml-histopathology/testhisto/testhisto/mocks/base_data_generator.py:123:47: W504 line break after binary operator
hi-ml-histopathology/src/histopathology/preprocessing/create_tiles_dataset.py:202:59: W504 line break after binary operator
hi-ml-histopathology/src/histopathology/utils/analysis_plot_utils.py:181:44: W504 line break after binary operator
hi-ml-histopathology/src/histopathology/utils/analysis_plot_utils.py:292:44: W504 line break after binary operator
hi-ml-histopathology/testhisto/testhisto/utils/test_output_utils.py:171:64: W504 line break after binary operator
hi-ml-histopathology/src/SSL/lightning_modules/byol/byol_moving_average.py:55:62: W504 line break after binary operator
hi-ml-histopathology/testhisto/testhisto/preprocessing/test_tiling.py:51:46: W504 line break after binary operator
hi-ml-histopathology/testhisto/testhisto/preprocessing/test_tiling.py:103:50: W504 line break after binary operator
hi-ml-histopathology/src/SSL/data/cxr_datasets.py:152:37: W504 line break after binary operator
hi-ml-histopathology/src/SSL/data/cxr_datasets.py:189:37: W504 line break after binary operator
hi-ml-histopathology/src/histopathology/preprocessing/create_panda_tiles_dataset.py:170:54: W504 line break after binary operator
hi-ml-histopathology/testhisto/testhisto/datamodules/test_datamodule_caching.py:80:59: W504 line break after binary operator
hi-ml-histopathology/testSSL/testSSL/test_ssl_containers.py:315:29: W504 line break after binary operator
hi-ml-histopathology/testSSL/testSSL/test_ssl_containers.py:318:29: W504 line break after binary operator

autopep8.................................................................Passed

do you perhaps have a flake8 config outside of your repo that's affecting your runs? ../.flake8 / ../../.flake8 / etc.

autopep8 and flake8 are unrelated tools -- autopep8 ran against all files in your repository since that's how it's configured: https://github.com/microsoft/hi-ml/blob/35fa33ed51a1e590f21bc00ac0016e3805b01337/.pre-commit-config.yaml#L43-L46

I'll note that your flake8 configuration is ~not quite correct -- I would recommend extend-ignore instead of ignore (as it is right now you'll enable a bunch of checks which are off by default including some which are conflicting): https://github.com/microsoft/hi-ml/blob/ce984d4cf6c83b5f71988c8f8be68388860a6f94/hi-ml/.flake8#L4

asottile commented 2 years ago

seems like you've figured out how to configure autopep8: https://github.com/microsoft/hi-ml/pull/403/files

fepegar commented 2 years ago

I don't know if "figured out" is true, but your answer did help. I wanted to investigate and try things before coming back to you with more information. I'm still working on it. Anyway, thanks for your help! I'll probably ask more soon.