Skip to content

Commit f93995e

Browse files
Merge pull request #3614 from asottile/upgrade_hooks
Upgrade hooks
2 parents 8133d19 + f940967 commit f93995e

Some content is hidden

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

86 files changed

+311
-633
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
exclude: doc/en/example/py2py3/test_py2.py
22
repos:
33
- repo: https://github.com/ambv/black
4-
rev: 18.4a4
4+
rev: 18.6b4
55
hooks:
66
- id: black
77
args: [--safe, --quiet]
88
language_version: python3.6
99
- repo: https://github.com/asottile/blacken-docs
10-
rev: v0.1.1
10+
rev: v0.2.0
1111
hooks:
1212
- id: blacken-docs
13-
additional_dependencies: [black==18.5b1]
13+
additional_dependencies: [black==18.6b4]
1414
language_version: python3.6
1515
- repo: https://github.com/pre-commit/pre-commit-hooks
16-
rev: v1.2.3
16+
rev: v1.3.0
1717
hooks:
1818
- id: trailing-whitespace
1919
- id: end-of-file-fixer

doc/en/example/assertion/failure_demo.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def pytest_generate_tests(metafunc):
2525

2626

2727
class TestFailing(object):
28-
2928
def test_simple(self):
30-
3129
def f():
3230
return 42
3331

@@ -40,15 +38,13 @@ def test_simple_multiline(self):
4038
otherfunc_multi(42, 6 * 9)
4139

4240
def test_not(self):
43-
4441
def f():
4542
return 42
4643

4744
assert not f()
4845

4946

5047
class TestSpecialisedExplanations(object):
51-
5248
def test_eq_text(self):
5349
assert "spam" == "eggs"
5450

@@ -106,7 +102,6 @@ def test_not_in_text_single_long_term(self):
106102

107103

108104
def test_attribute():
109-
110105
class Foo(object):
111106
b = 1
112107

@@ -115,17 +110,14 @@ class Foo(object):
115110

116111

117112
def test_attribute_instance():
118-
119113
class Foo(object):
120114
b = 1
121115

122116
assert Foo().b == 2
123117

124118

125119
def test_attribute_failure():
126-
127120
class Foo(object):
128-
129121
def _get_b(self):
130122
raise Exception("Failed to get attrib")
131123

@@ -136,7 +128,6 @@ def _get_b(self):
136128

137129

138130
def test_attribute_multiple():
139-
140131
class Foo(object):
141132
b = 1
142133

@@ -151,7 +142,6 @@ def globf(x):
151142

152143

153144
class TestRaises(object):
154-
155145
def test_raises(self):
156146
s = "qwe" # NOQA
157147
raises(TypeError, "int(s)")
@@ -193,9 +183,7 @@ def test_dynamic_compile_shows_nicely():
193183

194184

195185
class TestMoreErrors(object):
196-
197186
def test_complex_error(self):
198-
199187
def f():
200188
return 44
201189

@@ -218,7 +206,6 @@ def test_startswith(self):
218206
assert s.startswith(g)
219207

220208
def test_startswith_nested(self):
221-
222209
def f():
223210
return "123"
224211

@@ -246,17 +233,14 @@ def test_try_finally(self):
246233

247234

248235
class TestCustomAssertMsg(object):
249-
250236
def test_single_line(self):
251-
252237
class A(object):
253238
a = 1
254239

255240
b = 2
256241
assert A.a == b, "A.a appears not to be b"
257242

258243
def test_multiline(self):
259-
260244
class A(object):
261245
a = 1
262246

@@ -266,7 +250,6 @@ class A(object):
266250
), "A.a appears not to be b\n" "or does not appear to be b\none of those"
267251

268252
def test_custom_repr(self):
269-
270253
class JSON(object):
271254
a = 1
272255

doc/en/example/assertion/test_failures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import py
33

44
failure_demo = py.path.local(__file__).dirpath("failure_demo.py")
5-
pytest_plugins = "pytester",
5+
pytest_plugins = ("pytester",)
66

77

88
def test_failure_demo_fails_properly(testdir):

doc/en/example/assertion/test_setup_flow_example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ def setup_module(module):
33

44

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

doc/en/example/costlysetup/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def setup(request):
1010

1111

1212
class CostlySetup(object):
13-
1413
def __init__(self):
1514
import time
1615

doc/en/example/multipython.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def python2(request, python1):
2121

2222

2323
class Python(object):
24-
2524
def __init__(self, version, picklefile):
2625
self.pythonpath = py.path.local.sysfind(version)
2726
if not self.pythonpath:

doc/en/example/nonpython/conftest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ def pytest_collect_file(parent, path):
99

1010

1111
class YamlFile(pytest.File):
12-
1312
def collect(self):
1413
import yaml # we need a yaml parser, e.g. PyYAML
1514

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

2019

2120
class YamlItem(pytest.Item):
22-
2321
def __init__(self, name, parent, spec):
2422
super(YamlItem, self).__init__(name, parent)
2523
self.spec = spec

doc/en/example/py2py3/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class DummyCollector(pytest.collect.File):
8-
98
def collect(self):
109
return []
1110

doc/en/example/pythoncollection.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ def test_function():
77

88

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

src/_pytest/_code/code.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ class Traceback(list):
274274
""" Traceback objects encapsulate and offer higher level
275275
access to Traceback entries.
276276
"""
277+
277278
Entry = TracebackEntry
278279

279280
def __init__(self, tb, excinfo=None):
@@ -382,8 +383,11 @@ class ExceptionInfo(object):
382383
""" wraps sys.exc_info() objects and offers
383384
help for navigating the traceback.
384385
"""
386+
385387
_striptext = ""
386-
_assert_start_repr = "AssertionError(u'assert " if _PY2 else "AssertionError('assert "
388+
_assert_start_repr = (
389+
"AssertionError(u'assert " if _PY2 else "AssertionError('assert "
390+
)
387391

388392
def __init__(self, tup=None, exprinfo=None):
389393
import _pytest._code
@@ -424,7 +428,7 @@ def exconly(self, tryshort=False):
424428
text = text.rstrip()
425429
if tryshort:
426430
if text.startswith(self._striptext):
427-
text = text[len(self._striptext):]
431+
text = text[len(self._striptext) :]
428432
return text
429433

430434
def errisinstance(self, exc):
@@ -497,6 +501,7 @@ def match(self, regexp):
497501
@attr.s
498502
class FormattedExcinfo(object):
499503
""" presenting information about failing Functions and Generators. """
504+
500505
# for traceback entries
501506
flow_marker = ">"
502507
fail_marker = "E"
@@ -556,7 +561,7 @@ def get_source(self, source, line_index=-1, excinfo=None, short=False):
556561
for line in source.lines[:line_index]:
557562
lines.append(space_prefix + line)
558563
lines.append(self.flow_marker + " " + source.lines[line_index])
559-
for line in source.lines[line_index + 1:]:
564+
for line in source.lines[line_index + 1 :]:
560565
lines.append(space_prefix + line)
561566
if excinfo is not None:
562567
indent = 4 if short else self._getindent(source)
@@ -691,7 +696,7 @@ def _truncate_recursive_traceback(self, traceback):
691696
else:
692697
if recursionindex is not None:
693698
extraline = "!!! Recursion detected (same locals & position)"
694-
traceback = traceback[:recursionindex + 1]
699+
traceback = traceback[: recursionindex + 1]
695700
else:
696701
extraline = None
697702

@@ -722,15 +727,19 @@ def repr_excinfo(self, excinfo):
722727
repr_chain += [(reprtraceback, reprcrash, descr)]
723728
if e.__cause__ is not None:
724729
e = e.__cause__
725-
excinfo = ExceptionInfo(
726-
(type(e), e, e.__traceback__)
727-
) if e.__traceback__ else None
730+
excinfo = (
731+
ExceptionInfo((type(e), e, e.__traceback__))
732+
if e.__traceback__
733+
else None
734+
)
728735
descr = "The above exception was the direct cause of the following exception:"
729-
elif (e.__context__ is not None and not e.__suppress_context__):
736+
elif e.__context__ is not None and not e.__suppress_context__:
730737
e = e.__context__
731-
excinfo = ExceptionInfo(
732-
(type(e), e, e.__traceback__)
733-
) if e.__traceback__ else None
738+
excinfo = (
739+
ExceptionInfo((type(e), e, e.__traceback__))
740+
if e.__traceback__
741+
else None
742+
)
734743
descr = "During handling of the above exception, another exception occurred:"
735744
else:
736745
e = None
@@ -739,7 +748,6 @@ def repr_excinfo(self, excinfo):
739748

740749

741750
class TerminalRepr(object):
742-
743751
def __str__(self):
744752
s = self.__unicode__()
745753
if _PY2:
@@ -759,7 +767,6 @@ def __repr__(self):
759767

760768

761769
class ExceptionRepr(TerminalRepr):
762-
763770
def __init__(self):
764771
self.sections = []
765772

@@ -773,7 +780,6 @@ def toterminal(self, tw):
773780

774781

775782
class ExceptionChainRepr(ExceptionRepr):
776-
777783
def __init__(self, chain):
778784
super(ExceptionChainRepr, self).__init__()
779785
self.chain = chain
@@ -792,7 +798,6 @@ def toterminal(self, tw):
792798

793799

794800
class ReprExceptionInfo(ExceptionRepr):
795-
796801
def __init__(self, reprtraceback, reprcrash):
797802
super(ReprExceptionInfo, self).__init__()
798803
self.reprtraceback = reprtraceback
@@ -831,7 +836,6 @@ def toterminal(self, tw):
831836

832837

833838
class ReprTracebackNative(ReprTraceback):
834-
835839
def __init__(self, tblines):
836840
self.style = "native"
837841
self.reprentries = [ReprEntryNative(tblines)]
@@ -885,7 +889,6 @@ def __str__(self):
885889

886890

887891
class ReprFileLocation(TerminalRepr):
888-
889892
def __init__(self, path, lineno, message):
890893
self.path = str(path)
891894
self.lineno = lineno
@@ -903,7 +906,6 @@ def toterminal(self, tw):
903906

904907

905908
class ReprLocals(TerminalRepr):
906-
907909
def __init__(self, lines):
908910
self.lines = lines
909911

@@ -913,7 +915,6 @@ def toterminal(self, tw):
913915

914916

915917
class ReprFuncArgs(TerminalRepr):
916-
917918
def __init__(self, args):
918919
self.args = args
919920

src/_pytest/_code/source.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Source(object):
1717
""" an immutable object holding a source code fragment,
1818
possibly deindenting it.
1919
"""
20+
2021
_compilecounter = 0
2122

2223
def __init__(self, *parts, **kwargs):
@@ -60,7 +61,7 @@ def __getitem__(self, key):
6061
if key.step not in (None, 1):
6162
raise IndexError("cannot slice a Source with a step")
6263
newsource = Source()
63-
newsource.lines = self.lines[key.start:key.stop]
64+
newsource.lines = self.lines[key.start : key.stop]
6465
return newsource
6566

6667
def __len__(self):
@@ -178,7 +179,7 @@ def compile(
178179
except SyntaxError:
179180
ex = sys.exc_info()[1]
180181
# re-represent syntax errors from parsing python strings
181-
msglines = self.lines[:ex.lineno]
182+
msglines = self.lines[: ex.lineno]
182183
if ex.offset:
183184
msglines.append(" " * ex.offset + "^")
184185
msglines.append("(code was compiled probably from here: %s)" % filename)
@@ -313,7 +314,7 @@ def readline_generator(lines):
313314
except (IndentationError, tokenize.TokenError):
314315
pass
315316
# Add any lines we didn't see. E.g. if an exception was raised.
316-
newlines.extend(lines[len(newlines):])
317+
newlines.extend(lines[len(newlines) :])
317318
return newlines
318319

319320

src/_pytest/assertion/rewrite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def _rewrite_test(config, fn):
319319
if (
320320
not source.startswith(BOM_UTF8)
321321
and cookie_re.match(source[0:end1]) is None
322-
and cookie_re.match(source[end1 + 1:end2]) is None
322+
and cookie_re.match(source[end1 + 1 : end2]) is None
323323
):
324324
if hasattr(state, "_indecode"):
325325
# encodings imported us again, so don't rewrite.

0 commit comments

Comments
 (0)