Skip to content

Commit

Permalink
Expose is_valid as dedicated private method
Browse files Browse the repository at this point in the history
  • Loading branch information
jonashaag authored Jan 1, 2025
1 parent 951c2fa commit 98e33a9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions loguru/_better_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ def _is_file_mine(self, file):
return False
return not any(filepath.startswith(d) for d in self._lib_dirs)

def _should_include_frame(self, frame):
return frame.f_code.co_filename != self._hidden_frames_filename

def _extract_frames(self, tb, is_first, *, limit=None, from_decorator=False):
frames, final_source = [], None

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

def is_valid(frame):
return frame.f_code.co_filename != self._hidden_frames_filename

def get_info(frame, lineno):
filename = frame.f_code.co_filename
function = frame.f_code.co_name
Expand All @@ -213,15 +213,15 @@ def get_info(frame, lineno):

infos = []

if is_valid(tb.tb_frame):
if self._should_include_frame(tb.tb_frame):
infos.append((get_info(tb.tb_frame, tb.tb_lineno), tb.tb_frame))

get_parent_only = from_decorator and not self._backtrace

if (self._backtrace and is_first) or get_parent_only:
frame = tb.tb_frame.f_back
while frame:
if is_valid(frame):
if self._should_include_frame(frame):
infos.insert(0, (get_info(frame, frame.f_lineno), frame))
if get_parent_only:
break
Expand All @@ -235,7 +235,7 @@ def get_info(frame, lineno):
tb = tb.tb_next

while tb:
if is_valid(tb.tb_frame):
if self._should_include_frame(tb.tb_frame):
infos.append((get_info(tb.tb_frame, tb.tb_lineno), tb.tb_frame))
tb = tb.tb_next

Expand Down

0 comments on commit 98e33a9

Please sign in to comment.