|
39 | 39 | import types as _types |
40 | 40 | from io import StringIO as _StringIO |
41 | 41 |
|
42 | | -lazy from dataclasses import is_dataclass |
43 | | -lazy from dataclasses import fields as dataclass_fields |
44 | | -lazy import re |
| 42 | +lazy from dataclasses import is_dataclass as _is_dataclass |
| 43 | +lazy from dataclasses import fields as _dataclass_fields |
| 44 | +lazy import re as _re |
45 | 45 |
|
46 | 46 | __all__ = ["pprint","pformat","isreadable","isrecursive","saferepr", |
47 | 47 | "PrettyPrinter", "pp"] |
@@ -208,7 +208,7 @@ def _format(self, object, stream, indent, allowance, context, level): |
208 | 208 | p(self, object, stream, indent, allowance, context, level + 1) |
209 | 209 | del context[objid] |
210 | 210 | return |
211 | | - elif (is_dataclass(object) and |
| 211 | + elif (_is_dataclass(object) and |
212 | 212 | not isinstance(object, type) and |
213 | 213 | object.__dataclass_params__.repr and |
214 | 214 | # Check dataclass has generated repr method. |
@@ -248,7 +248,7 @@ def _pprint_dataclass(self, object, stream, indent, allowance, context, level): |
248 | 248 | indent += self._indent_per_level |
249 | 249 | else: |
250 | 250 | indent += len(cls_name) + 1 |
251 | | - items = [(f.name, getattr(object, f.name)) for f in dataclass_fields(object) if f.repr] |
| 251 | + items = [(f.name, getattr(object, f.name)) for f in _dataclass_fields(object) if f.repr] |
252 | 252 | stream.write(self._format_block_start(cls_name + '(', indent)) |
253 | 253 | self._format_namespace_items(items, stream, indent, allowance, context, level) |
254 | 254 | stream.write(self._format_block_end(')', indent - self._indent_per_level)) |
@@ -423,7 +423,7 @@ def _pprint_str(self, object, stream, indent, allowance, context, level): |
423 | 423 | chunks.append(rep) |
424 | 424 | else: |
425 | 425 | # A list of alternating (non-space, space) strings |
426 | | - parts = re.findall(r'\S*\s*', line) |
| 426 | + parts = _re.findall(r'\S*\s*', line) |
427 | 427 | assert parts |
428 | 428 | assert not parts[-1] |
429 | 429 | parts.pop() # drop empty last part |
|
0 commit comments