Skip to content

Fix click compatibility issues #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
parameters:
job_name: macos14_cpython
image_name: macOS-14
python_versions: ['3.9', '3.10', '3.11', '3.12']
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
test_suites:
all: venv/bin/pytest -n 2 -vvs

Expand Down Expand Up @@ -68,9 +68,9 @@ jobs:
python_versions: ["3.9", "3.10", "3.11", "3.12", "3.13"]
test_suites:
click_versions: |
for clk_ver in 8.1.7 8.1.6 8.1.5 8.1.4 8.1.3 8.1.2 8.1.1 8.1.0 8.0.4 8.0.2 8.0.3 8.0.1 7.1.2 7.1.1 7.1 6.7;
for clk_ver in 8.2.0 8.2.1 8.1.8 8.1.7 8.1.6 8.1.5 8.1.4 8.1.3 8.1.2 8.1.1 8.1.0 8.0.4 8.0.2 8.0.3 8.0.1 7.1.2 7.1.1 7.1 6.7;
do
pip install click==$clk_ver;
venv/bin/pip install click==$clk_ver;
venv/bin/pytest -vvs tests/test_cliutils_progressbar.py;
done

Expand Down
4 changes: 3 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aboutcode-toolkit==7.2.0
aboutcode-toolkit==11.1.1
black==23.1.0
bleach==6.0.0
boolean.py==4.0
Expand All @@ -10,6 +10,7 @@ exceptiongroup==1.1.0
execnet==1.9.0
importlib-metadata==6.0.0
iniconfig==2.0.0
isort==6.0.1
jaraco.classes==3.2.3
jeepney==0.8.0
jinja2==3.1.2
Expand All @@ -27,6 +28,7 @@ pathspec==0.11.0
pkginfo==1.9.6
platformdirs==3.0.0
pluggy==1.0.0
pycodestyle==2.13.0
pycparser==2.21
pygments==2.14.0
pytest==7.2.1
Expand Down
29 changes: 16 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
attrs==22.2.0
beautifulsoup4==4.13.3
certifi==2022.12.7
attrs==25.3.0
beautifulsoup4==4.13.4
certifi==2025.4.26
chardet==5.2.0
click==8.1.3
idna==3.4
pip==23.0
PyYAML==6.0
requests==2.28.2
saneyaml==0.6.0
setuptools==67.1.0
soupsieve==2.4
charset-normalizer==3.4.2
click==8.2.1;python_version>='3.10'
click==8.1.8;python_version<'3.10'
idna==3.10
pip==25.1.1
PyYAML==6.0.2
requests==2.32.2
saneyaml==0.6.1
setuptools==80.3.1
soupsieve==2.7
text-unidecode==1.3
urllib3==1.26.14
wheel==0.38.4
typing_extensions==4.13.2
urllib3==1.26.20
wheel==0.38.4
9 changes: 5 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ setup_requires = setuptools_scm[toml] >= 4
python_requires = >=3.9

install_requires =
attrs >= 18.1, !=20.1.0
attrs >= 18.1,!=20.1.0;python_version<'3.11'
attrs >= 22.1.0;python_version>='3.11'
Beautifulsoup4[chardet] >= 4.13.0
click >= 6.7, !=7.0
click >= 6.7, !=7.0;python_version<'3.10'
click >= 8.2.0;python_version>='3.10'
requests[use_chardet_on_py3] >= 2.7.0
saneyaml >= 0.5.2
text_unidecode >= 1.0
Expand All @@ -56,7 +58,7 @@ where = src
testing =
pytest >= 6, != 7.0.0
pytest-xdist >= 2
aboutcode-toolkit >= 7.0.2
aboutcode-toolkit >= 11.1.1
pycodestyle >= 2.8.0
twine
black
Expand All @@ -70,4 +72,3 @@ docs =
sphinx-autobuild
sphinx-rtd-dark-mode>=1.3.0
sphinx-copybutton

15 changes: 13 additions & 2 deletions src/commoncode/cliutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,20 @@ def format_options(self, ctx, formatter):
formatter.write_dl(sorted_records)


class CompatProgressBar(ProgressBar):
# TODO Remove when dropping support for Python 3.9 or Click 8.1.
@property
def is_hidden(self) -> bool:
return self.hidden
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this be failing on click <8.2 because self.hidden does not exist?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see now that you've implemented a version cap for python 3.9


@is_hidden.setter
def is_hidden(self, value: bool) -> None:
self.hidden = value


# overriden and copied from Click to work around Click woes for
# https://github.com/aboutcode-org/scancode-toolkit/issues/2583
class DebuggedProgressBar(ProgressBar):
class DebuggedProgressBar(CompatProgressBar):
# overriden and copied from Click to work around Click woes for
# https://github.com/aboutcode-org/scancode-toolkit/issues/2583
def make_step(self, n_steps):
Expand Down Expand Up @@ -200,7 +211,7 @@ def render_progress(self):
return super(EnhancedProgressBar, self).render_progress()


class ProgressLogger(ProgressBar):
class ProgressLogger(CompatProgressBar):
"""
A subclass of Click ProgressBar providing a verbose line-by-line progress
reporting.
Expand Down