Skip to content

Commit 2ad6dbb

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 28692bc commit 2ad6dbb

Some content is hidden

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

50 files changed

+326
-357
lines changed

doc/en/example/nonpython/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def runtest(self):
2828
raise YamlException(self, name, value)
2929

3030
def repr_failure(self, excinfo):
31-
""" called when self.runtest() raises an exception. """
31+
"""called when self.runtest() raises an exception."""
3232
if isinstance(excinfo.value, YamlException):
3333
return "\n".join(
3434
[
@@ -43,4 +43,4 @@ def reportinfo(self):
4343

4444

4545
class YamlException(Exception):
46-
""" custom exception for error reporting. """
46+
"""custom exception for error reporting."""

src/_pytest/_argcomplete.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ def __call__(self, prefix, **kwargs):
100100
def try_argcomplete(parser):
101101
argcomplete.autocomplete(parser, always_complete_options=False)
102102

103-
104103
else:
105104

106105
def try_argcomplete(parser):

src/_pytest/_code/code.py

Lines changed: 57 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333
class Code(object):
34-
""" wrapper around Python code objects """
34+
"""wrapper around Python code objects"""
3535

3636
def __init__(self, rawcode):
3737
if not hasattr(rawcode, "co_filename"):
@@ -54,8 +54,8 @@ def __ne__(self, other):
5454

5555
@property
5656
def path(self):
57-
""" return a path object pointing to source code (note that it
58-
might not point to an actually existing file). """
57+
"""return a path object pointing to source code (note that it
58+
might not point to an actually existing file)."""
5959
try:
6060
p = py.path.local(self.raw.co_filename)
6161
# maybe don't try this checking
@@ -70,26 +70,24 @@ def path(self):
7070

7171
@property
7272
def fullsource(self):
73-
""" return a _pytest._code.Source object for the full source file of the code
74-
"""
73+
"""return a _pytest._code.Source object for the full source file of the code"""
7574
from _pytest._code import source
7675

7776
full, _ = source.findsource(self.raw)
7877
return full
7978

8079
def source(self):
81-
""" return a _pytest._code.Source object for the code object's source only
82-
"""
80+
"""return a _pytest._code.Source object for the code object's source only"""
8381
# return source only for that part of code
8482
import _pytest._code
8583

8684
return _pytest._code.Source(self.raw)
8785

8886
def getargs(self, var=False):
89-
""" return a tuple with the argument names for the code object
87+
"""return a tuple with the argument names for the code object
9088
91-
if 'var' is set True also return the names of the variable and
92-
keyword arguments when present
89+
if 'var' is set True also return the names of the variable and
90+
keyword arguments when present
9391
"""
9492
# handfull shortcut for getting args
9593
raw = self.raw
@@ -113,46 +111,45 @@ def __init__(self, frame):
113111

114112
@property
115113
def statement(self):
116-
""" statement this frame is at """
114+
"""statement this frame is at"""
117115
import _pytest._code
118116

119117
if self.code.fullsource is None:
120118
return _pytest._code.Source("")
121119
return self.code.fullsource.getstatement(self.lineno)
122120

123121
def eval(self, code, **vars):
124-
""" evaluate 'code' in the frame
122+
"""evaluate 'code' in the frame
125123
126-
'vars' are optional additional local variables
124+
'vars' are optional additional local variables
127125
128-
returns the result of the evaluation
126+
returns the result of the evaluation
129127
"""
130128
f_locals = self.f_locals.copy()
131129
f_locals.update(vars)
132130
return eval(code, self.f_globals, f_locals)
133131

134132
def exec_(self, code, **vars):
135-
""" exec 'code' in the frame
133+
"""exec 'code' in the frame
136134
137-
'vars' are optiona; additional local variables
135+
'vars' are optiona; additional local variables
138136
"""
139137
f_locals = self.f_locals.copy()
140138
f_locals.update(vars)
141139
six.exec_(code, self.f_globals, f_locals)
142140

143141
def repr(self, object):
144-
""" return a 'safe' (non-recursive, one-line) string repr for 'object'
145-
"""
142+
"""return a 'safe' (non-recursive, one-line) string repr for 'object'"""
146143
return saferepr(object)
147144

148145
def is_true(self, object):
149146
return object
150147

151148
def getargs(self, var=False):
152-
""" return a list of tuples (name, value) for all arguments
149+
"""return a list of tuples (name, value) for all arguments
153150
154-
if 'var' is set True also include the variable and keyword
155-
arguments when present
151+
if 'var' is set True also include the variable and keyword
152+
arguments when present
156153
"""
157154
retval = []
158155
for arg in self.code.getargs(var):
@@ -164,7 +161,7 @@ def getargs(self, var=False):
164161

165162

166163
class TracebackEntry(object):
167-
""" a single entry in a traceback """
164+
"""a single entry in a traceback"""
168165

169166
_repr_style = None
170167
exprinfo = None
@@ -193,13 +190,13 @@ def __repr__(self):
193190

194191
@property
195192
def statement(self):
196-
""" _pytest._code.Source object for the current statement """
193+
"""_pytest._code.Source object for the current statement"""
197194
source = self.frame.code.fullsource
198195
return source.getstatement(self.lineno)
199196

200197
@property
201198
def path(self):
202-
""" path to the source code """
199+
"""path to the source code"""
203200
return self.frame.code.path
204201

205202
def getlocals(self):
@@ -212,7 +209,7 @@ def getfirstlinesource(self):
212209
return max(self.frame.code.firstlineno, 0)
213210

214211
def getsource(self, astcache=None):
215-
""" return failing source code. """
212+
"""return failing source code."""
216213
# we use the passed in astcache to not reparse asttrees
217214
# within exception info printing
218215
from _pytest._code.source import getstatementrange_ast
@@ -240,13 +237,13 @@ def getsource(self, astcache=None):
240237
source = property(getsource)
241238

242239
def ishidden(self):
243-
""" return True if the current frame has a var __tracebackhide__
244-
resolving to True.
240+
"""return True if the current frame has a var __tracebackhide__
241+
resolving to True.
245242
246-
If __tracebackhide__ is a callable, it gets called with the
247-
ExceptionInfo instance and can decide whether to hide the traceback.
243+
If __tracebackhide__ is a callable, it gets called with the
244+
ExceptionInfo instance and can decide whether to hide the traceback.
248245
249-
mostly for internal use
246+
mostly for internal use
250247
"""
251248
f = self.frame
252249
tbh = f.f_locals.get(
@@ -277,14 +274,14 @@ def name(self):
277274

278275

279276
class Traceback(list):
280-
""" Traceback objects encapsulate and offer higher level
281-
access to Traceback entries.
277+
"""Traceback objects encapsulate and offer higher level
278+
access to Traceback entries.
282279
"""
283280

284281
Entry = TracebackEntry
285282

286283
def __init__(self, tb, excinfo=None):
287-
""" initialize from given python traceback object and ExceptionInfo """
284+
"""initialize from given python traceback object and ExceptionInfo"""
288285
self._excinfo = excinfo
289286
if hasattr(tb, "tb_next"):
290287

@@ -298,14 +295,14 @@ def f(cur):
298295
list.__init__(self, tb)
299296

300297
def cut(self, path=None, lineno=None, firstlineno=None, excludepath=None):
301-
""" return a Traceback instance wrapping part of this Traceback
298+
"""return a Traceback instance wrapping part of this Traceback
302299
303-
by provding any combination of path, lineno and firstlineno, the
304-
first frame to start the to-be-returned traceback is determined
300+
by provding any combination of path, lineno and firstlineno, the
301+
first frame to start the to-be-returned traceback is determined
305302
306-
this allows cutting the first part of a Traceback instance e.g.
307-
for formatting reasons (removing some uninteresting bits that deal
308-
with handling of the exception/traceback)
303+
this allows cutting the first part of a Traceback instance e.g.
304+
for formatting reasons (removing some uninteresting bits that deal
305+
with handling of the exception/traceback)
309306
"""
310307
for x in self:
311308
code = x.frame.code
@@ -330,19 +327,19 @@ def __getitem__(self, key):
330327
return val
331328

332329
def filter(self, fn=lambda x: not x.ishidden()):
333-
""" return a Traceback instance with certain items removed
330+
"""return a Traceback instance with certain items removed
334331
335-
fn is a function that gets a single argument, a TracebackEntry
336-
instance, and should return True when the item should be added
337-
to the Traceback, False when not
332+
fn is a function that gets a single argument, a TracebackEntry
333+
instance, and should return True when the item should be added
334+
to the Traceback, False when not
338335
339-
by default this removes all the TracebackEntries which are hidden
340-
(see ishidden() above)
336+
by default this removes all the TracebackEntries which are hidden
337+
(see ishidden() above)
341338
"""
342339
return Traceback(filter(fn, self), self._excinfo)
343340

344341
def getcrashentry(self):
345-
""" return last non-hidden traceback entry that lead
342+
"""return last non-hidden traceback entry that lead
346343
to the exception of a traceback.
347344
"""
348345
for i in range(-1, -len(self) - 1, -1):
@@ -352,8 +349,8 @@ def getcrashentry(self):
352349
return self[-1]
353350

354351
def recursionindex(self):
355-
""" return the index of the frame/TracebackEntry where recursion
356-
originates if appropriate, None if no recursion occurred
352+
"""return the index of the frame/TracebackEntry where recursion
353+
originates if appropriate, None if no recursion occurred
357354
"""
358355
cache = {}
359356
for i, entry in enumerate(self):
@@ -387,8 +384,8 @@ def recursionindex(self):
387384

388385
@attr.s(repr=False)
389386
class ExceptionInfo(object):
390-
""" wraps sys.exc_info() objects and offers
391-
help for navigating the traceback.
387+
"""wraps sys.exc_info() objects and offers
388+
help for navigating the traceback.
392389
"""
393390

394391
_assert_start_repr = (
@@ -426,8 +423,7 @@ def from_current(cls, exprinfo=None):
426423

427424
@classmethod
428425
def for_later(cls):
429-
"""return an unfilled ExceptionInfo
430-
"""
426+
"""return an unfilled ExceptionInfo"""
431427
return cls(None)
432428

433429
@property
@@ -467,12 +463,12 @@ def __repr__(self):
467463
return "<ExceptionInfo %s tblen=%d>" % (self.typename, len(self.traceback))
468464

469465
def exconly(self, tryshort=False):
470-
""" return the exception as a string
466+
"""return the exception as a string
471467
472-
when 'tryshort' resolves to True, and the exception is a
473-
_pytest._code._AssertionError, only the actual exception part of
474-
the exception representation is returned (so 'AssertionError: ' is
475-
removed from the beginning)
468+
when 'tryshort' resolves to True, and the exception is a
469+
_pytest._code._AssertionError, only the actual exception part of
470+
the exception representation is returned (so 'AssertionError: ' is
471+
removed from the beginning)
476472
"""
477473
lines = format_exception_only(self.type, self.value)
478474
text = "".join(lines)
@@ -483,7 +479,7 @@ def exconly(self, tryshort=False):
483479
return text
484480

485481
def errisinstance(self, exc):
486-
""" return True if the exception is an instance of exc """
482+
"""return True if the exception is an instance of exc"""
487483
return isinstance(self.value, exc)
488484

489485
def _getreprcrash(self):
@@ -578,7 +574,7 @@ def match(self, regexp):
578574

579575
@attr.s
580576
class FormattedExcinfo(object):
581-
""" presenting information about failing Functions and Generators. """
577+
"""presenting information about failing Functions and Generators."""
582578

583579
# for traceback entries
584580
flow_marker = ">"
@@ -625,7 +621,7 @@ def repr_args(self, entry):
625621
return ReprFuncArgs(args)
626622

627623
def get_source(self, source, line_index=-1, excinfo=None, short=False):
628-
""" return formatted and marked up source lines. """
624+
"""return formatted and marked up source lines."""
629625
import _pytest._code
630626

631627
lines = []
@@ -1024,7 +1020,7 @@ def toterminal(self, tw):
10241020

10251021

10261022
def getrawcode(obj, trycall=True):
1027-
""" return code object for given function. """
1023+
"""return code object for given function."""
10281024
try:
10291025
return obj.__code__
10301026
except AttributeError:
@@ -1045,7 +1041,6 @@ def getrawcode(obj, trycall=True):
10451041
def is_recursion_error(excinfo):
10461042
return excinfo.errisinstance(RecursionError) # noqa
10471043

1048-
10491044
else:
10501045

10511046
def is_recursion_error(excinfo):

0 commit comments

Comments
 (0)