Skip to content

Commit f663828

Browse files
authored
stubtest: better formatting for runtime objects (#13023)
Co-authored-by: hauntsaninja <>
1 parent 203bd64 commit f663828

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mypy/stubtest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ def _style(message: str, **kwargs: Any) -> str:
5555
return _formatter.style(message, **kwargs)
5656

5757

58+
def _truncate(message: str, length: int) -> str:
59+
if len(message) > length:
60+
return message[:length - 3] + "..."
61+
return message
62+
63+
5864
class StubtestFailure(Exception):
5965
pass
6066

@@ -86,7 +92,7 @@ def __init__(
8692
self.stub_object = stub_object
8793
self.runtime_object = runtime_object
8894
self.stub_desc = stub_desc or str(getattr(stub_object, "type", stub_object))
89-
self.runtime_desc = runtime_desc or str(runtime_object)
95+
self.runtime_desc = runtime_desc or _truncate(repr(runtime_object), 100)
9096

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

0 commit comments

Comments
 (0)