From 49408c25affc81c8bbcd1567be1c52f254a6f208 Mon Sep 17 00:00:00 2001 From: Theodore Aptekarev Date: Mon, 19 May 2025 14:42:46 +0300 Subject: [PATCH 1/2] Fix using incorrect hidden property on ProgressBar instance Signed-off-by: Theodore Aptekarev Signed-off-by: Ayan Sinha Mahapatra --- azure-pipelines.yml | 4 ++-- requirements-dev.txt | 6 +++--- requirements.txt | 27 ++++++++++++++------------- setup.cfg | 5 ++--- src/commoncode/cliutils.py | 6 +++--- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a3fc9e8..5d09bda 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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; do - pip install click==$clk_ver; + venv/bin/pip install --force-reinstall click==$clk_ver; venv/bin/pytest -vvs tests/test_cliutils_progressbar.py; done diff --git a/requirements-dev.txt b/requirements-dev.txt index 4645517..c2d9aa0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 @@ -6,10 +6,10 @@ cffi==1.15.1 cryptography==39.0.1 docutils==0.19 et-xmlfile==1.1.0 -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 @@ -27,6 +27,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 @@ -37,7 +38,6 @@ rfc3986==2.0.0 rich==13.3.1 secretstorage==3.3.3 six==1.16.0 -tomli==2.0.1 twine==4.0.2 webencodings==0.5.1 zipp==3.14.0 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 562ae0b..c48b99e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,16 @@ -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 +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 diff --git a/setup.cfg b/setup.cfg index 063b149..c172c36 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,7 +42,7 @@ python_requires = >=3.9 install_requires = attrs >= 18.1, !=20.1.0 Beautifulsoup4[chardet] >= 4.13.0 - click >= 6.7, !=7.0 + click >= 8.2.0 requests[use_chardet_on_py3] >= 2.7.0 saneyaml >= 0.5.2 text_unidecode >= 1.0 @@ -56,7 +56,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 @@ -70,4 +70,3 @@ docs = sphinx-autobuild sphinx-rtd-dark-mode>=1.3.0 sphinx-copybutton - diff --git a/src/commoncode/cliutils.py b/src/commoncode/cliutils.py index 8ec419c..a1d2723 100644 --- a/src/commoncode/cliutils.py +++ b/src/commoncode/cliutils.py @@ -177,7 +177,7 @@ def make_step(self, n_steps): # overriden and copied from Click to work around Click woes for # https://github.com/aboutcode-org/scancode-toolkit/issues/2583 def generator(self): - if self.is_hidden: + if self.hidden: yield from self.iter else: for rv in self.iter: @@ -196,7 +196,7 @@ class EnhancedProgressBar(DebuggedProgressBar): """ def render_progress(self): - if not self.is_hidden: + if not self.hidden: return super(EnhancedProgressBar, self).render_progress() @@ -217,7 +217,7 @@ class ProgressLogger(ProgressBar): def __init__(self, *args, **kwargs): super(ProgressLogger, self).__init__(*args, **kwargs) - self.is_hidden = False + self.hidden = False def render_progress(self): line = self.format_progress_line() From 48001c36ba0161a70efe053bece239e9572c02e5 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 11 Jun 2025 17:25:40 +0530 Subject: [PATCH 2/2] Fix compatibility issues from click >= 8.2.0 Signed-off-by: Ayan Sinha Mahapatra --- azure-pipelines.yml | 6 +++--- requirements-dev.txt | 2 ++ requirements.txt | 4 +++- setup.cfg | 8 +++++--- src/commoncode/cliutils.py | 21 ++++++++++++++++----- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5d09bda..c4743d9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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 @@ -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.2.0 8.2.1; + 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 - venv/bin/pip install --force-reinstall click==$clk_ver; + venv/bin/pip install click==$clk_ver; venv/bin/pytest -vvs tests/test_cliutils_progressbar.py; done diff --git a/requirements-dev.txt b/requirements-dev.txt index c2d9aa0..0dc3378 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,6 +6,7 @@ cffi==1.15.1 cryptography==39.0.1 docutils==0.19 et-xmlfile==1.1.0 +exceptiongroup==1.1.0 execnet==1.9.0 importlib-metadata==6.0.0 iniconfig==2.0.0 @@ -38,6 +39,7 @@ rfc3986==2.0.0 rich==13.3.1 secretstorage==3.3.3 six==1.16.0 +tomli==2.0.1 twine==4.0.2 webencodings==0.5.1 zipp==3.14.0 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index c48b99e..ec24059 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,8 @@ beautifulsoup4==4.13.4 certifi==2025.4.26 chardet==5.2.0 charset-normalizer==3.4.2 -click==8.2.1 +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 @@ -14,3 +15,4 @@ soupsieve==2.7 text-unidecode==1.3 typing_extensions==4.13.2 urllib3==1.26.20 +wheel==0.38.4 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index c172c36..852bf80 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 >= 8.2.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 @@ -56,7 +58,7 @@ where = src testing = pytest >= 6, != 7.0.0 pytest-xdist >= 2 - aboutcode-toolkit >=11.1.1 + aboutcode-toolkit >= 11.1.1 pycodestyle >= 2.8.0 twine black diff --git a/src/commoncode/cliutils.py b/src/commoncode/cliutils.py index a1d2723..026e26b 100644 --- a/src/commoncode/cliutils.py +++ b/src/commoncode/cliutils.py @@ -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 + + @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): @@ -177,7 +188,7 @@ def make_step(self, n_steps): # overriden and copied from Click to work around Click woes for # https://github.com/aboutcode-org/scancode-toolkit/issues/2583 def generator(self): - if self.hidden: + if self.is_hidden: yield from self.iter else: for rv in self.iter: @@ -196,11 +207,11 @@ class EnhancedProgressBar(DebuggedProgressBar): """ def render_progress(self): - if not self.hidden: + if not self.is_hidden: 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. @@ -217,7 +228,7 @@ class ProgressLogger(ProgressBar): def __init__(self, *args, **kwargs): super(ProgressLogger, self).__init__(*args, **kwargs) - self.hidden = False + self.is_hidden = False def render_progress(self): line = self.format_progress_line()