Completed
Pull Request — master (#211)
by Björn
25:41
created

format_exc_skip()   A

Complexity

Conditions 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
1
"""Shared utility functions."""
2
3
import sys
4
from traceback import format_exception
5
6
7
def format_exc_skip(skip, limit=None):
8
    """Like traceback.format_exc but allow skipping the first frames."""
9
    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
    for i in range(skip):
0 ignored issues
show
Unused Code introduced by
The variable i seems to be unused.
Loading history...
11
        tb = tb.tb_next
12
    return '\n'.join(format_exception(type, val, tb, limit))
13