1

I am using black on pre-commit and this is the hook

- repo: https://github.com/psf/black
    rev: 19.10b0
    hooks:
      - id: black

this is the CI config I am using for black

 black --check .

and it will reformat some files in the pre-commit and make it fails when build the project on CI

reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/migrations/0007_auto_20190616_0310.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/migrations/0011_auto_20190620_0517.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/migrations/0020_auto_20191030_0712.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/migrations/0021_auto_20191106_0013.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/migrations/0026_delete_comparison.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/migrations/0004_auto_20190613_1032.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/migrations/0005_auto_20190614_0405.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/views/session.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore_api_server/logger.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore_api_server/settings/base.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore_api_server/settings/local.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/models.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore_api_server/settings/production.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore_api_server/settings/test.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/migrations/0001_initial.py
reformatted /Users/rzuhairi/Documents/Anymotion/encore-api-server/encore/tests/serializers/test_drawing.py
All done! ✨  ✨
16 files reformatted, 119 files left unchanged.

and then when I change the hooks into this

- repo: https://github.com/psf/black
    rev: 19.10b0
    hooks:
      - id: black
        language: system
        language_version: python3

it will not reformat the files

I have 2 questions about this:

  1. what is this hooks means: 'language: system' because when I read the documentation it should be language: python?
  2. is anyone know why my first hook didn't work, and black in my pre-commit keep auto-updating my files?
anthony sottile
  • 61,815
  • 15
  • 148
  • 207
Zuhairi
  • 165
  • 2
  • 3
  • 14

1 Answers1

3

what is this hooks means: 'language: system' because when I read the documentation it should be language: python?

This means it'll just use whatever black points to on your system, instead of creating a new virtualenv.

is anyone know why my first hook didn't work, and black in my pre-commit keep auto-updating my files?

No, but my best guess is you're using a different version of black. What's the output of black --version?

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
ignoring_gravity
  • 6,677
  • 4
  • 32
  • 65
  • specifically it means whatever version of `black` you have on your `system` is not the same as the configured version (19.10b0) – anthony sottile Oct 14 '20 at 15:55
  • @AnthonySottile thank you very much for the answer thank you very much for the explanation black --version output is `black, version 20.8b1` it is not the same with the hook – Zuhairi Oct 15 '20 at 00:19
  • @ignoring_black even tho I installed the same version and change the hooks, it keeps modifying my files – Zuhairi Oct 15 '20 at 01:02