bloomberg/pystack

Fix type error in traceback formatter

ecalifornica opened this issue · 1 comments

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

mypy check failing due to a mismatch between signature and return type. Looks like the return value can be removed, as the only call to the function expects an iterable, matching the function signature.

Error:

python -m mypy src/pystack --strict --ignore-missing-imports
src/pystack/traceback_formatter.py:113: error: No return value expected  [return-value]
Found 1 error in 1 file (checked 11 source files)

Relevant function:

def _format_merged_stacks(
thread: PyThread, current_frame: Optional[PyFrame]
) -> Iterable[str]:
for frame in thread.native_frames:
if frame_type(frame, thread.python_version) == NativeFrame.FrameType.EVAL:
assert current_frame is not None
yield from format_frame(current_frame)
current_frame = current_frame.next
while current_frame and not current_frame.is_entry:
yield from format_frame(current_frame)
current_frame = current_frame.next
continue
elif frame_type(frame, thread.python_version) == NativeFrame.FrameType.IGNORE:
continue
elif frame_type(frame, thread.python_version) == NativeFrame.FrameType.OTHER:
function = colored(frame.symbol, "yellow")
yield (
f' {colored("(C)", "blue")} File "{frame.path}",'
f" line {frame.linenumber},"
f" in {function} ({colored(frame.library, attrs=['faint'])})"
)
else: # pragma: no cover
raise ValueError(
f"Invalid frame type: {frame_type(frame, thread.python_version)}"
)
return current_frame

Usage:

yield from _format_merged_stacks(thread, current_frame)

Expected Behavior

No CI failure.

Steps To Reproduce

  1. In development container.
  2. Run make lint

Pystack Version

1.3.0

Python Version

3.12

Linux distribution

Ubuntu

Anything else?

No response

Fixed by #175