Skip to content

Debug output and watches don't use custom repr()/str() for long strings? #838

@ldorigo

Description

@ldorigo

Issue Type: Bug

Hi, consider this small snippet:

from typing import NamedTuple


class Test(NamedTuple):
    a: str
    b: str
    c: str

    def __str__(self):
        return f"{self.a} {self.b} {self.c}"

    def __repr__(self) -> str:
        return str(self)

test_works = Test("a","b","c")
test_doesntwork = Test("a", "b", "potato" * 15)
print(test)

If I add test_works to watches or evaluate it in the debug console, it correctly uses the repr() I provide. However after some arbitrary string length, it reverts to showing <Test, len() = 3> - which I don't want. I tried looking for a setting to change the value at which this change happens but couldn't find any. This is quite annoying when debugging as I need to continuously focus the output window and type print(test_doesntwork) to be able to see what's in it.

Extension version: 2022.0.1786462952
VS Code version: Code 1.64.0 (5554b12acf27056905806867f251c859323ff7e9, 2022-02-03T04:23:11.224Z)
OS version: Linux x64 5.15.19-1-lts
Restricted Mode: No

System Info
Item Value
CPUs AMD Ryzen 7 3700X 8-Core Processor (16 x 3600)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 0, 1, 1
Memory (System) 31.36GB (3.09GB free)
Process Argv --crash-reporter-id 66ea3ec9-05eb-4edd-8d35-34bbe6c1aba1
Screen Reader no
VM 0%
DESKTOP_SESSION plasma-i3
XDG_CURRENT_DESKTOP KDE
XDG_SESSION_DESKTOP KDE-i3
XDG_SESSION_TYPE x11

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions