(
self,
object: Any,
stream: IO[str],
indent: int,
allowance: int,
context: set[int],
level: int,
)
| 92 | return sio.getvalue() |
| 93 | |
| 94 | def _format( |
| 95 | self, |
| 96 | object: Any, |
| 97 | stream: IO[str], |
| 98 | indent: int, |
| 99 | allowance: int, |
| 100 | context: set[int], |
| 101 | level: int, |
| 102 | ) -> None: |
| 103 | objid = id(object) |
| 104 | if objid in context: |
| 105 | stream.write(_recursion(object)) |
| 106 | return |
| 107 | |
| 108 | p = self._dispatch.get(type(object).__repr__, None) |
| 109 | if p is not None: |
| 110 | context.add(objid) |
| 111 | p(self, object, stream, indent, allowance, context, level + 1) |
| 112 | context.remove(objid) |
| 113 | elif ( |
| 114 | _dataclasses.is_dataclass(object) |
| 115 | and not isinstance(object, type) |
| 116 | and object.__dataclass_params__.repr class="cm"># type:ignore[attr-defined] |
| 117 | and |
| 118 | class="cm"># Check dataclass has generated repr method. |
| 119 | hasattr(object.__repr__, class="st">"__wrapped__") |
| 120 | and class="st">"__create_fn__" in object.__repr__.__wrapped__.__qualname__ |
| 121 | ): |
| 122 | context.add(objid) |
| 123 | self._pprint_dataclass( |
| 124 | object, stream, indent, allowance, context, level + 1 |
| 125 | ) |
| 126 | context.remove(objid) |
| 127 | else: |
| 128 | stream.write(self._repr(object, context, level)) |
| 129 | |
| 130 | def _pprint_dataclass( |
| 131 | self, |
no test coverage detected