Python Black hooks (language: system)

1.2k views Asked by At

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?
1

There are 1 answers

3
ignoring_gravity On BEST ANSWER

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?