From f8ef58235ea9c0eff08624fe44b64fe0b4ccb20a Mon Sep 17 00:00:00 2001 From: Kevin James Date: Fri, 26 Apr 2024 09:06:54 +0100 Subject: [PATCH] feat: drop support for python 3.5 --- .circleci/config.yml | 4 ---- .github/workflows/pythonpackage.yml | 2 +- .pre-commit-config.yaml | 8 +++++--- .travis.yml | 1 - coveralls/api.py | 24 ++++++++++++------------ coveralls/git.py | 6 +++--- coveralls/reporter.py | 3 +-- docs/usage/tox.rst | 2 +- setup.py | 3 +-- tests/api/reporter_test.py | 4 ++-- tests/conftest.py | 2 +- tests/git_test.py | 4 ++-- tox.ini | 3 +-- 13 files changed, 30 insertions(+), 36 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5d693fa5..c05166e9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,10 +61,6 @@ workflows: test-cpython: jobs: - - toxpy: - name: test-py3.5 - docker_image: '3.5' - tox_environment: py35 - toxpy: name: test-py3.6-cov<> docker_image: '3.6' diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index ca4f2c0d..7b5910be 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -8,7 +8,7 @@ jobs: strategy: max-parallel: 6 matrix: - python-version: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10'] + python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] steps: - uses: actions/checkout@v3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ba2b8c10..7cb1f4ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,6 +2,9 @@ ci: autofix_commit_msg: 'refactor(lint): apply automatic lint fixes' autoupdate_commit_msg: 'chore(deps): bump pre-commit linter versions' +default_language_version: + python: python3.7 + repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 @@ -58,7 +61,6 @@ repos: - -d too-few-public-methods - -d ungrouped-imports # conflicts with reorder-python-imports - -d wrong-import-order # conflicts with reorder-python-imports - - -d consider-using-f-string # not py35 compatible - -d unspecified-encoding # TODO: reevaluate - -d disallowed-name # TODO: fix exclude: example/.* @@ -70,13 +72,13 @@ repos: rev: v3.9.0 hooks: - id: reorder-python-imports - args: [--py3-plus] + args: [--py36-plus] exclude: nonunicode/.* - repo: https://github.com/asottile/pyupgrade rev: v3.2.2 hooks: - id: pyupgrade - args: [--py3-plus] + args: [--py36-plus] exclude: nonunicode/.* - repo: https://github.com/asottile/yesqa rev: v1.4.0 diff --git a/.travis.yml b/.travis.yml index 91e55366..1b8be745 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ sudo: false language: python python: - - 3.5 - 3.6 - 3.7 - 3.8 diff --git a/coveralls/api.py b/coveralls/api.py index 5997a994..1d833344 100644 --- a/coveralls/api.py +++ b/coveralls/api.py @@ -59,9 +59,8 @@ def ensure_token(self): 'your step config.') raise CoverallsException( - 'Not on TravisCI. You have to provide either repo_token in {} or ' - 'set the COVERALLS_REPO_TOKEN env var.'.format( - self.config_filename)) + 'Not on TravisCI. You have to provide either repo_token in ' + f'{self.config_filename} or set the COVERALLS_REPO_TOKEN env var.') def load_config(self, kwargs, service_name): """ @@ -257,7 +256,7 @@ def wear(self, dry_run=False): return self.submit_report(json_string) def submit_report(self, json_string): - endpoint = '{}/api/v1/jobs'.format(self._coveralls_host.rstrip('/')) + endpoint = f'{self._coveralls_host.rstrip("/")}/api/v1/jobs' verify = not bool(os.environ.get('COVERALLS_SKIP_SSL_VERIFY')) response = requests.post(endpoint, files={'json_file': json_string}, verify=verify) @@ -273,10 +272,11 @@ def submit_report(self, json_string): if os.environ.get('GITHUB_REPOSITORY'): new_id = None else: - new_id = '{}-{}'.format( - self.config.get('service_job_id', 42), - random.randint(0, sys.maxsize)) - print('resubmitting with id {}'.format(new_id)) + new_id = '-'.join(( + self.config.get('service_job_id', '42'), + str(random.randint(0, sys.maxsize)), + )) + print(f'resubmitting with id {new_id}') self.config['service_job_id'] = new_id self._data = None # force create_report to use updated data @@ -291,7 +291,7 @@ def submit_report(self, json_string): return response.json() except Exception as e: raise CoverallsException( - 'Could not submit coverage: {}'.format(e)) from e + f'Could not submit coverage: {e}') from e # https://docs.coveralls.io/parallel-build-webhook def parallel_finish(self): @@ -308,7 +308,7 @@ def parallel_finish(self): # Github Actions only payload['repo_name'] = os.environ.get('GITHUB_REPOSITORY') - endpoint = '{}/webhook'.format(self._coveralls_host.rstrip('/')) + endpoint = f'{self._coveralls_host.rstrip("/")}/webhook' verify = not bool(os.environ.get('COVERALLS_SKIP_SSL_VERIFY')) response = requests.post(endpoint, json=payload, verify=verify) try: @@ -316,11 +316,11 @@ def parallel_finish(self): response = response.json() except Exception as e: raise CoverallsException( - 'Parallel finish failed: {}'.format(e)) from e + f'Parallel finish failed: {e}') from e if 'error' in response: e = response['error'] - raise CoverallsException('Parallel finish failed: {}'.format(e)) + raise CoverallsException(f'Parallel finish failed: {e}') if 'done' not in response or not response['done']: raise CoverallsException('Parallel finish failed') diff --git a/coveralls/git.py b/coveralls/git.py index 895405ae..093f69d0 100644 --- a/coveralls/git.py +++ b/coveralls/git.py @@ -15,15 +15,15 @@ def run_command(*args): if cmd.returncode != 0: raise CoverallsException( - 'command return code {}, STDOUT: "{}"\nSTDERR: "{}"'.format( - cmd.returncode, stdout, stderr)) + f'command returned code {cmd.returncode}, STDOUT: "{stdout}"\n' + f'STDERR: "{stderr}"') return stdout.decode().strip() def gitlog(fmt): glog = run_command('git', '--no-pager', 'log', '-1', - '--pretty=format:{}'.format(fmt)) + f'--pretty=format:{fmt}') return str(glog) diff --git a/coveralls/reporter.py b/coveralls/reporter.py index 06f0b141..07c1051d 100644 --- a/coveralls/reporter.py +++ b/coveralls/reporter.py @@ -96,8 +96,7 @@ def report5(self, cov): # should_be_python() method. if fr.should_be_python(): if config.ignore_errors: - msg = "Couldn't parse Python file '{}'".format( - fr.filename) + msg = f"Couldn't parse Python file '{fr.filename}'" cov._warn(msg, # pylint: disable=W0212 slug='couldnt-parse') else: diff --git a/docs/usage/tox.rst b/docs/usage/tox.rst index 3605bc26..fbacae0b 100644 --- a/docs/usage/tox.rst +++ b/docs/usage/tox.rst @@ -6,7 +6,7 @@ Running coveralls-python from within a `tox`_ environment (v2.0 and above) requi For example, on TravisCI:: [tox] - envlist = py34,py35,py36,py37,py38 + envlist = py310,py311,py312 [testenv] passenv = TRAVIS TRAVIS_* diff --git a/setup.py b/setup.py index 100985fc..33422140 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ 'coveralls = coveralls.cli:main', ], }, - python_requires='>= 3.5', + python_requires='>= 3.6', install_requires=[ 'coverage>=4.1,<7.0,!=6.0.*,!=6.1,!=6.1.1', 'docopt>=0.6.1', @@ -49,7 +49,6 @@ 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', diff --git a/tests/api/reporter_test.py b/tests/api/reporter_test.py index c2743c3c..0281dc1f 100644 --- a/tests/api/reporter_test.py +++ b/tests/api/reporter_test.py @@ -51,7 +51,7 @@ def make_test_results(with_branches=False, name_prefix=''): ' print(\'condition tested both ways\')\n' ' if cond2:\n' ' print(\'condition not tested both ways\')\n'), - 'name': '{}project.py'.format(name_prefix), + 'name': f'{name_prefix}project.py', 'coverage': [1, 1, None, None, 1, None, None, None, 1, 0, None, 1, 1, 1, 1, 1]}, { 'source': ('from project import branch\n' @@ -60,7 +60,7 @@ def make_test_results(with_branches=False, name_prefix=''): ' hello()\n' ' branch(False, True)\n' ' branch(True, True)\n'), - 'name': '{}runtests.py'.format(name_prefix), + 'name': f'{name_prefix}runtests.py', 'coverage': [1, 1, None, 1, 1, 1, 1]}) if with_branches: results[0]['branches'] = [13, 0, 14, 1, 13, 0, 15, 1, 15, 0, 16, 1, diff --git a/tests/conftest.py b/tests/conftest.py index b48c069b..36a520a1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,6 +7,6 @@ def nuke_coverage(): for folder in ('.', './example', './nonunicode'): try: - os.remove('{}/.coverage'.format(folder)) + os.remove(f'{folder}/.coverage') except FileNotFoundError: pass diff --git a/tests/git_test.py b/tests/git_test.py index 4d8bf602..da2cded7 100644 --- a/tests/git_test.py +++ b/tests/git_test.py @@ -33,9 +33,9 @@ def setUp(self): subprocess.call(['git', 'init'], cwd=self.dir) subprocess.call(['git', 'config', 'user.name', - '"{}"'.format(GIT_NAME)], cwd=self.dir) + f'"{GIT_NAME}"'], cwd=self.dir) subprocess.call(['git', 'config', 'user.email', - '"{}"'.format(GIT_EMAIL)], cwd=self.dir) + f'"{GIT_EMAIL}"'], cwd=self.dir) subprocess.call(['git', 'add', 'README'], cwd=self.dir) subprocess.call(['git', 'commit', '-m', GIT_COMMIT_MSG], cwd=self.dir) subprocess.call(['git', 'remote', 'add', GIT_REMOTE, GIT_URL], diff --git a/tox.ini b/tox.ini index f5cedc4c..024cb831 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,8 @@ [tox] -envlist = py35-cov41-{default,pyyaml},py{36,37,38,39,310,py3}-cov{41,5,6}-{default,pyyaml} +envlist = py{36,37,38,39,310,py3}-cov{41,5,6}-{default,pyyaml} [gh-actions] python = - 3.5: py35 3.6: py36-cov6 3.7: py37-cov6 3.8: py38-cov6