Skip to content

Commit 5976f36

Browse files
authored
Merge pull request #5368 from asottile/pyupgrade
Automated / semi-automated python3 upgrades
2 parents b8781ff + ce78c9a commit 5976f36

File tree

191 files changed

+820
-1517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+820
-1517
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ repos:
77
args: [--safe, --quiet]
88
language_version: python3
99
- repo: https://github.com/asottile/blacken-docs
10-
rev: v0.5.0
10+
rev: v1.0.0
1111
hooks:
1212
- id: blacken-docs
1313
additional_dependencies: [black==19.3b0]
1414
language_version: python3
1515
- repo: https://github.com/pre-commit/pre-commit-hooks
16-
rev: v2.2.2
16+
rev: v2.2.3
1717
hooks:
1818
- id: trailing-whitespace
1919
- id: end-of-file-fixer
2020
- id: fix-encoding-pragma
21+
args: [--remove]
2122
- id: check-yaml
2223
- id: debug-statements
2324
exclude: _pytest/debugging.py
@@ -31,14 +32,14 @@ repos:
3132
rev: v1.4.0
3233
hooks:
3334
- id: reorder-python-imports
34-
args: ['--application-directories=.:src']
35+
args: ['--application-directories=.:src', --py3-plus]
3536
- repo: https://github.com/asottile/pyupgrade
36-
rev: v1.15.0
37+
rev: v1.18.0
3738
hooks:
3839
- id: pyupgrade
39-
args: [--keep-percent-format]
40+
args: [--py3-plus]
4041
- repo: https://github.com/pre-commit/pygrep-hooks
41-
rev: v1.3.0
42+
rev: v1.4.0
4243
hooks:
4344
- id: rst-backticks
4445
- repo: local

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37
3535

3636
# Full run of latest supported version, without xdist.
37-
- env: TOXENV=py37
37+
- env: TOXENV=py37 PYTEST_COVERAGE=1
3838
python: '3.7'
3939

4040
# Coverage tracking is slow with pypy, skip it.

bench/bench.py

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

43
if __name__ == "__main__":

bench/bench_argcomplete.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# 10000 iterations, just for relative comparison
32
# 2.7.5 3.3.2
43
# FilesCompleter 75.1109 69.2116

bench/empty.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
# -*- coding: utf-8 -*-
21
for i in range(1000):
32
exec("def test_func_%d(): pass" % i)

bench/manyparam.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import pytest
32

43

bench/skip.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from six.moves import range
3-
41
import pytest
52

63
SKIP = True

doc/en/_themes/flask_theme_support.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# flasky extensions. flasky pygments style based on tango style
32
from pygments.style import Style
43
from pygments.token import Comment

doc/en/conf.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# pytest documentation build configuration file, created by
43
# sphinx-quickstart on Fri Oct 8 17:54:28 2010.
@@ -63,9 +62,9 @@
6362
master_doc = "contents"
6463

6564
# General information about the project.
66-
project = u"pytest"
65+
project = "pytest"
6766
year = datetime.datetime.utcnow().year
68-
copyright = u"2015–2019 , holger krekel and pytest-dev team"
67+
copyright = "2015–2019 , holger krekel and pytest-dev team"
6968

7069

7170
# The language for content autogenerated by Sphinx. Refer to documentation
@@ -233,8 +232,8 @@
233232
(
234233
"contents",
235234
"pytest.tex",
236-
u"pytest Documentation",
237-
u"holger krekel, trainer and consultant, http://merlinux.eu",
235+
"pytest Documentation",
236+
"holger krekel, trainer and consultant, http://merlinux.eu",
238237
"manual",
239238
)
240239
]
@@ -266,16 +265,16 @@
266265

267266
# One entry per manual page. List of tuples
268267
# (source start file, name, description, authors, manual section).
269-
man_pages = [("usage", "pytest", u"pytest usage", [u"holger krekel at merlinux eu"], 1)]
268+
man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"], 1)]
270269

271270

272271
# -- Options for Epub output ---------------------------------------------------
273272

274273
# Bibliographic Dublin Core info.
275-
epub_title = u"pytest"
276-
epub_author = u"holger krekel at merlinux eu"
277-
epub_publisher = u"holger krekel at merlinux eu"
278-
epub_copyright = u"2013, holger krekel et alii"
274+
epub_title = "pytest"
275+
epub_author = "holger krekel at merlinux eu"
276+
epub_publisher = "holger krekel at merlinux eu"
277+
epub_copyright = "2013, holger krekel et alii"
279278

280279
# The language of the text. It defaults to the language option
281280
# or en if the language is not set.

doc/en/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# -*- coding: utf-8 -*-
21
collect_ignore = ["conf.py"]

doc/en/example/assertion/failure_demo.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import _pytest._code
32
import pytest
43
from pytest import raises
@@ -21,7 +20,7 @@ def test_generative(param1, param2):
2120
assert param1 * 2 < param2
2221

2322

24-
class TestFailing(object):
23+
class TestFailing:
2524
def test_simple(self):
2625
def f():
2726
return 42
@@ -41,7 +40,7 @@ def f():
4140
assert not f()
4241

4342

44-
class TestSpecialisedExplanations(object):
43+
class TestSpecialisedExplanations:
4544
def test_eq_text(self):
4645
assert "spam" == "eggs"
4746

@@ -101,7 +100,7 @@ def test_eq_dataclass(self):
101100
from dataclasses import dataclass
102101

103102
@dataclass
104-
class Foo(object):
103+
class Foo:
105104
a: int
106105
b: str
107106

@@ -113,7 +112,7 @@ def test_eq_attrs(self):
113112
import attr
114113

115114
@attr.s
116-
class Foo(object):
115+
class Foo:
117116
a = attr.ib()
118117
b = attr.ib()
119118

@@ -123,22 +122,22 @@ class Foo(object):
123122

124123

125124
def test_attribute():
126-
class Foo(object):
125+
class Foo:
127126
b = 1
128127

129128
i = Foo()
130129
assert i.b == 2
131130

132131

133132
def test_attribute_instance():
134-
class Foo(object):
133+
class Foo:
135134
b = 1
136135

137136
assert Foo().b == 2
138137

139138

140139
def test_attribute_failure():
141-
class Foo(object):
140+
class Foo:
142141
def _get_b(self):
143142
raise Exception("Failed to get attrib")
144143

@@ -149,10 +148,10 @@ def _get_b(self):
149148

150149

151150
def test_attribute_multiple():
152-
class Foo(object):
151+
class Foo:
153152
b = 1
154153

155-
class Bar(object):
154+
class Bar:
156155
b = 2
157156

158157
assert Foo().b == Bar().b
@@ -162,7 +161,7 @@ def globf(x):
162161
return x + 1
163162

164163

165-
class TestRaises(object):
164+
class TestRaises:
166165
def test_raises(self):
167166
s = "qwe"
168167
raises(TypeError, int, s)
@@ -203,7 +202,7 @@ def test_dynamic_compile_shows_nicely():
203202
module.foo()
204203

205204

206-
class TestMoreErrors(object):
205+
class TestMoreErrors:
207206
def test_complex_error(self):
208207
def f():
209208
return 44
@@ -253,16 +252,16 @@ def test_try_finally(self):
253252
x = 0
254253

255254

256-
class TestCustomAssertMsg(object):
255+
class TestCustomAssertMsg:
257256
def test_single_line(self):
258-
class A(object):
257+
class A:
259258
a = 1
260259

261260
b = 2
262261
assert A.a == b, "A.a appears not to be b"
263262

264263
def test_multiline(self):
265-
class A(object):
264+
class A:
266265
a = 1
267266

268267
b = 2
@@ -271,7 +270,7 @@ class A(object):
271270
), "A.a appears not to be b\nor does not appear to be b\none of those"
272271

273272
def test_custom_repr(self):
274-
class JSON(object):
273+
class JSON:
275274
a = 1
276275

277276
def __repr__(self):

doc/en/example/assertion/global_testmodule_config/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import py
32

43
import pytest

doc/en/example/assertion/global_testmodule_config/test_hello_world.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
hello = "world"
32

43

doc/en/example/assertion/test_failures.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import py
32

43
failure_demo = py.path.local(__file__).dirpath("failure_demo.py")

doc/en/example/assertion/test_setup_flow_example.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# -*- coding: utf-8 -*-
21
def setup_module(module):
32
module.TestStateFullThing.classcount = 0
43

54

6-
class TestStateFullThing(object):
5+
class TestStateFullThing:
76
def setup_class(cls):
87
cls.classcount += 1
98

doc/en/example/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# -*- coding: utf-8 -*-
21
collect_ignore = ["nonpython"]

doc/en/example/costlysetup/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import pytest
32

43

@@ -9,7 +8,7 @@ def setup(request):
98
setup.finalize()
109

1110

12-
class CostlySetup(object):
11+
class CostlySetup:
1312
def __init__(self):
1413
import time
1514

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# -*- coding: utf-8 -*-
21
#
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
# -*- coding: utf-8 -*-
21
def test_quick(setup):
32
pass
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# -*- coding: utf-8 -*-
21
#

doc/en/example/costlysetup/sub_b/test_two.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
def test_something(setup):
32
assert setup.timecostly == 1
43

doc/en/example/multipython.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
module containing a parametrized tests testing cross-python
43
serialization via the pickle module.
@@ -23,7 +22,7 @@ def python2(request, python1):
2322
return Python(request.param, python1.picklefile)
2423

2524

26-
class Python(object):
25+
class Python:
2726
def __init__(self, version, picklefile):
2827
self.pythonpath = distutils.spawn.find_executable(version)
2928
if not self.pythonpath:

doc/en/example/nonpython/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# content of conftest.py
32
import pytest
43

@@ -19,7 +18,7 @@ def collect(self):
1918

2019
class YamlItem(pytest.Item):
2120
def __init__(self, name, parent, spec):
22-
super(YamlItem, self).__init__(name, parent)
21+
super().__init__(name, parent)
2322
self.spec = spec
2423

2524
def runtest(self):

doc/en/example/py2py3/conftest.py

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

43
import pytest

doc/en/example/py2py3/test_py3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
def test_exception_syntax():
32
try:
43
0 / 0

doc/en/example/pythoncollection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# run this with $ pytest --collect-only test_collectonly.py
32
#
43

@@ -7,7 +6,7 @@ def test_function():
76
pass
87

98

10-
class TestClass(object):
9+
class TestClass:
1110
def test_method(self):
1211
pass
1312

doc/en/example/xfail_demo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import pytest
32

43
xfail = pytest.mark.xfail

doc/en/writing_plugins.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,6 @@ string value of ``Hello World!`` if we do not supply a value or ``Hello
335335

336336
.. code-block:: python
337337
338-
# -*- coding: utf-8 -*-
339-
340338
import pytest
341339
342340

extra/get_issues.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import json
32

43
import py

extra/setup-py.test/setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import sys
32
from distutils.core import setup
43

scripts/release.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Invoke development tasks.
43
"""

0 commit comments

Comments
 (0)