(self, object, stream, indent, allowance, context, level)
| 187 | return readable and not recursive |
| 188 | |
| 189 | def _format(self, object, stream, indent, allowance, context, level): |
| 190 | objid = id(object) |
| 191 | if objid in context: |
| 192 | stream.write(_recursion(object)) |
| 193 | self._recursive = True |
| 194 | self._readable = False |
| 195 | return |
| 196 | rep = self._repr(object, context, level) |
| 197 | max_width = self._width - indent - allowance |
| 198 | if len(rep) > max_width: |
| 199 | p = self._dispatch.get(type(object).__repr__, None) |
| 200 | # Lazy import to improve module import time |
| 201 | from dataclasses import is_dataclass |
| 202 | |
| 203 | if p is not None: |
| 204 | context[objid] = 1 |
| 205 | p(self, object, stream, indent, allowance, context, level + 1) |
| 206 | del context[objid] |
| 207 | return |
| 208 | elif (is_dataclass(object) and |
| 209 | not isinstance(object, type) and |
| 210 | object.__dataclass_params__.repr and |
| 211 | # Check dataclass has generated repr method. |
| 212 | hasattr(object.__repr__, "__wrapped__") and |
| 213 | "__create_fn__" in object.__repr__.__wrapped__.__qualname__): |
| 214 | context[objid] = 1 |
| 215 | self._pprint_dataclass(object, stream, indent, allowance, context, level + 1) |
| 216 | del context[objid] |
| 217 | return |
| 218 | stream.write(rep) |
| 219 | |
| 220 | def _format_block_start(self, start_str, indent): |
| 221 | if self._expand: |
no test coverage detected