Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
  • Loading branch information
hugovk and AA-Turner authored Aug 7, 2024
commit 07cffca9a441c6f696e2133dd5139ea7b4d5e26e
6 changes: 3 additions & 3 deletions Lib/pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def _format(self, object, stream, indent, allowance, context, level):
if len(rep) > max_width:
p = self._dispatch.get(type(object).__repr__, None)
# Lazy import to improve module import time
import dataclasses as _dataclasses
from dataclasses import is_dataclass

if p is not None:
context[objid] = 1
Expand All @@ -207,11 +207,11 @@ def _format(self, object, stream, indent, allowance, context, level):

def _pprint_dataclass(self, object, stream, indent, allowance, context, level):
# Lazy import to improve module import time
import dataclasses as _dataclasses
from dataclasses import fields as dataclass_fields

cls_name = object.__class__.__name__
indent += len(cls_name) + 1
items = [(f.name, getattr(object, f.name)) for f in _dataclasses.fields(object) if f.repr]
items = [(f.name, getattr(object, f.name)) for f in dataclass_fields(object) if f.repr]
stream.write(cls_name + '(')
self._format_namespace_items(items, stream, indent, allowance, context, level)
stream.write(')')
Expand Down