First time here? Check out the FAQ!
1

Wing doesn't print repr of dataclasses in some cases

I've noticed that Wing doesn't print a full repr of some dataclasses in the debug console. For example, a dataclass containing a builtin datetime as one of its fields prints it in its repr, while one using a pendulum.DateTime does not. Is this deliberate? Is there a way to make Wing print all contents, similar to how it would print a namedtuple?

For example:

from dataclasses import dataclass
import datetime
import pendulum
import typing as tp

@dataclass
class A:
    f: tp.Any = None


# Wing shows this as  `A(f=datetime.date(2025, 1, 1))` in the debug console:
A(f=datetime.date(2025, 1, 1))

# Wing shows this as `A()` in the debug console:
A(f=pendulum.Date(2025, 1, 1))
Tmr's avatar
45
Tmr
asked 2025-05-08 15:59:15 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

With Python 3.12, the repr() of A(f=pendulum.Date(2025, 1, 1)) is A(f=Date(2025, 1, 1)) -- this is what print(repr(A(f=pendulum.Date(2025, 1, 1))) shows and what the Debug Console displays. Note that the Debug Console simply calls repr() on the value that the input line evaluates to if the pretty print option is off; if the pretty print option is on, the pprint stdlib module is used.

answered 2025-05-08 20:29:22 -0500
This post is a wiki. Anyone with karma >75 is welcome to improve it.
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer