From 115100267ea20349d19ac8e0315bf8d7215e684c Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 14 May 2021 18:54:34 +0200 Subject: [PATCH 1/6] build(ci/tox): add click7 factor, given click 8 is the default now --- .circleci/config.yml | 7 +++++++ tox.ini | 1 + 2 files changed, 8 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2b6593f..839c231 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -88,6 +88,12 @@ jobs: - image: circleci/python:3.7 environment: - TOXENV=py37-click6-coverage + py38-click7: + <<: *common + docker: + - image: circleci/python:3.8 + environment: + - TOXENV=py38-click7-coverage checkqa: <<: *common docker: @@ -99,6 +105,7 @@ workflows: test: jobs: - py38 + - py38-click7 - py37-coveragepy5 - py37 - py37-click6 diff --git a/tox.ini b/tox.ini index ab0f579..af9d24e 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,7 @@ changedir = integration: {envtmpdir} deps = click6: click<7 + click7: click<8 coverage: pytest-cov coveragepy4: coverage<5 coveragepy5: coverage==5.0a5 From a44e348ca832eb04d19a9a9eca17fc411e312cfb Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 15 May 2021 23:10:29 +0200 Subject: [PATCH 2/6] Move string_types to covimerage._compat --- covimerage/__init__.py | 2 +- covimerage/_compat.py | 7 +++++++ covimerage/utils.py | 4 +--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/covimerage/__init__.py b/covimerage/__init__.py index d0ee675..bf61d9c 100755 --- a/covimerage/__init__.py +++ b/covimerage/__init__.py @@ -5,8 +5,8 @@ import re import attr -from click.utils import string_types +from ._compat import string_types from .coveragepy import CoverageData from .logger import logger from .utils import ( diff --git a/covimerage/_compat.py b/covimerage/_compat.py index e47110d..cbb746b 100644 --- a/covimerage/_compat.py +++ b/covimerage/_compat.py @@ -1,3 +1,5 @@ +import sys + try: FileNotFoundError = FileNotFoundError except NameError: @@ -12,3 +14,8 @@ from shlex import quote as shell_quote except ImportError: from pipes import quote as shell_quote # noqa: F401 + +if sys.version_info < (3,): + string_types = (str, unicode) # noqa: F821 +else: + string_types = str diff --git a/covimerage/utils.py b/covimerage/utils.py index 663eabe..12bed0d 100644 --- a/covimerage/utils.py +++ b/covimerage/utils.py @@ -1,9 +1,7 @@ import os import re -from click.utils import string_types - -from ._compat import shell_quote +from ._compat import shell_quote, string_types # Empty (whitespace only), comments, continued, or `end` statements. RE_NON_EXECED = re.compile(r'^\s*("|end|$)') From 355425490166fc24b31b3e4f7d0702b9c7437f95 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 16 May 2021 14:08:16 +0200 Subject: [PATCH 3/6] tox/ci: add py38-click70 --- .circleci/config.yml | 7 +++++++ tox.ini | 1 + 2 files changed, 8 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 839c231..c394bb6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -94,6 +94,12 @@ jobs: - image: circleci/python:3.8 environment: - TOXENV=py38-click7-coverage + py38-click70: + <<: *common + docker: + - image: circleci/python:3.8 + environment: + - TOXENV=py38-click70-coverage checkqa: <<: *common docker: @@ -106,6 +112,7 @@ workflows: jobs: - py38 - py38-click7 + - py38-click70 - py37-coveragepy5 - py37 - py37-click6 diff --git a/tox.ini b/tox.ini index af9d24e..dbd07d0 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ changedir = deps = click6: click<7 click7: click<8 + click70: click<7.1 coverage: pytest-cov coveragepy4: coverage<5 coveragepy5: coverage==5.0a5 From 1725ac6dede5f2a5c1f8f326fc7b0b0222125023 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 16 May 2021 14:59:04 +0200 Subject: [PATCH 4/6] Fix tests/test_logging.py::test_loglevel for click 8 --- tests/test_logging.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_logging.py b/tests/test_logging.py index 877d3ac..71cc981 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -37,12 +37,13 @@ def assert_output(result): if click.__version__ < '7.0': assert result.output.splitlines() == [ 'Error: no such option: --nonexistingoption'] + return + lines = result.output.splitlines() + assert lines[0] == 'Usage: main report [OPTIONS] [PROFILE_FILE]...' + if click.__version__ < '8.0': + assert lines[-1] == 'Error: no such option: --nonexistingoption' else: - assert result.output.splitlines() == [ - 'Usage: main report [OPTIONS] [PROFILE_FILE]...', - 'Try "main report -h" for help.', - '', - 'Error: no such option: --nonexistingoption'] + assert lines[-1] == 'Error: No such option: --nonexistingoption' for level in ['error', 'warning', 'info', 'debug']: result = runner.invoke(cli.main, [ From 2716796331f9519be7cfca0ffd9d82919c476cd9 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 16 May 2021 15:00:47 +0200 Subject: [PATCH 5/6] Fix test_run_cmd_requires_args --- tests/test_cli.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index e613ab0..979957e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -13,6 +13,15 @@ from covimerage.cli import get_version_message +def format_click_arg(name): + if click.__version__ < '7.0': + return '"{}"'.format(name) + elif click.__version__ < '7.1': + return '"{}..."'.format(name.upper()) + else: + return "'{}...'".format(name.upper()) + + def test_dunder_main_run(capfd): assert call([sys.executable, '-m', 'covimerage']) == 0 out, err = capfd.readouterr() @@ -795,9 +804,10 @@ def test_run_forwards_sighup(devnull): def test_run_cmd_requires_args(runner): result = runner.invoke(cli.run, []) - assert 'Error: Missing argument "%s".' % ( - 'args' if click.__version__ < '7.0' else 'ARGS...', - ) in result.output.splitlines() + assert ( + 'Error: Missing argument {}.'.format(format_click_arg('args')) + in result.output.splitlines() + ) assert result.exit_code == 2 From 14e827059c22b684bd1fb1d159ede942847457fe Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 12 Sep 2021 22:42:24 +0200 Subject: [PATCH 6/6] unpin click --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a906601..4a71a44 100755 --- a/setup.py +++ b/setup.py @@ -81,7 +81,7 @@ def run(self): ], install_requires=[ 'attrs>=16.1.0', - 'click<7.1', + 'click', 'coverage<5.0a6', ], extras_require={