Skip to content

Commit efc37e6

Browse files
author
rocky
committed
blacken
1 parent a35ec71 commit efc37e6

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

trepan/lib/stack.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,22 @@ def getsourcefile(filename):
5959
all_bytecode_suffixes = (".pyc", ".pyo")
6060
if any(filename.endswith(s) for s in all_bytecode_suffixes):
6161
if osp.dirname(filename).endswith("__pycache__"):
62-
filename = osp.join(osp.dirname(osp.dirname(filename)), osp.basename(filename))
63-
filename = (osp.splitext(filename)[0] + ".py")
64-
elif any(filename.endswith(s) for s in
65-
[".abi3.so", ".so"]):
62+
filename = osp.join(
63+
osp.dirname(osp.dirname(filename)), osp.basename(filename)
64+
)
65+
filename = osp.splitext(filename)[0] + ".py"
66+
elif any(filename.endswith(s) for s in [".abi3.so", ".so"]):
6667
return None
6768
if osp.exists(filename):
6869
return filename
6970
# only return a non-existent filename if the module has a PEP 302 loader
70-
if getattr(inspect.getmodule(object, filename), '__loader__', None) is not None:
71+
if getattr(inspect.getmodule(object, filename), "__loader__", None) is not None:
7172
return filename
7273
# or it is in the linecache
7374
if filename in linecache.cache:
7475
return filename
7576

77+
7678
def deparse_source_from_code(code):
7779
source_text = ""
7880
try:
@@ -107,7 +109,11 @@ def format_stack_entry(
107109
s = format_token(Mformat.Function, funcname, highlight=color)
108110

109111
args, varargs, varkw, local_vars = inspect.getargvalues(frame)
110-
if "<module>" == funcname and ([], None, None,) == (args, varargs, varkw,):
112+
if "<module>" == funcname and ([], None, None,) == (
113+
args,
114+
varargs,
115+
varkw,
116+
):
111117
is_module = True
112118
if is_exec_stmt(frame):
113119
fn_name = format_token(Mformat.Function, "exec", highlight=color)
@@ -131,7 +137,7 @@ def format_stack_entry(
131137
try:
132138
parms = inspect.formatargvalues(args, varargs, varkw, local_vars)
133139
except:
134-
pass
140+
pass
135141
else:
136142
maxargstrsize = dbg_obj.settings["maxargstrsize"]
137143
if len(parms) >= maxargstrsize:
@@ -224,8 +230,8 @@ def check_path_with_frame(frame, path):
224230
return False, "bytecode and local files mismatch"
225231
if fs_size and fs_size != my_size:
226232
return False, (
227-
"frame file size, %d bytes, and local file size, %d bytes, on file %s mismatch" %
228-
(fs_size, my_size, path)
233+
"frame file size, %d bytes, and local file size, %d bytes, on file %s mismatch"
234+
% (fs_size, my_size, path)
229235
)
230236
return True, None
231237

@@ -429,8 +435,9 @@ def __init__(self):
429435

430436
frame = inspect.currentframe()
431437
print(frame2filesize(frame))
432-
pyc_file = osp.join(osp.dirname(__file__),
433-
"__pycache__", osp.basename(__file__)[:-3] + ".pyc")
438+
pyc_file = osp.join(
439+
osp.dirname(__file__), "__pycache__", osp.basename(__file__)[:-3] + ".pyc"
440+
)
434441
print(pyc_file, getsourcefile(pyc_file))
435442

436443
# m = MockDebugger()

0 commit comments

Comments
 (0)