Objects in pretty traceback printing which are dataclass objects with fields that are specified with init=False will cause an uncaught exception in the printing. See below.
from dataclasses import dataclass, field, fields
@dataclass(eq=False)
class BadDataclass:
item: int = field(init=False)
# item is not provided
ob = BadDataclass()
# Displays all fields, including item
print([f for f in fields(ob) if f.repr])
# Raises an AttributeError since ob.item is not defined
print([getattr(ob, f.name) for f in fields(ob)])
Describe the bug
Objects in pretty traceback printing which are
dataclass
objects with fields that are specified withinit=False
will cause an uncaught exception in the printing. See below.This is specifically caused by this line of code.
PR Submitted