BUG: .isin on datetimelike indexes do not validate input of level parameter
State: closed

#LondonPythonSprints

- [x] closes #26675
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Datetime
description: Datetime data dtype
name: Index
description: Related to the Index class or subclasses

Comments:
To exclude IntegerIndex and NumericIndex classes. But ci failed. so may
need  rethink. the idea was to create a fixture that checks all registered
indexes for API checking. May just have to list them explicitly for now

On Wed, 5 Jun 2019, 22:41 William Ayd, <notifications@github.com> wrote:

> *@WillAyd* commented on this pull request.
> ------------------------------
>
> In pandas/tests/indexes/conftest.py
> <https://github.com/pandas-dev/pandas/pull/26677#discussion_r290946446>:
>
> > @@ -47,3 +47,37 @@ def zero(request):
>      # For testing division by (or of) zero for Index with length 5, this
>      # gives several scalar-zeros and length-5 vector-zeros
>      return request.param
> +
> +
> +def _get_subclasses(cls):
> +    for subclass in cls.__subclasses__():
> +        yield from _get_subclasses(subclass)
> +        yield subclass
> +
> +
> +all_indexes = [index for index in ([Index] + list(set(_get_subclasses(Index))))
> +               if getattr(pd, index.__name__, None) is not None]
>
> What is the name check for?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/26677?email_source=notifications&email_token=ADEMUXMUFATJ3BCOVTBNL6DPZAXI7A5CNFSM4HUE47D2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOB2W5INA#pullrequestreview-246273076>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ADEMUXMV4FAGWFTTC36THYDPZAXI7ANCNFSM4HUE47DQ>
> .
>

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

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

```diff
@@             Coverage Diff             @@
##           master   #26677       +/-   ##
===========================================
- Coverage   91.88%   41.78%   -50.11%     
===========================================
  Files         174      174               
  Lines       50694    50665       -29     
===========================================
- Hits        46581    21169    -25412     
- Misses       4113    29496    +25383
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `?` | |
| #single | `41.78% <50%> (-0.21%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26677?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `56.61% <50%> (-41.53%)` | :arrow_down: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/sas/sas\_constants.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfY29uc3RhbnRzLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/core/groupby/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9jYXRlZ29yaWNhbC5weQ==) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvY29udmVydGVyLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/formats/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `0% <0%> (-99.37%)` | :arrow_down: |
| [pandas/io/sas/sas7bdat.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXM3YmRhdC5weQ==) | `0% <0%> (-91.16%)` | :arrow_down: |
| [pandas/io/sas/sas\_xport.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfeHBvcnQucHk=) | `0% <0%> (-90.1%)` | :arrow_down: |
| [pandas/core/sparse/scipy\_sparse.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL3NjaXB5X3NwYXJzZS5weQ==) | `10.14% <0%> (-89.86%)` | :arrow_down: |
| ... and [129 more](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26677?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/26677?src=pr&el=footer). Last update [c9c6c22...1c88839](https://codecov.io/gh/pandas-dev/pandas/pull/26677?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/26677?src=pr&el=h1) Report
> Merging [#26677](https://codecov.io/gh/pandas-dev/pandas/pull/26677?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/a387110c054e0f9db40cef6b05d3cfa804532dd9?src=pr&el=desc) will **increase** coverage by `1.4%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##           master   #26677     +/-   ##
=========================================
+ Coverage    90.3%    91.7%   +1.4%     
=========================================
  Files         179      179             
  Lines       50747    50749      +2     
=========================================
+ Hits        45826    46540    +714     
+ Misses       4921     4209    -712
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.3% <100%> (ø)` | :arrow_up: |
| #single | `41.22% <50%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26677?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `98.14% <100%> (ø)` | :arrow_up: |
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.92% <0%> (+0.12%)` | :arrow_up: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `96.37% <0%> (+0.16%)` | :arrow_up: |
| [pandas/io/formats/printing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvcHJpbnRpbmcucHk=) | `85.56% <0%> (+1.06%)` | :arrow_up: |
| [pandas/io/clipboard/clipboards.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NsaXBib2FyZC9jbGlwYm9hcmRzLnB5) | `34.78% <0%> (+2.89%)` | :arrow_up: |
| [pandas/core/computation/expr.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vZXhwci5weQ==) | `97.52% <0%> (+3.02%)` | :arrow_up: |
| [pandas/core/computation/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vY29tbW9uLnB5) | `89.47% <0%> (+5.26%)` | :arrow_up: |
| [pandas/io/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3B5dGFibGVzLnB5) | `90.29% <0%> (+26.47%)` | :arrow_up: |
| [pandas/core/computation/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/26677/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vcHl0YWJsZXMucHk=) | `90.24% <0%> (+27.74%)` | :arrow_up: |

------

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

@WillAyd the ci failures are now fixed. but could still parametrise `all_index_empty` directly for now and decompose later as required, if it makes the code clearer.
thanks @simonjayhawkins