TST: ExtensionArrays disallow .values attribute 
State: closed

xref https://github.com/pandas-dev/pandas/issues/20735. 
Adds a test to ensure EA authors don't use the `.values` or `._values` attribute, which can give problems with pandas internals depending on how the data is stored.




Labels:
name: ExtensionArray
description: Extending pandas with custom dtypes or arrays.

Comments:
This is a temporary "fix" to the interface. 
Long term solution would be to make sure we don't make such assumptions internally, but that would need to fix all places where we currently check for a `_values` or `values` attribute, which is much more work (as often it is actually a way to have code be generic for eg both Series and EA/ndarray, as `_values` on the Series then returns the underlying EA/ndarray).
Ah, see you just did the same https://github.com/pandas-dev/pandas/pull/20793 :-)
Do you want to copy-paste my test here? https://github.com/pandas-dev/pandas/pull/20793/files#diff-fac89eff36e78c735bd1046e704780c9

I prefer your check. I was duck-typing on `.values` without a `.dtype`, but just checking for `.values` more generically like you do is best.
> Do you want to copy-paste my test here? https://github.com/pandas-dev/pandas/pull/20793/files#diff-fac89eff36e78c735bd1046e704780c9

which test do you mean?


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

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

```diff
@@            Coverage Diff             @@
##           master   #20794      +/-   ##
==========================================
- Coverage   91.85%   91.82%   -0.03%     
==========================================
  Files         153      153              
  Lines       49308    49310       +2     
==========================================
- Hits        45290    45280      -10     
- Misses       4018     4030      +12
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.21% <ø> (-0.03%)` | :arrow_down: |
| #single | `41.89% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/20794?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/20794/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `84.14% <ø> (ø)` | :arrow_up: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/20794/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `65.07% <0%> (-1.74%)` | :arrow_down: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/20794/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.68% <0%> (ø)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/20794/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.17% <0%> (ø)` | :arrow_up: |
| [pandas/core/accessor.py](https://codecov.io/gh/pandas-dev/pandas/pull/20794/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYWNjZXNzb3IucHk=) | `98.71% <0%> (+0.01%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20794?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/20794?src=pr&el=footer). Last update [0ae7e90...a57f8e0](https://codecov.io/gh/pandas-dev/pandas/pull/20794?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

thanks!