pycln: Incompatibility with click-8.1.0 (typer-0.4.0)
Describe the bug
At https://github.com/wntrblm/nox/pull/590, we tried to adress a Black issue with a breaking Click update. However, we noticed that also pycln was affected.
At least, I can reproduce this with GitHub Actions.
To Reproduce
Steps to reproduce the behavior:
-
Run pycln anywhere, with the latest
clickversion. -
See the error:
pycln....................................................................Failed - hook id: pycln - exit code: 1 Traceback (most recent call last): File "/home/runner/.cache/pre-commit/repo4hw2hs9j/py_env-python3/bin/pycln", line 5, in <module> from pycln.cli import app File "/home/runner/.cache/pre-commit/repo4hw2hs9j/py_env-python3/lib/python3.9/site-packages/pycln/__init__.py", line 7, in <module> import typer File "/home/runner/.cache/pre-commit/repo4hw2hs9j/py_env-python3/lib/python3.9/site-packages/typer/__init__.py", line 12, in <module> from click.termui import get_terminal_size as get_terminal_size ImportError: cannot import name 'get_terminal_size' from 'click.termui' (/home/runner/.cache/pre-commit/repo4hw2hs9j/py_env-python3/lib/python3.9/site-packages/click/termui.py) Traceback (most recent call last): File "/home/runner/.cache/pre-commit/repo4hw2hs9j/py_env-python3/bin/pycln", line 5, in <module> from pycln.cli import app File "/home/runner/.cache/pre-commit/repo4hw2hs9j/py_env-python3/lib/python3.9/site-packages/pycln/__init__.py", line 7, in <module> import typer File "/home/runner/.cache/pre-commit/repo4hw2hs9j/py_env-python3/lib/python3.9/site-packages/typer/__init__.py", line 12, in <module> from click.termui import get_terminal_size as get_terminal_size ImportError: cannot import name 'get_terminal_size' from 'click.termui' (/home/runner/.cache/pre-commit/repo4hw2hs9j/py_env-python3/lib/python3.9/site-packages/click/termui.py)
Expected behavior:
-
Description: I expected
pyclnto finish cleanly. -
Expected output (if present):
-
Expected fixed code (if present):
Environment (please complete the following informations):
- Python Version:
python-version: 3.9 - Pycln Version:
1.2.5(but also checked using1.1.0) - OS Type:
runs-on: ubuntu-20.04
Additional context
I think Click 8.1.0 is the responsible, like the issue with Black (https://github.com/psf/black/issues/2964). However, maybe something else is involved.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 19
Most of my repos use pre-commit.ci, which runs
pre-commit autoupdateonce a week (can be set to monthly) and PRs the result if it changes.This is https://github.com/tiangolo/typer/issues/377 - as long as they don’t bump the version too high when fixing it, it will get fixed here automatically.
This is a great reason to avoid putting upper caps on things - it didn’t protect against this, but it might protect against a fix! This would not have been caught (minor release, rather than major, and in a dependency, not this package), so adding upper caps when you knot know there will be a breakage doesn’t help. See https://iscinumpy.dev/post/bound-version-constraints/.
pre-commit clean?Also,
pre-commit autoupdateis not a setting, it just updates all the repos when you run it.I just released Typer
0.4.1that should handle this. 🚀 🤓This was fixed in typer 0.4.1, so as long as you aren’t getting an old cached version in pre-commit, this should be working again! https://github.com/tiangolo/typer/pull/380
Yep, that’s what I’m doing. I have not updated it in the Developer Guidelines yet (https://scikit-hep.org/developer/style#pycln), but I have updated the matching cookie cutter (https://github.com/scikit-hep/cookie/blob/12c4755988652134eeadf82b0b562d02fdcfd7e8/{{cookiecutter.project_name}}/.pre-commit-config.yaml#L63-L69). I’m assuming it will be fixed quickly, but if not, I’ll update the dev pages too. 😕