Completed
Pull Request — master (#211)
by Björn
18:50 queued 17:33
created

format_exc_skip()   A

Complexity

Conditions 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
1
"""Shared utility functions."""
2
3 6
import sys
4 6
from traceback import format_exception
5
6
7 6
def format_exc_skip(skip, limit=None):
8
    """Like traceback.format_exc but allow skipping the first frames."""
9 6
    type, val, tb = sys.exc_info()
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in type.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
10 6
    for i in range(skip):
0 ignored issues
show
Unused Code introduced by
The variable i seems to be unused.
Loading history...
11 6
        tb = tb.tb_next
12
    return ('\n'.join(format_exception(type, val, tb, limit))).rstrip()
13