Skip to content

Commit 48001c3

Browse files
Fix compatibility issues from click >= 8.2.0
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent 49408c2 commit 48001c3

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
parameters:
3838
job_name: macos14_cpython
3939
image_name: macOS-14
40-
python_versions: ['3.9', '3.10', '3.11', '3.12']
40+
python_versions: ['3.9', '3.10', '3.11', '3.12', '3.13']
4141
test_suites:
4242
all: venv/bin/pytest -n 2 -vvs
4343

@@ -68,9 +68,9 @@ jobs:
6868
python_versions: ["3.9", "3.10", "3.11", "3.12", "3.13"]
6969
test_suites:
7070
click_versions: |
71-
for clk_ver in 8.2.0 8.2.1;
71+
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;
7272
do
73-
venv/bin/pip install --force-reinstall click==$clk_ver;
73+
venv/bin/pip install click==$clk_ver;
7474
venv/bin/pytest -vvs tests/test_cliutils_progressbar.py;
7575
done
7676

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cffi==1.15.1
66
cryptography==39.0.1
77
docutils==0.19
88
et-xmlfile==1.1.0
9+
exceptiongroup==1.1.0
910
execnet==1.9.0
1011
importlib-metadata==6.0.0
1112
iniconfig==2.0.0
@@ -38,6 +39,7 @@ rfc3986==2.0.0
3839
rich==13.3.1
3940
secretstorage==3.3.3
4041
six==1.16.0
42+
tomli==2.0.1
4143
twine==4.0.2
4244
webencodings==0.5.1
4345
zipp==3.14.0

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ beautifulsoup4==4.13.4
33
certifi==2025.4.26
44
chardet==5.2.0
55
charset-normalizer==3.4.2
6-
click==8.2.1
6+
click==8.2.1;python_version>='3.10'
7+
click==8.1.8;python_version<'3.10'
78
idna==3.10
89
pip==25.1.1
910
PyYAML==6.0.2
@@ -14,3 +15,4 @@ soupsieve==2.7
1415
text-unidecode==1.3
1516
typing_extensions==4.13.2
1617
urllib3==1.26.20
18+
wheel==0.38.4

setup.cfg

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ setup_requires = setuptools_scm[toml] >= 4
4040
python_requires = >=3.9
4141

4242
install_requires =
43-
attrs >= 18.1, !=20.1.0
43+
attrs >= 18.1,!=20.1.0;python_version<'3.11'
44+
attrs >= 22.1.0;python_version>='3.11'
4445
Beautifulsoup4[chardet] >= 4.13.0
45-
click >= 8.2.0
46+
click >= 6.7, !=7.0;python_version<'3.10'
47+
click >= 8.2.0;python_version>='3.10'
4648
requests[use_chardet_on_py3] >= 2.7.0
4749
saneyaml >= 0.5.2
4850
text_unidecode >= 1.0
@@ -56,7 +58,7 @@ where = src
5658
testing =
5759
pytest >= 6, != 7.0.0
5860
pytest-xdist >= 2
59-
aboutcode-toolkit >=11.1.1
61+
aboutcode-toolkit >= 11.1.1
6062
pycodestyle >= 2.8.0
6163
twine
6264
black

src/commoncode/cliutils.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,20 @@ def format_options(self, ctx, formatter):
164164
formatter.write_dl(sorted_records)
165165

166166

167+
class CompatProgressBar(ProgressBar):
168+
# TODO Remove when dropping support for Python 3.9 or Click 8.1.
169+
@property
170+
def is_hidden(self) -> bool:
171+
return self.hidden
172+
173+
@is_hidden.setter
174+
def is_hidden(self, value: bool) -> None:
175+
self.hidden = value
176+
177+
167178
# overriden and copied from Click to work around Click woes for
168179
# https://github.com/aboutcode-org/scancode-toolkit/issues/2583
169-
class DebuggedProgressBar(ProgressBar):
180+
class DebuggedProgressBar(CompatProgressBar):
170181
# overriden and copied from Click to work around Click woes for
171182
# https://github.com/aboutcode-org/scancode-toolkit/issues/2583
172183
def make_step(self, n_steps):
@@ -177,7 +188,7 @@ def make_step(self, n_steps):
177188
# overriden and copied from Click to work around Click woes for
178189
# https://github.com/aboutcode-org/scancode-toolkit/issues/2583
179190
def generator(self):
180-
if self.hidden:
191+
if self.is_hidden:
181192
yield from self.iter
182193
else:
183194
for rv in self.iter:
@@ -196,11 +207,11 @@ class EnhancedProgressBar(DebuggedProgressBar):
196207
"""
197208

198209
def render_progress(self):
199-
if not self.hidden:
210+
if not self.is_hidden:
200211
return super(EnhancedProgressBar, self).render_progress()
201212

202213

203-
class ProgressLogger(ProgressBar):
214+
class ProgressLogger(CompatProgressBar):
204215
"""
205216
A subclass of Click ProgressBar providing a verbose line-by-line progress
206217
reporting.
@@ -217,7 +228,7 @@ class ProgressLogger(ProgressBar):
217228

218229
def __init__(self, *args, **kwargs):
219230
super(ProgressLogger, self).__init__(*args, **kwargs)
220-
self.hidden = False
231+
self.is_hidden = False
221232

222233
def render_progress(self):
223234
line = self.format_progress_line()

0 commit comments

Comments
 (0)