Skip to content

Commit

Permalink
stubtest: better formatting for runtime objects (#13023)
Browse files Browse the repository at this point in the history
Co-authored-by: hauntsaninja <>
  • Loading branch information
hauntsaninja authored Jun 26, 2022
1 parent 203bd64 commit f663828
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def _style(message: str, **kwargs: Any) -> str:
return _formatter.style(message, **kwargs)


def _truncate(message: str, length: int) -> str:
if len(message) > length:
return message[:length - 3] + "..."
return message


class StubtestFailure(Exception):
pass

Expand Down Expand Up @@ -86,7 +92,7 @@ def __init__(
self.stub_object = stub_object
self.runtime_object = runtime_object
self.stub_desc = stub_desc or str(getattr(stub_object, "type", stub_object))
self.runtime_desc = runtime_desc or str(runtime_object)
self.runtime_desc = runtime_desc or _truncate(repr(runtime_object), 100)

def is_missing_stub(self) -> bool:
"""Whether or not the error is for something missing from the stub."""
Expand Down

0 comments on commit f663828

Please sign in to comment.