Skip to content

Pre-commit hook fails due to import error #1146

@chadmarchand

Description

@chadmarchand

Description

When following the contribution guidelines, I installed all dependencies and ran the pre-commit hook when working on my PR (#1145). The pre-commit hook failed when committing due to an import error. I manually moved an older version of the click package in order to get the hook to work.

Steps/Code to Reproduce

Follow the contribution guidelines (pip install -e .[test], pre-commit install). Then commit a change.

Expected Results

No import error is thrown when running the pre-commit hook.

Actual Results

An import error is thrown when running the pre-commit hook.

[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/chad/.cache/pre-commit/patch1656209125-53395.
black....................................................................Failed
- hook id: black
- exit code: 1

Traceback (most recent call last):
  File "/home/chad/.cache/pre-commit/repo9hzu_n53/py_env-python3/bin/black", line 8, in <module>
    sys.exit(patched_main())
  File "/home/chad/.cache/pre-commit/repo9hzu_n53/py_env-python3/lib/python3.8/site-packages/black.py", line 4134, in patched_main
    patch_click()
  File "/home/chad/.cache/pre-commit/repo9hzu_n53/py_env-python3/lib/python3.8/site-packages/black.py", line 4123, in patch_click
    from click import _unicodefun  # type: ignore
ImportError: cannot import name '_unicodefun' from 'click' (/home/chad/.cache/pre-commit/repo9hzu_n53/py_env-python3/lib/python3.8/site-packages/click/__init__.py)

mypy openml..............................................................Passed
mypy tests...........................................(no files to check)Skipped
flake8 openml............................................................Passed
flake8 tests.........................................(no files to check)Skipped
[INFO] Restored changes from /home/chad/.cache/pre-commit/patch1656209125-53395.

Versions

Python 3.8.10 (default, Mar 15 2022, 12:22:08)
NumPy 1.20.1
SciPy 1.6.1
Scikit-Learn 1.1.1
OpenML 0.12.2

Comments

This appears to be the issue: https://stackoverflow.com/questions/71673404/importerror-cannot-import-name-unicodefun-from-click So it seems updating black in the pre-commit hook would fix the issue.

Metadata

Metadata

Assignees

Labels

maintenance & CIContinuous integration & package distribution

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions