|
11 | 11 | Iterable,
|
12 | 12 | Mapping,
|
13 | 13 | Sequence,
|
14 |
| - Sized, |
15 | 14 | TypeVar,
|
16 | 15 | Union,
|
17 | 16 | )
|
@@ -505,44 +504,6 @@ def _justify(
|
505 | 504 | return head, tail # type: ignore[return-value]
|
506 | 505 |
|
507 | 506 |
|
508 |
| -def format_object_attrs( |
509 |
| - obj: Sized, include_dtype: bool = True |
510 |
| -) -> list[tuple[str, str | int]]: |
511 |
| - """ |
512 |
| - Return a list of tuples of the (attr, formatted_value) |
513 |
| - for common attrs, including dtype, name, length |
514 |
| -
|
515 |
| - Parameters |
516 |
| - ---------- |
517 |
| - obj : object |
518 |
| - Must be sized. |
519 |
| - include_dtype : bool |
520 |
| - If False, dtype won't be in the returned list |
521 |
| -
|
522 |
| - Returns |
523 |
| - ------- |
524 |
| - list of 2-tuple |
525 |
| -
|
526 |
| - """ |
527 |
| - attrs: list[tuple[str, str | int]] = [] |
528 |
| - if hasattr(obj, "dtype") and include_dtype: |
529 |
| - # error: "Sized" has no attribute "dtype" |
530 |
| - attrs.append(("dtype", f"'{obj.dtype}'")) # type: ignore[attr-defined] |
531 |
| - if getattr(obj, "name", None) is not None: |
532 |
| - # error: "Sized" has no attribute "name" |
533 |
| - attrs.append(("name", default_pprint(obj.name))) # type: ignore[attr-defined] |
534 |
| - # error: "Sized" has no attribute "names" |
535 |
| - elif getattr(obj, "names", None) is not None and any( |
536 |
| - obj.names # type: ignore[attr-defined] |
537 |
| - ): |
538 |
| - # error: "Sized" has no attribute "names" |
539 |
| - attrs.append(("names", default_pprint(obj.names))) # type: ignore[attr-defined] |
540 |
| - max_seq_items = get_option("display.max_seq_items") or len(obj) |
541 |
| - if len(obj) > max_seq_items: |
542 |
| - attrs.append(("length", len(obj))) |
543 |
| - return attrs |
544 |
| - |
545 |
| - |
546 | 507 | class PrettyDict(Dict[_KT, _VT]):
|
547 | 508 | """Dict extension to support abbreviated __repr__"""
|
548 | 509 |
|
|
0 commit comments