Skip to content

Commit f62c9eb

Browse files
authored
Merge pull request #488 from pytest-dev/graingert-patch-1
Update .pre-commit-config.yaml
2 parents 1f4277c + e31a95f commit f62c9eb

File tree

12 files changed

+33
-51
lines changed

12 files changed

+33
-51
lines changed

.appveyor.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,13 @@ image:
77
environment:
88
matrix:
99
- TOXENV: check
10-
- TOXENV: 'py27-pytest46-xdist127-coverage55'
11-
- TOXENV: 'py35-pytest46-xdist127-coverage55'
1210
- TOXENV: 'py36-pytest46-xdist127-coverage55,py36-pytest46-xdist133-coverage55,py36-pytest54-xdist133-coverage55,py36-pytest62-xdist202-coverage55'
1311
- TOXENV: 'py37-pytest46-xdist127-coverage55,py37-pytest46-xdist133-coverage55,py37-pytest54-xdist133-coverage55,py37-pytest62-xdist202-coverage55'
1412
- TOXENV: 'py38-pytest46-xdist133-coverage55,py38-pytest54-xdist133-coverage55,py38-pytest62-xdist202-coverage55'
1513
- TOXENV: 'py39-pytest62-xdist202-coverage55'
16-
- TOXENV: 'pypy-pytest46-xdist127-coverage55'
1714
- TOXENV: 'pypy3-pytest46-xdist127-coverage55,pypy3-pytest46-xdist133-coverage55,pypy3-pytest54-xdist133-coverage55,pypy3-pytest62-xdist202-coverage55'
1815
matrix:
1916
exclude:
20-
- image: Visual Studio 2019
21-
TOXENV: 'py27-pytest46-xdist127-coverage55'
2217
- image: Visual Studio 2015
2318
TOXENV: 'py36-pytest46-xdist127-coverage55,py36-pytest46-xdist133-coverage55,py36-pytest54-xdist133-coverage55,py36-pytest62-xdist202-coverage55'
2419
- image: Visual Studio 2015
@@ -27,15 +22,12 @@ matrix:
2722
TOXENV: 'py38-pytest46-xdist133-coverage55,py38-pytest54-xdist133-coverage55,py38-pytest62-xdist202-coverage55'
2823
- image: Visual Studio 2015
2924
TOXENV: 'py39-pytest62-xdist202-coverage55'
30-
- image: Visual Studio 2015
31-
TOXENV: 'pypy-pytest46-xdist127-coverage55'
3225
- image: Visual Studio 2015
3326
TOXENV: 'pypy3-pytest46-xdist127-coverage55,pypy3-pytest46-xdist133-coverage55,pypy3-pytest54-xdist133-coverage55,pypy3-pytest62-xdist202-coverage55'
3427
init:
3528
- ps: echo $env:TOXENV
3629
- ps: ls C:\Python*
3730
install:
38-
- IF "%TOXENV:~0,5%" == "pypy-" choco install --no-progress python.pypy
3931
- IF "%TOXENV:~0,6%" == "pypy3-" choco install --no-progress pypy3
4032
- SET PATH=C:\tools\pypy\pypy;%PATH%
4133
- C:\Python37\python -m pip install --progress-bar=off tox -rci/requirements.txt

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# pre-commit install
33
# To update the pre-commit hooks run:
44
# pre-commit install-hooks
5-
exclude: '^(src/.*\.pth|\.tox|ci/templates|\.bumpversion\.cfg)(/|$)'
65
repos:
76
- repo: https://github.com/pre-commit/pre-commit-hooks
87
rev: v4.0.1
98
hooks:
109
- id: trailing-whitespace
1110
- id: end-of-file-fixer
11+
exclude: '.*\.pth$'
1212
- id: debug-statements
1313
- repo: https://github.com/PyCQA/isort
1414
rev: 5.9.3
@@ -18,3 +18,8 @@ repos:
1818
rev: 3.9.2
1919
hooks:
2020
- id: flake8
21+
- repo: https://github.com/asottile/pyupgrade
22+
rev: v2.23.3
23+
hooks:
24+
- id: pyupgrade
25+
args: [--py36-plus]

ci/bootstrap.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
from __future__ import absolute_import
4-
from __future__ import print_function
5-
from __future__ import unicode_literals
62

73
import os
84
import subprocess
@@ -30,7 +26,7 @@ def exec_in_env():
3026
if not exists(env_path):
3127
import subprocess
3228

33-
print("Making bootstrap env in: {0} ...".format(env_path))
29+
print(f"Making bootstrap env in: {env_path} ...")
3430
try:
3531
check_call([sys.executable, "-m", "venv", env_path])
3632
except subprocess.CalledProcessError:
@@ -44,15 +40,15 @@ def exec_in_env():
4440
if not os.path.exists(python_executable):
4541
python_executable += '.exe'
4642

47-
print("Re-executing with: {0}".format(python_executable))
43+
print(f"Re-executing with: {python_executable}")
4844
print("+ exec", python_executable, __file__, "--no-env")
4945
os.execv(python_executable, [python_executable, __file__, "--no-env"])
5046

5147

5248
def main():
5349
import jinja2
5450

55-
print("Project path: {0}".format(base_path))
51+
print(f"Project path: {base_path}")
5652

5753
jinja = jinja2.Environment(
5854
loader=jinja2.FileSystemLoader(join(base_path, "ci", "templates")),
@@ -78,7 +74,7 @@ def main():
7874
with open(join(base_path, name), "w") as fh:
7975
fh.write('# NOTE: this file is auto-generated via ci/bootstrap.py (ci/templates/%s).\n' % name)
8076
fh.write(jinja.get_template(name).render(**template_vars))
81-
print("Wrote {}".format(name))
77+
print(f"Wrote {name}")
8278
print("DONE.")
8379

8480

@@ -89,5 +85,5 @@ def main():
8985
elif not args:
9086
exec_in_env()
9187
else:
92-
print("Unexpected arguments {0}".format(args), file=sys.stderr)
88+
print(f"Unexpected arguments {args}", file=sys.stderr)
9389
sys.exit(1)

docs/conf.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
import os
52

63
import sphinx_py3doc_enhanced_theme
@@ -25,7 +22,7 @@
2522
project = 'pytest-cov'
2623
year = '2016'
2724
author = 'pytest-cov contributors'
28-
copyright = '{}, {}'.format(year, author)
25+
copyright = f'{year}, {author}'
2926
version = release = '2.12.1'
3027

3128
pygments_style = 'trac'
@@ -47,7 +44,7 @@
4744
html_sidebars = {
4845
'**': ['searchbox.html', 'globaltoc.html', 'sourcelink.html'],
4946
}
50-
html_short_title = '%s-%s' % (project, version)
47+
html_short_title = f'{project}-{version}'
5148

5249
napoleon_use_ivar = True
5350
napoleon_use_rtype = False

examples/adhoc-layout/example/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import sys
32

43
PY2 = sys.version_info[0] == 2

examples/src-layout/src/example/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import sys
32

43
PY2 = sys.version_info[0] == 2

setup.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/usr/bin/env python
2-
# -*- encoding: utf-8 -*-
3-
from __future__ import absolute_import
4-
from __future__ import print_function
52

6-
import io
73
import re
84
from distutils.command.build import build
95
from glob import glob
@@ -22,7 +18,7 @@
2218

2319

2420
def read(*names, **kwargs):
25-
with io.open(
21+
with open(
2622
join(dirname(__file__), *names),
2723
encoding=kwargs.get('encoding', 'utf8')
2824
) as fh:
@@ -88,7 +84,7 @@ def run(self):
8884
version='2.12.1',
8985
license='MIT',
9086
description='Pytest plugin for measuring coverage.',
91-
long_description='%s\n%s' % (read('README.rst'), re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))),
87+
long_description='{}\n{}'.format(read('README.rst'), re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))),
9288
author='Marc Schlaich',
9389
author_email='[email protected]',
9490
url='https://github.com/pytest-dev/pytest-cov',
@@ -107,9 +103,8 @@ def run(self):
107103
'Operating System :: POSIX',
108104
'Operating System :: Unix',
109105
'Programming Language :: Python',
110-
'Programming Language :: Python :: 2',
111-
'Programming Language :: Python :: 2.7',
112106
'Programming Language :: Python :: 3',
107+
'Programming Language :: Python :: 3 :: Only',
113108
'Programming Language :: Python :: 3.6',
114109
'Programming Language :: Python :: 3.7',
115110
'Programming Language :: Python :: 3.8',
@@ -126,7 +121,7 @@ def run(self):
126121
'pytest>=4.6',
127122
'coverage[toml]>=5.2.1'
128123
],
129-
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
124+
python_requires='>=3.6',
130125
extras_require={
131126
'testing': [
132127
'fields',

src/pytest_cov/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
hookwrapper = pytest.mark.hookwrapper
1515

1616

17-
class SessionWrapper(object):
17+
class SessionWrapper:
1818
def __init__(self, session):
1919
self._session = session
2020
if hasattr(session, 'testsfailed'):

src/pytest_cov/engine.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .embed import cleanup
1515

1616

17-
class _NullFile(object):
17+
class _NullFile:
1818
@staticmethod
1919
def write(v):
2020
pass
@@ -49,7 +49,7 @@ def ensure_topdir_wrapper(self, *args, **kwargs):
4949
return ensure_topdir_wrapper
5050

5151

52-
class CovController(object):
52+
class CovController:
5353
"""Base class for different plugin implementations."""
5454

5555
def __init__(self, cov_source, cov_report, cov_config, cov_append, cov_branch, config=None, nodeid=None):
@@ -116,7 +116,7 @@ def unset_env():
116116
def get_node_desc(platform, version_info):
117117
"""Return a description of this node."""
118118

119-
return 'platform %s, python %s' % (platform, '%s.%s.%s-%s-%s' % version_info[:5])
119+
return 'platform {}, python {}'.format(platform, '%s.%s.%s-%s-%s' % version_info[:5])
120120

121121
@staticmethod
122122
def sep(stream, s, txt):
@@ -126,7 +126,7 @@ def sep(stream, s, txt):
126126
sep_total = max((70 - 2 - len(txt)), 2)
127127
sep_len = sep_total // 2
128128
sep_extra = sep_total % 2
129-
out = '%s %s %s\n' % (s * sep_len, txt, s * (sep_len + sep_extra))
129+
out = f'{s * sep_len} {txt} {s * (sep_len + sep_extra)}\n'
130130
stream.write(out)
131131

132132
@_ensure_topdir

src/pytest_cov/plugin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def validate_report(arg):
3636
values = arg.split(":", 1)
3737
report_type = values[0]
3838
if report_type not in all_choices + ['']:
39-
msg = 'invalid choice: "{}" (choose from "{}")'.format(arg, all_choices)
39+
msg = f'invalid choice: "{arg}" (choose from "{all_choices}")'
4040
raise argparse.ArgumentTypeError(msg)
4141

4242
if len(values) == 1:
@@ -141,7 +141,7 @@ def pytest_load_initial_conftests(early_config, parser, args):
141141
early_config.pluginmanager.register(plugin, '_cov')
142142

143143

144-
class CovPlugin(object):
144+
class CovPlugin:
145145
"""Use coverage package to produce code coverage reports.
146146
147147
Delegates all work to a particular implementation based on whether
@@ -196,7 +196,7 @@ def start(self, controller_cls, config=None, nodeid=None):
196196

197197
if config is None:
198198
# fake config option for engine
199-
class Config(object):
199+
class Config:
200200
option = self.options
201201

202202
config = Config()
@@ -354,7 +354,7 @@ def pytest_runtest_call(self, item):
354354
yield
355355

356356

357-
class TestContextPlugin(object):
357+
class TestContextPlugin:
358358
def __init__(self, cov):
359359
self.cov = cov
360360

@@ -368,7 +368,7 @@ def pytest_runtest_call(self, item):
368368
self.switch_context(item, 'run')
369369

370370
def switch_context(self, item, when):
371-
context = "{item.nodeid}|{when}".format(item=item, when=when)
371+
context = f"{item.nodeid}|{when}"
372372
self.cov.switch_context(context)
373373
os.environ['COV_CORE_CONTEXT'] = context
374374

tests/test_pytest_cov.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from process_tests import TestProcess as _TestProcess
1717
from process_tests import dump_on_error
1818
from process_tests import wait_for_strings
19-
from six import exec_
2019

2120
import pytest_cov.plugin
2221

@@ -780,13 +779,13 @@ def test_dist_not_collocated_coveragerc_source(testdir, prop):
780779
dir2 = testdir.mkdir('dir2')
781780
testdir.tmpdir.join('.coveragerc').write('''
782781
[run]
783-
%s
784-
source = %s
782+
{}
783+
source = {}
785784
[paths]
786785
source =
787786
.
788787
dir1
789-
dir2''' % (prop.conf, script.dirpath()))
788+
dir2'''.format(prop.conf, script.dirpath()))
790789

791790
result = testdir.runpytest('-v',
792791
'--cov',
@@ -1964,7 +1963,7 @@ def bad_init():
19641963
monkeypatch.setattr(embed, 'init', bad_init)
19651964
monkeypatch.setattr(sys, 'stderr', buff)
19661965
monkeypatch.setitem(os.environ, 'COV_CORE_SOURCE', 'foobar')
1967-
exec_(payload)
1966+
exec(payload)
19681967
assert buff.getvalue() == '''pytest-cov: Failed to setup subprocess coverage. Environ: {'COV_CORE_SOURCE': 'foobar'} Exception: SpecificError()
19691968
'''
19701969

@@ -2087,7 +2086,7 @@ def test_contexts(testdir, opts):
20872086
continue
20882087
data.set_query_context(context)
20892088
actual = set(data.lines(test_context_path))
2090-
assert line_data[label] == actual, "Wrong lines for context {!r}".format(context)
2089+
assert line_data[label] == actual, f"Wrong lines for context {context!r}"
20912090

20922091

20932092
@pytest.mark.skipif("coverage.version_info >= (5, 0)")

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ passenv =
1313
[tox]
1414
envlist =
1515
check
16-
py{27,35,36,37,py,py3}-pytest46-xdist127-coverage{55}
16+
py{36,37,py,py3}-pytest46-xdist127-coverage{55}
1717
py{36,37,38,py3}-pytest{46,54}-xdist133-coverage{55}
1818
py{36,37,38,39,py3}-pytest{62}-xdist202-coverage{55}
1919
docs

0 commit comments

Comments
 (0)