Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving the issue #74 #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions prettyprinter/extras/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,7 @@ def pretty_dataclass_instance(value, ctx):
# to display the field value.
if not field_def.repr:
continue

display_attr = False

if (
field_def.default is MISSING and
field_def.default_factory is MISSING
):
display_attr = True
elif field_def.default is not MISSING:
if field_def.default != getattr(value, field_def.name):
display_attr = True
elif field_def.default_factory is not MISSING:
default_value = field_def.default_factory()
if default_value != getattr(value, field_def.name):
display_attr = True
else:
assert "default and default_factory should not be both defined"

if display_attr:
kwargs.append((field_def.name, getattr(value, field_def.name)))
kwargs.append((field_def.name, getattr(value, field_def.name)))

return pretty_call(ctx, cls, **OrderedDict(kwargs))

Expand Down