WIP for MyPy CI Integration
State: closed

progress towards #25601 

Not complete just pushing for now. Main goal here is to get a CI run that works for any modules existing with comments.

Labels:
name: Code Style
description: Code style, linting, code_checks

Comments:
Hello @WillAyd! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:































* In the file [`pandas/core/internals/blocks.py`](https://github.com/pandas-dev/pandas/blob/ac7e76895b80314c78b246abb19a8764516123ae/pandas/core/internals/blocks.py):

> [Line 1835:5](https://github.com/pandas-dev/pandas/blob/ac7e76895b80314c78b246abb19a8764516123ae/pandas/core/internals/blocks.py#L1835): [E124](https://duckduckgo.com/?q=pep8%20E124) closing bracket does not match visual indentation





##### Comment last updated at 2019-03-11 19:40:33 UTC
One issue in existings that I wasn't sure how to resolve stems from the ExtensionBlock in internals, specifically this line:

https://github.com/pandas-dev/pandas/blob/e28ae70ba8bd8b4174143543d1660421bc67887b/pandas/core/internals/blocks.py#L1693

It's superclass and all other subclasses derived therefrom treat this as an attribute, whereas here it's a property. I *think* that's the root of the issue
> One issue in existings that I wasn't sure how to resolve stems from the ExtensionBlock in internals, specifically this line:
> 
> [pandas/pandas/core/internals/blocks.py](https://github.com/pandas-dev/pandas/blob/e28ae70ba8bd8b4174143543d1660421bc67887b/pandas/core/internals/blocks.py#L1693)
> 
> Line 1693 in [e28ae70](/pandas-dev/pandas/commit/e28ae70ba8bd8b4174143543d1660421bc67887b)
>  def _can_hold_na(self): 
> 
> It's superclass and all other subclasses derived therefrom treat this as an attribute, whereas here it's a property. I _think_ that's the root of the issue

Interesting issue, it might be a bug in mypy. Although, it might also be a legitimate typing error: my guess would be that mypy is saying "you told me it's a property, so I expect that I can do `@Class.property.setter`, however, you also said it's `None` in which case `None.setter` is an error"
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25622?src=pr&el=h1) Report
> Merging [#25622](https://codecov.io/gh/pandas-dev/pandas/pull/25622?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/e28ae70ba8bd8b4174143543d1660421bc67887b?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #25622      +/-   ##
==========================================
+ Coverage   91.26%   91.26%   +<.01%     
==========================================
  Files         173      173              
  Lines       52968    52974       +6     
==========================================
+ Hits        48339    48345       +6     
  Misses       4629     4629
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.84% <100%> (ø)` | :arrow_up: |
| #single | `41.72% <100%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25622?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Jhc2UucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `94.08% <100%> (ø)` | :arrow_up: |
| [pandas/core/groupby/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGJ5LnB5) | `97.21% <100%> (ø)` | :arrow_up: |
| [pandas/core/internals/managers.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL21hbmFnZXJzLnB5) | `93.93% <100%> (+0.01%)` | :arrow_up: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `98.39% <100%> (ø)` | :arrow_up: |

------

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

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

```diff
@@            Coverage Diff             @@
##           master   #25622      +/-   ##
==========================================
+ Coverage   91.26%   91.26%   +<.01%     
==========================================
  Files         173      173              
  Lines       52968    52992      +24     
==========================================
+ Hits        48339    48364      +25     
+ Misses       4629     4628       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.84% <100%> (ø)` | :arrow_up: |
| #single | `41.73% <90.24%> (+0.02%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25622?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/integer.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2ludGVnZXIucHk=) | `96.32% <ø> (ø)` | :arrow_up: |
| [pandas/core/dtypes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Jhc2UucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `98.27% <100%> (+0.02%)` | :arrow_up: |
| [pandas/core/arrays/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lbGlrZS5weQ==) | `97.68% <100%> (ø)` | :arrow_up: |
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `94.08% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `98.52% <100%> (ø)` | :arrow_up: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `98.54% <100%> (+0.01%)` | :arrow_up: |
| [pandas/core/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYmFzZS5weQ==) | `97.76% <100%> (ø)` | :arrow_up: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `88.22% <100%> (+0.02%)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.79% <100%> (ø)` | :arrow_up: |
| ... and [20 more](https://codecov.io/gh/pandas-dev/pandas/pull/25622/diff?src=pr&el=tree-more) | |

------

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

Changes so far were low effort fixes. Here's what's left when running `mypy @mypy_whitelist.txt`:

```sh
pandas/core/base.py:853: error: "IndexOpsMixin" has no attribute "_values"; maybe "_map_values"?
pandas/core/base.py:978: error: "IndexOpsMixin" has no attribute "values"
pandas/core/arrays/array_.py:235: error: Item "str" of "Union[str, Any, ExtensionDtype, None]" has no attribute "construct_array_type"
pandas/core/arrays/array_.py:235: error: Item "None" of "Union[str, Any, ExtensionDtype, None]" has no attribute "construct_array_type"
pandas/core/arrays/datetimelike.py:365: error: "DatetimeLikeArrayMixin" has no attribute "_data"
pandas/core/arrays/datetimelike.py:466: error: Name 'Scalar' is not defined
pandas/core/arrays/datetimelike.py:482: error: Argument 1 to "len" has incompatible type "Union[int, Sequence[int], Sequence[bool], slice]"; expected "Sized"
pandas/core/arrays/datetimelike.py:486: error: Argument 1 to "len" has incompatible type "Union[int, Sequence[int], Sequence[bool], slice]"; expected "Sized"
pandas/core/arrays/datetimelike.py:487: error: Argument 1 to "len" has incompatible type "Union[int, Sequence[int], Sequence[bool], slice]"; expected "Sized"
pandas/core/arrays/datetimelike.py:503: error: Item "Tuple[Any, ...]" of "Union[type, Tuple[type]]" has no attribute "__name__"
pandas/core/arrays/datetimelike.py:505: error: "DatetimeLikeArrayMixin" has no attribute "_data"
pandas/core/arrays/sparse.py:80: error: Incompatible types in assignment (expression has type "Tuple[str, str, str]", base class "_DtypeOpsMixin" defined the type as "Tuple[]")
pandas/core/arrays/period.py:189: error: "PeriodDtype" has no attribute "freq"
pandas/core/arrays/period.py:278: error: Read-only property cannot override read-write property
pandas/core/arrays/period.py:544: error: The first argument to Callable must be a list of types or "..."
pandas/core/arrays/period.py:550: error: Unsupported operand type for unary - ("Union[Index, ExtensionArray, Any]")
pandas/core/arrays/period.py:784: error: Incompatible types in assignment (expression has type "None", variable has type "PeriodDtype")
pandas/core/arrays/integer.py:34: error: Incompatible types in assignment (expression has type "None", base class "ExtensionDtype" defined the type as "str")
pandas/core/arrays/integer.py:36: error: Incompatible types in assignment (expression has type "None", base class "ExtensionDtype" defined the type as "Type[Any]")
pandas/core/indexes/datetimelike.py:65: error: "Callable[[Any], Any]" has no attribute "fget"
pandas/core/indexes/datetimelike.py:66: error: "Callable[[Any], Any]" has no attribute "fget"
pandas/core/indexes/datetimelike.py:67: error: "Callable[[Any], Any]" has no attribute "fget"
pandas/core/indexes/datetimelike.py:69: error: "Callable[[Any], Any]" has no attribute "fget"
pandas/core/indexes/datetimelike.py:70: error: "Callable[[Any], Any]" has no attribute "fget"
pandas/core/indexes/datetimelike.py:136: error: "DatetimeLikeArrayMixin" has no attribute "_data"
pandas/core/indexes/datetimelike.py:138: error: Decorated property not supported
pandas/core/indexes/datetimelike.py:208: error: Name '_box_values' already defined on line 72
pandas/core/indexes/period.py:68: error: Definition of "_data" in base class "DatetimeIndexOpsMixin" is incompatible with definition in base class "Index"
pandas/core/indexes/period.py:68: error: Definition of "_data" in base class "DatetimeIndexOpsMixin" is incompatible with definition in base class "DatetimelikeDelegateMixin"
pandas/core/indexes/period.py:68: error: Definition of "map" in base class "DatetimeIndexOpsMixin" is incompatible with definition in base class "Index"
pandas/core/indexes/period.py:68: error: Definition of "_format_with_header" in base class "DatetimeIndexOpsMixin" is incompatible with definition in base class "Index"
pandas/core/indexes/period.py:68: error: Definition of "isin" in base class "DatetimeIndexOpsMixin" is incompatible with definition in base class "Index"
pandas/core/internals/blocks.py:2218: error: Definition of "_can_hold_na" in base class "ExtensionBlock" is incompatible with definition in base class "DatetimeBlock"
```

Some of these will actually require a refactor of code. Probably want to split off into pre-cursor or at least separate PRs to tackle
Somewhat superseded by #25789 - there are some things here I'd like to extract out but easier to start fresh than merge master at this point