0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Python pre-commitのblackでcannot import name '_unicodefun' from 'click'

Posted at

はじめに

この記事は2022年3月にまとめていた「細かいつまずいたことをメモしておく(3月編)をそれぞれ投稿した内容になります
解決方法が最新でない可能性もありますのでご了承ください

問題

pre-commitを走らせたところblackで以下のエラーが発生した

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

解決方法

これは.pre-commit-config.yamlblackのバージョンが古いことから起きていた

.pre-commit-config.yaml
- repo: https://github.com/psf/black
  rev: 22.3.0
  hooks:
    - id: black
      language_version: python3

バージョンを22.3.0に固定したら動くようになった

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?