Skip to content

Commit c490ce0

Browse files
authored
Expose is_valid as dedicated private method (#1270)
1 parent 8bba363 commit c490ce0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

loguru/_better_exceptions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ def _is_file_mine(self, file):
196196
return False
197197
return not any(filepath.startswith(d) for d in self._lib_dirs)
198198

199+
def _should_include_frame(self, frame):
200+
return frame.f_code.co_filename != self._hidden_frames_filename
201+
199202
def _extract_frames(self, tb, is_first, *, limit=None, from_decorator=False):
200203
frames, final_source = [], None
201204

202205
if tb is None or (limit is not None and limit <= 0):
203206
return frames, final_source
204207

205-
def is_valid(frame):
206-
return frame.f_code.co_filename != self._hidden_frames_filename
207-
208208
def get_info(frame, lineno):
209209
filename = frame.f_code.co_filename
210210
function = frame.f_code.co_name
@@ -213,15 +213,15 @@ def get_info(frame, lineno):
213213

214214
infos = []
215215

216-
if is_valid(tb.tb_frame):
216+
if self._should_include_frame(tb.tb_frame):
217217
infos.append((get_info(tb.tb_frame, tb.tb_lineno), tb.tb_frame))
218218

219219
get_parent_only = from_decorator and not self._backtrace
220220

221221
if (self._backtrace and is_first) or get_parent_only:
222222
frame = tb.tb_frame.f_back
223223
while frame:
224-
if is_valid(frame):
224+
if self._should_include_frame(frame):
225225
infos.insert(0, (get_info(frame, frame.f_lineno), frame))
226226
if get_parent_only:
227227
break
@@ -235,7 +235,7 @@ def get_info(frame, lineno):
235235
tb = tb.tb_next
236236

237237
while tb:
238-
if is_valid(tb.tb_frame):
238+
if self._should_include_frame(tb.tb_frame):
239239
infos.append((get_info(tb.tb_frame, tb.tb_lineno), tb.tb_frame))
240240
tb = tb.tb_next
241241

0 commit comments

Comments
 (0)