1

Here is my pre-commit config file:

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.3.0
    hooks:
    -   id: check-yaml
    -   id: end-of-file-fixer
    -   id: trailing-whitespace
-   repo: https://github.com/psf/black
    rev: 21.12b0
    hooks:
    - id: black
    #   name: black
    #   entry: black
    #   language: system
    #   require_serial: true
    #   types: [python]
    #   always_run: true
-   repo: local
    hooks:
    - id: pytest-check
      name: pytest-check
      stages: [commit]
      types: [python]
      entry: pytest
      language: system
      pass_filenames: false
      always_run: true

Where I hashed out was necessary to make the pre-commit work. Having said that I have ran into an error all of a sudden when committing:

 git add . && git commit -m "checking pre-commit"
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/psf/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Check Yaml...........................................(no files to check)Skipped
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
black....................................................................Failed
- hook id: black
- exit code: 1

Traceback (most recent call last):
  File "C:\users\XYZ\.pyenv\pyenv-win\versions\3.9.6\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\users\XYZ\.pyenv\pyenv-win\versions\3.9.6\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\XYZ\.cache\pre-commit\repo7o_agfhv\py_env-python3.9\Scripts\black.EXE\__main__.py", line 7, in <module>
  File "C:\Users\XYZ\.cache\pre-commit\repo7o_agfhv\py_env-python3.9\lib\site-packages\black\__init__.py", line 1372, in patched_main
    patch_click()
  File "C:\Users\XYZ\.cache\pre-commit\repo7o_agfhv\py_env-python3.9\lib\site-packages\black\__init__.py", line 1358, in patch_click
    from click import _unicodefun
ImportError: cannot import name '_unicodefun' from 'click' (C:\Users\XYZ\.cache\pre-commit\repo7o_agfhv\py_env-python3.9\lib\site-packages\click\__init__.py)

pytest-check.............................................................Failed
- hook id: pytest-check
- files were modified by this hook

============================= test session starts =============================
platform win32 -- Python 3.9.6, pytest-7.1.2, pluggy-1.0.0
rootdir: C:\Users\XYZ\dev\repos\fibfind
plugins: codecov-0.5.0, cov-3.0.0
collected 2 items

test_fibFind.py ..                                                       [100%]

============================== 2 passed in 0.03s ==============================

I have seen some related articles on stack overflow but did not find the sufficient to understand and resolve the problem.

Cheers in advance

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
JnooriRS
  • 103
  • 11

0 Answers0