Fix type annotation for pandas.core.generic.py
State: closed

Also remove this module from mypy.ini

- [x] closes #25901 
- [x] 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:
@vaibhavhrt could you also take care of the following?

```sh
pandas/core/frame.py:368: error: Need type annotation for '_accessors'
```

Very similar problem mentioned in issue I think makes sense to knock out together
@WillAyd Sure I will take care of frames.py too
There is a little problem with frame.py, I am getting this error instead of what you wrote in your comment:

> pandas\core\frame.py:368: error: Incompatible types in assignment (expression has type "Set[\<nothing\>]", base class "NDFrame" defined the type as "FrozenSet[str]")

And I can't fix it even after adding type. Still getting the same(almost) error.

> pandas\core\frame.py:368: error: Incompatible types in assignment (expression has type "Set[str]", base class "NDFrame" defined the type as "FrozenSet[str]")

Most likely because I just set type of `_accessor` to `FrozenSet` in generic.py and the class DataFrame extends the class I just edited in generic.py. I think `_accessor` of both class needs to be same type. So which type should I use, `set` or `frozenset`
I think just using Set consistently should be fine. 

Sent from my iPhone

> On Mar 28, 2019, at 6:24 AM, Vaibhav Vishal <notifications@github.com> wrote:
> 
> There is a little problem with frame.py, I am getting this error instead of what you wrote in your comment:
> 
> pandas\core\frame.py:368: error: Incompatible types in assignment (expression has type "Set[<nothing>]", base class "NDFrame" defined the type as "FrozenSet[str]")
> 
> And I can't fix it even after adding type. Still getting the same(almost) error.
> 
> pandas\core\frame.py:368: error: Incompatible types in assignment (expression has type "Set[str]", base class "NDFrame" defined the type as "FrozenSet[str]")
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.

Alright I will replace `_accessor = frozenset()` with `_accessor = set()` in generic.NDFrame too. Or should I just change the type to `Set[str]`
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25909?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@68dd979`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #25909   +/-   ##
=========================================
  Coverage          ?   91.56%           
=========================================
  Files             ?      175           
  Lines             ?    52776           
  Branches          ?        0           
=========================================
  Hits              ?    48322           
  Misses            ?     4454           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.12% <100%> (?)` | |
| #single | `41.81% <100%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25909?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/25909/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `93.54% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25909?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/25909?src=pr&el=footer). Last update [68dd979...6829ccd](https://codecov.io/gh/pandas-dev/pandas/pull/25909?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/25909?src=pr&el=h1) Report
> Merging [#25909](https://codecov.io/gh/pandas-dev/pandas/pull/25909?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d86553b00fe263d264bd0b2ce691724591dc7b01?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/25909/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25909?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #25909      +/-   ##
==========================================
- Coverage   91.96%   91.95%   -0.01%     
==========================================
  Files         175      175              
  Lines       52405    52406       +1     
==========================================
- Hits        48193    48189       -4     
- Misses       4212     4217       +5
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25909?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/25909/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.9% <100%> (-0.12%)` | :arrow_down: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/25909/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `93.54% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/25909/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `75% <0%> (-12.5%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25909/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.61% <0%> (-0.11%)` | :arrow_down: |

------

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

@vaibhavhrt yes change both
I have already changed it to `_accessor = set()  # type: Set[str]` in both files, but it's on my other laptop. I will push them tomorrow morning.
also pls merge master
@jreback Yeah I saw the conflicts, looks like master updated after I started working on it. I will take care of that too.
@jreback I have made changes as requested. Please review it when you find some time.
It is required because it can’t infer from the declaration what type of objects the set should hold. 

Sent from my iPhone

> On Apr 8, 2019, at 11:29 AM, jbrockmendel <notifications@github.com> wrote:
> 
> @jbrockmendel commented on this pull request.
> 
> In pandas/core/frame.py:
> 
> > @@ -363,10 +363,11 @@ class DataFrame(NDFrame):
>      def _constructor(self):
>          return DataFrame
>  
> -    _constructor_sliced = Series
> -    _deprecations = NDFrame._deprecations | frozenset(
> -        ['get_value', 'set_value', 'from_csv', 'from_items'])
> -    _accessors = set()
> +    _constructor_sliced = Series  # type: Type[Series]
> +    _deprecations = NDFrame._deprecations | frozenset([
> +        'get_value', 'set_value', 'from_csv', 'from_items'
> +    ])  # type: FrozenSet[str]
> +    _accessors = set()  # type: Set[str]
> @WillAyd Im still not clear on what the upside from this added verbosity is. Can mypy really not figure out that set() is a set?
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.

@vaibhavhrt can you merge master?
@WillAyd master merged.
thanks @vaibhavhrt 
Thanks for merging, I will pick up some new issues tomorrow.