COMPAT: Catch warnings on tab-complete in IPy 6
State: closed

Properties may run code with Jedi completion in IPython 6

Closes https://github.com/pandas-dev/pandas/issues/16409

I want to leave this open for a couple days to see if I can find other places that trigger this warning. I'm pretty sure I've seen other instances, but they may have been from other libraries.

Labels:

Comments:
I think it was on Resampler. I'll just push additional fixes here.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16414?src=pr&el=h1) Report
> Merging [#16414](https://codecov.io/gh/pandas-dev/pandas/pull/16414?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d5a681bfa2de24b4a1449956c84393a413909738?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `50%`.

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

```diff
@@            Coverage Diff             @@
##           master   #16414      +/-   ##
==========================================
+ Coverage   90.42%   90.42%   +<.01%     
==========================================
  Files         161      161              
  Lines       51023    51025       +2     
==========================================
+ Hits        46137    46139       +2     
  Misses       4886     4886
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.26% <50%> (ø)` | :arrow_up: |
| #single | `40.17% <50%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16414?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/16414?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `95.78% <50%> (-0.14%)` | :arrow_down: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16414?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `91.39% <0%> (+0.33%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16414?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/16414?src=pr&el=footer). Last update [d5a681b...da2d290](https://codecov.io/gh/pandas-dev/pandas/pull/16414?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/16414?src=pr&el=h1) Report
> Merging [#16414](https://codecov.io/gh/pandas-dev/pandas/pull/16414?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/e41fe7f52a7ae6be962e683f40500624b2ba2cf6?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `70%`.

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

```diff
@@            Coverage Diff             @@
##           master   #16414      +/-   ##
==========================================
- Coverage   90.43%   90.42%   -0.01%     
==========================================
  Files         161      161              
  Lines       51045    51055      +10     
==========================================
+ Hits        46161    46168       +7     
- Misses       4884     4887       +3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.26% <70%> (-0.01%)` | :arrow_down: |
| #single | `40.16% <20%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16414?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/resample.py](https://codecov.io/gh/pandas-dev/pandas/pull/16414?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzYW1wbGUucHk=) | `96.09% <100%> (+0.01%)` | :arrow_up: |
| [pandas/conftest.py](https://codecov.io/gh/pandas-dev/pandas/pull/16414?src=pr&el=tree#diff-cGFuZGFzL2NvbmZ0ZXN0LnB5) | `96.42% <100%> (+0.59%)` | :arrow_up: |
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/16414?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `95.5% <25%> (-0.42%)` | :arrow_down: |

------

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

Catching all of the warnings from `Resampler` is turning out to be difficult. I've added an `xfail`, but might just remove it since this should be fixed by IPython 6.0.1 anyway.

And I don't think there's any way to catch the warnings from `pd.lib.<tab>` (extra incentive to avoid the deprecation I guess?)
Latest commit fixes this for Categorical and Resampler.

@jreback do the changes to `Resampler.__getitem__` look sensible to you? The issue was `jedi` checking for attributes like `__objclass__` in a try/except block. Now we skip the warning if we're going to just raise an AttributeError anyway (I had to modify one test to not expect a warning anymore).

My change could be incorrect if `Resampler.obj.mean()` has an attribute `Resampler.obj` doesn't, but I don't think that should ever happen.
FYI, I think for 0.21.0 going to remove the back-compat for .resample anyhow (IOW, all of that hacking to make it look like the previous API), but this is good.
> IOW, all of that hacking to make it look like the previous API

I didn't appreciate how awesome of a hack it was until now :)