(self, object, stream, indent, allowance, context, level)
| 169 | return readable and not recursive |
| 170 | |
| 171 | def _format(self, object, stream, indent, allowance, context, level): |
| 172 | objid = id(object) |
| 173 | if objid in context: |
| 174 | stream.write(_recursion(object)) |
| 175 | self._recursive = True |
| 176 | self._readable = False |
| 177 | return |
| 178 | rep = self._repr(object, context, level) |
| 179 | max_width = self._width - indent - allowance |
| 180 | if len(rep) > max_width: |
| 181 | p = self._dispatch.get(type(object).__repr__, None) |
| 182 | if p is not None: |
| 183 | context[objid] = 1 |
| 184 | p(self, object, stream, indent, allowance, context, level + 1) |
| 185 | del context[objid] |
| 186 | return |
| 187 | elif (_dataclasses.is_dataclass(object) and |
| 188 | not isinstance(object, type) and |
| 189 | object.__dataclass_params__.repr and |
| 190 | # Check dataclass has generated repr method. |
| 191 | hasattr(object.__repr__, "__wrapped__") and |
| 192 | "__create_fn__" in object.__repr__.__wrapped__.__qualname__): |
| 193 | context[objid] = 1 |
| 194 | self._pprint_dataclass(object, stream, indent, allowance, context, level + 1) |
| 195 | del context[objid] |
| 196 | return |
| 197 | stream.write(rep) |
| 198 | |
| 199 | def _pprint_dataclass(self, object, stream, indent, allowance, context, level): |
| 200 | cls_name = object.__class__.__name__ |
no test coverage detected