REF: remove special-casing for internal EAs from format_array
State: closed

- [ ] closes #26837
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [n/a ] whatsnew entry

cc @jorisvandenbossche 

changes to tests for spacing before Datetime64TZ, which now have additional space.

Labels:
name: Output-Formatting
description: __repr__ of pandas objects, to_string
name: ExtensionArray
description: Extending pandas with custom dtypes or arrays.

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=h1) Report
> Merging [#26965](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/cfd65e98e694b2ad40e97d06ffdd9096a3dea909?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `94.28%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26965/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26965      +/-   ##
==========================================
- Coverage   91.87%   91.86%   -0.01%     
==========================================
  Files         180      180              
  Lines       50746    50743       -3     
==========================================
- Hits        46623    46616       -7     
- Misses       4123     4127       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.46% <94.28%> (-0.01%)` | :arrow_down: |
| #single | `41.12% <62.85%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `100% <100%> (+0.56%)` | :arrow_up: |
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `98% <100%> (+0.09%)` | :arrow_up: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `88.82% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9pbnRlcnZhbC5weQ==) | `96.44% <100%> (ø)` | :arrow_up: |
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.81% <100%> (-0.12%)` | :arrow_down: |
| [pandas/core/arrays/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lbGlrZS5weQ==) | `97.6% <66.66%> (-0.33%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `88.88% <0%> (-11.12%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.89% <0%> (-0.12%)` | :arrow_down: |
| [pandas/io/formats/printing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvcHJpbnRpbmcucHk=) | `87.2% <0%> (+0.47%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=footer). Last update [cfd65e9...5d023cc](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=h1) Report
> Merging [#26965](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/cfd65e98e694b2ad40e97d06ffdd9096a3dea909?src=pr&el=desc) will **decrease** coverage by `1.41%`.
> The diff coverage is `94.28%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26965/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26965      +/-   ##
==========================================
- Coverage   91.87%   90.46%   -1.42%     
==========================================
  Files         180      180              
  Lines       50746    50741       -5     
==========================================
- Hits        46623    45902     -721     
- Misses       4123     4839     +716
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.46% <94.28%> (-0.01%)` | :arrow_down: |
| #single | `?` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `94.37% <ø> (-0.01%)` | :arrow_down: |
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `100% <100%> (+0.56%)` | :arrow_up: |
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `98% <100%> (+0.09%)` | :arrow_up: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `88.82% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9pbnRlcnZhbC5weQ==) | `96.44% <100%> (ø)` | :arrow_up: |
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.68% <100%> (-0.25%)` | :arrow_down: |
| [pandas/core/arrays/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lbGlrZS5weQ==) | `97.6% <66.66%> (-0.33%)` | :arrow_down: |
| [pandas/core/computation/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vcHl0YWJsZXMucHk=) | `62.5% <0%> (-27.75%)` | :arrow_down: |
| [pandas/io/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3B5dGFibGVzLnB5) | `63.82% <0%> (-26.48%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `88.88% <0%> (-11.12%)` | :arrow_down: |
| ... and [8 more](https://codecov.io/gh/pandas-dev/pandas/pull/26965/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=footer). Last update [cfd65e9...1ef1969](https://codecov.io/gh/pandas-dev/pandas/pull/26965?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

> the formatting is now recursive. so multiple formatters can be applied.

Sorry, that is still too cryptic for me. Can you try to explain what is going on? 
> the formatting is now recursive. so multiple formatters can be applied.

So this is specific for Categorical ? Where the actual values (whether they be string, datetime, etc) can still format themselves? 
And before, this was handled with some special casing in `formats.py` itself I suppose? 
> Some quick comments (didn't look in detail yet). This can certainly be a nice clean-up, but I don't think it closes the discussion in #26837

if the special-casing is removed we can close that issue. New issues can be raised for the other points being raised during that discussion.
I personally think we need a better reason to un-deprecate `EA._formatting_values`. There needs to be a clear, recommended interface for EAs, now we are adding something back just for Categorical (and maybe Sparse?). That moves the special case from our formatting code to the EA interface, not sure that is a net improvement. 
these are internal EAs. EA authors may need similar nesting functionality.

Internal EAs should not be special cased and use an interface available to all.
@jorisvandenbossche do you want to move the discussion back to the issue? This PR is a proof of concept and will obviously require further discussion and agreement before _formatting_values is undeprecated.
@simonjayhawkins can you rebase
@jbrockmendel I don't think is ready for getting merged, see above discussion.
closing for now