String representation.
(self)
| 2351 | return result |
| 2352 | |
| 2353 | def __repr__(self) -> str: |
| 2354 | """ |
| 2355 | String representation. |
| 2356 | """ |
| 2357 | footer = self._get_repr_footer() |
| 2358 | length = len(self) |
| 2359 | max_len = 10 |
| 2360 | if length > max_len: |
| 2361 | # In long cases we do not display all entries, so we add Length |
| 2362 | # information to the __repr__. |
| 2363 | num = max_len // 2 |
| 2364 | head = self[:num]._get_values_repr() |
| 2365 | tail = self[-(max_len - num) :]._get_values_repr() |
| 2366 | body = f"{head[:-1]}, ..., {tail[1:]}" |
| 2367 | length_info = f"Length: {len(self)}" |
| 2368 | result = f"{body}\n{length_info}\n{footer}" |
| 2369 | elif length > 0: |
| 2370 | body = self._get_values_repr() |
| 2371 | result = f"{body}\n{footer}" |
| 2372 | else: |
| 2373 | # In the empty case we use a comma instead of newline to get |
| 2374 | # a more compact __repr__ |
| 2375 | body = "[]" |
| 2376 | result = f"{body}, {footer}" |
| 2377 | |
| 2378 | return result |
| 2379 | |
| 2380 | # ------------------------------------------------------------------ |
| 2381 |
nothing calls this directly
no test coverage detected