Closed pombredanne closed 3 years ago
from https://github.com/nexB/commoncode/pull/30#issuecomment-910172231
The pull request #27 adds
update_min_steps
option usage ofclick._termui_impl.ProgressBar
that is available from click 8.0. But existedsetup.cfg
contains the following restriction:click >= 6.7, !=7.0
. It breaksscancode
withclick
<8 version installation. For example: https://github.com/ARMmbed/mbed-os/pull/14981/checks?check_run_id=3470879205This pull request updates minimal
click
version in thesetup.cfg
according changes in the pull request #27.I ran these tests:
/scancode-toolkit$ for clk_ver in 8.0.1 7.1.2 7.1.1 7.1 6.7; do pip uninstall -y click; pip install click==$clk_ver; scancode -i samples/ -n3 --json-pp - ; done
andcommoncode$ for clk_ver in 8.0.1 7.1.2 7.1.1 7.1 6.7; do pip uninstall -y click; pip install click==$clk_ver; pytest -vvs -n3; done
and all pass with this patch:
diff --git a/src/commoncode/cliutils.py b/src/commoncode/cliutils.py index 4ff8c8e..5a2a3b6 100644 --- a/src/commoncode/cliutils.py +++ b/src/commoncode/cliutils.py @@ -267,7 +267,8 @@ '[%(bar)s]' + ' ' + '%(info)s' if bar_template is None else bar_template ) - return progress_class( + + kwargs = dict( iterable=iterable, length=length, fill_char=fill_char, @@ -281,10 +282,15 @@ label=label, file=file, color=color, - update_min_steps=update_min_steps, width=width, ) + pb = progress_class([]) + if hasattr(pb, 'update_min_steps'): + kwargs['update_min_steps'] = update_min_steps + + return progress_class(**kwargs) + def fixed_width_file_name(path, max_length=25): """
The lines
+ pb = progress_class([]) + if hasattr(pb, 'update_min_steps'):
... are duck typing at its best... Not super elegant but effective nonetheless!
So with this patch we can accept all currently supported Click versions and not only > 8
Fixed and released in 30.0.0
See in #30 by @vznncv: