Remove pandas.core.index.datetimelike from MyPy Blacklist 
State: closed

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


Labels:
name: Typing
description: type annotations, mypy/pyright type checking

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

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

```diff
@@            Coverage Diff             @@
##           master   #26280      +/-   ##
==========================================
- Coverage   91.98%   91.98%   -0.01%     
==========================================
  Files         175      175              
  Lines       52379    52379              
==========================================
- Hits        48183    48179       -4     
- Misses       4196     4200       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.53% <100%> (ø)` | :arrow_up: |
| #single | `40.73% <100%> (-0.15%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26280?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `98.13% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.9% <0%> (-0.12%)` | :arrow_down: |

------

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

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

```diff
@@            Coverage Diff             @@
##           master   #26280      +/-   ##
==========================================
+ Coverage   91.71%   91.99%   +0.27%     
==========================================
  Files         178      180       +2     
  Lines       50755    50774      +19     
==========================================
+ Hits        46552    46708     +156     
+ Misses       4203     4066     -137
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.63% <100%> (+0.32%)` | :arrow_up: |
| #single | `41.85% <100%> (+0.54%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26280?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `99.43% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `98.14% <100%> (ø)` | :arrow_up: |
| [pandas/core/algorithms.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYWxnb3JpdGhtcy5weQ==) | `94.74% <100%> (ø)` | :arrow_up: |
| [pandas/core/computation/check.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vY2hlY2sucHk=) | `85.71% <0%> (-6.6%)` | :arrow_down: |
| [pandas/compat/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9fX2luaXRfXy5weQ==) | `92% <0%> (-1.55%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `88.88% <0%> (-0.59%)` | :arrow_down: |
| [pandas/tseries/offsets.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvb2Zmc2V0cy5weQ==) | `96.36% <0%> (-0.33%)` | :arrow_down: |
| [pandas/plotting/\_matplotlib/hist.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL2hpc3QucHk=) | `76.82% <0%> (-0.19%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.89% <0%> (-0.12%)` | :arrow_down: |
| [pandas/plotting/\_matplotlib/core.py](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL2NvcmUucHk=) | `88.02% <0%> (-0.09%)` | :arrow_down: |
| ... and [71 more](https://codecov.io/gh/pandas-dev/pandas/pull/26280/diff?src=pr&el=tree-more) | |

------

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

Can you merge master?
@makbigc some of the errors in this file has been solved by #26404 
You can go ahead and fix(or ignore) the remaining.
Can you merge master? Think this will be the last remaining module from the blacklist
can you merge master
mypy has the following error for the annotated value function: 

`pandas/core/indexes/datetimelike.py:139: error: "None" has no attribute "_data"`

I add annotation ` # type: DatetimeArray ` to `_data`. But mypy still has the same error.
https://github.com/pandas-dev/pandas/blob/8154efb0c1a64295cf54e00025b4ab09bcd02752/pandas/core/indexes/datetimes.py#L327

Do you have any better way?
@makbigc can you merge master and address last comment? This should close out the reference issue (updated OP to reflect)
I can't figure out why DatetimeArray, PeriodArray and TimedeltaArray cannot be imported inside _typing.py

`from pandas.core.arrays import DatetimeArray, PeriodArray, TimedeltaArray`
No I don’t think this needs to be renamed. I don’t have a problem using the TYPE_CHECKING constant in that module alone if it resolves circular imports. 

Sent from my iPhone

> On Jun 18, 2019, at 10:23 AM, Mak Sze Chun <notifications@github.com> wrote:
> 
> @makbigc commented on this pull request.
> 
> In pandas/_typing.py:
> 
> > @@ -11,12 +11,17 @@
>  from pandas.core.dtypes.generic import (
>      ABCExtensionArray, ABCIndexClass, ABCSeries, ABCSparseSeries)
>  
> +from pandas.core.arrays import DatetimeArray, PeriodArray, TimedeltaArray
> +
> @WillAyd Would you tell me your opinion? Should we change the filename of _typing.py?
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.

Yes, the problem is due to the circular import.
`common` -> `_typing` -> `datetimelikey` -> `common`
I can't resolve this circular import and datetimelike.py is the last exception in mypy.ini. So I close this PR for others picking it up.
Thanks all.
Doesn’t using the TYPE_CHECKING constant from the stdlib typing module in pandas._typing resolve the circular import?

I think this is really close!
@WillAyd Thanks for your reply. I have added the following in `_typing.py`
```
if TYPE_CHECKING:
    from pandas.core.arrays.datetimes import DatetimeArray
    from pandas.core.arrays.period import PeriodArray
    from pandas.core.arrays.timedeltas import TimedeltaArray
    DatetimeLikeArray = TypeVar('DatetimeLikeArray', DatetimeArray,
                                PeriodArray, TimedeltaArray)
```
and added the following to datetimelike.py
```
if TYPE_CHECKING:
    from pandas._typing import DatetimeLikeArray
```
The circular import is solved. But mypy cannot find the DatetimeLikeArray!
`pandas/core/indexes/datetimelike.py:67: error: Invalid type "pandas.DatetimeLikeArray"`
lgtm. @WillAyd merge when ready.
Thanks @makbigc !