From ccc5664f9d0bd8917548f30b84ef5e716aa5704e Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Thu, 28 Mar 2019 18:25:19 +0530 Subject: [PATCH 1/7] fix type annotation for pandas/core/generic.py and remove it from mypy.ini --- mypy.ini | 3 --- pandas/core/generic.py | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mypy.ini b/mypy.ini index b7dbf390fa8c9..eee109cd17b96 100644 --- a/mypy.ini +++ b/mypy.ini @@ -80,9 +80,6 @@ ignore_errors=True [mypy-pandas.core.frame] ignore_errors=True -[mypy-pandas.core.generic] -ignore_errors=True - [mypy-pandas.core.groupby.generic] ignore_errors=True diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 9797069566b4b..7a76708ea95ab 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6,6 +6,7 @@ import json import operator from textwrap import dedent +from typing import Container, List import warnings import weakref @@ -113,10 +114,10 @@ class NDFrame(PandasObject, SelectionMixin): '_default_fill_value', '_metadata', '__array_struct__', '__array_interface__'] _internal_names_set = set(_internal_names) - _accessors = frozenset() + _accessors = frozenset() # type: Container[str] _deprecations = frozenset(['as_blocks', 'blocks', 'convert_objects', 'is_copy']) - _metadata = [] + _metadata = [] # type: List[str] _is_copy = None # dummy attribute so that datetime.__eq__(Series/DataFrame) defers From 6829ccd9cab79c2c9f19b678349301a4bd3504e4 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Thu, 28 Mar 2019 18:35:03 +0530 Subject: [PATCH 2/7] use proper type for _accessors --- pandas/core/generic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 7a76708ea95ab..45d7853ba34c6 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6,7 +6,7 @@ import json import operator from textwrap import dedent -from typing import Container, List +from typing import FrozenSet, List import warnings import weakref @@ -114,7 +114,7 @@ class NDFrame(PandasObject, SelectionMixin): '_default_fill_value', '_metadata', '__array_struct__', '__array_interface__'] _internal_names_set = set(_internal_names) - _accessors = frozenset() # type: Container[str] + _accessors = frozenset() # type: FrozenSet[str] _deprecations = frozenset(['as_blocks', 'blocks', 'convert_objects', 'is_copy']) _metadata = [] # type: List[str] From d13214bce1c34b9e87fb6494b639aa7f7fe7fe99 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Thu, 28 Mar 2019 19:03:44 +0530 Subject: [PATCH 3/7] fix type annotation DataFrame._accessor in frame.py --- mypy.ini | 3 --- pandas/core/frame.py | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/mypy.ini b/mypy.ini index eee109cd17b96..610c2f27d058b 100644 --- a/mypy.ini +++ b/mypy.ini @@ -77,9 +77,6 @@ ignore_errors=True [mypy-pandas.core.dtypes.missing] ignore_errors=True -[mypy-pandas.core.frame] -ignore_errors=True - [mypy-pandas.core.groupby.generic] ignore_errors=True diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 7ead94ddcff4e..3285cfa77e376 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -17,7 +17,7 @@ import sys import warnings from textwrap import dedent -from typing import List, Union +from typing import FrozenSet, List, Union import numpy as np import numpy.ma as ma @@ -365,7 +365,7 @@ def _constructor(self): _constructor_sliced = Series _deprecations = NDFrame._deprecations | frozenset( ['get_value', 'set_value', 'from_csv', 'from_items']) - _accessors = set() + _accessors = frozenset() # type: FrozenSet[str] @property def _constructor_expanddim(self): From 5256a35eda6d9a4c71048f444cb0e824f8ea8cf2 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Thu, 28 Mar 2019 19:23:49 +0530 Subject: [PATCH 4/7] use set for _accessors of both NDFrame and DataFrame --- pandas/core/frame.py | 4 ++-- pandas/core/generic.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3285cfa77e376..ae195b46b78de 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -17,7 +17,7 @@ import sys import warnings from textwrap import dedent -from typing import FrozenSet, List, Union +from typing import List, Set, Union import numpy as np import numpy.ma as ma @@ -365,7 +365,7 @@ def _constructor(self): _constructor_sliced = Series _deprecations = NDFrame._deprecations | frozenset( ['get_value', 'set_value', 'from_csv', 'from_items']) - _accessors = frozenset() # type: FrozenSet[str] + _accessors = set() # type: Set[str] @property def _constructor_expanddim(self): diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 45d7853ba34c6..639de56b07ff9 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6,7 +6,7 @@ import json import operator from textwrap import dedent -from typing import FrozenSet, List +from typing import List, Set import warnings import weakref @@ -114,7 +114,7 @@ class NDFrame(PandasObject, SelectionMixin): '_default_fill_value', '_metadata', '__array_struct__', '__array_interface__'] _internal_names_set = set(_internal_names) - _accessors = frozenset() # type: FrozenSet[str] + _accessors = frozenset() # type: Set[str] _deprecations = frozenset(['as_blocks', 'blocks', 'convert_objects', 'is_copy']) _metadata = [] # type: List[str] From b6a69692e849f95cf98fab288b0e1b58d9fd3c1b Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Fri, 29 Mar 2019 10:54:16 +0530 Subject: [PATCH 5/7] make _accessor a set instead of frozenset --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 639de56b07ff9..e0c78d3276976 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -114,7 +114,7 @@ class NDFrame(PandasObject, SelectionMixin): '_default_fill_value', '_metadata', '__array_struct__', '__array_interface__'] _internal_names_set = set(_internal_names) - _accessors = frozenset() # type: Set[str] + _accessors = set() # type: Set[str] _deprecations = frozenset(['as_blocks', 'blocks', 'convert_objects', 'is_copy']) _metadata = [] # type: List[str] From 4b8a90936e5afa93cca926c43e1642f1d7057c7e Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Sun, 31 Mar 2019 19:44:49 +0530 Subject: [PATCH 6/7] type some more variables of generic.py --- pandas/core/generic.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index cfb67b99279ff..a9066497abd46 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6,7 +6,7 @@ import json import operator from textwrap import dedent -from typing import List, Set +from typing import FrozenSet, List, Set import warnings import weakref @@ -111,11 +111,12 @@ class NDFrame(PandasObject, SelectionMixin): _internal_names = ['_data', '_cacher', '_item_cache', '_cache', '_is_copy', '_subtyp', '_name', '_index', '_default_kind', '_default_fill_value', '_metadata', '__array_struct__', - '__array_interface__'] - _internal_names_set = set(_internal_names) + '__array_interface__'] # type: List[str] + _internal_names_set = set(_internal_names) # type: Set[str] _accessors = set() # type: Set[str] - _deprecations = frozenset(['as_blocks', 'blocks', - 'convert_objects', 'is_copy']) + _deprecations = frozenset([ + 'as_blocks', 'blocks', 'convert_objects', 'is_copy' + ]) # type: FrozenSet[str] _metadata = [] # type: List[str] _is_copy = None From 7f95d7f031d9647207d6cc8e1a25c7bf53ccf850 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Sun, 31 Mar 2019 19:56:32 +0530 Subject: [PATCH 7/7] type few more variables of frames.py --- pandas/core/frame.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index ac9845b21ca50..ca5e766abe8ea 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -17,7 +17,7 @@ import sys import warnings from textwrap import dedent -from typing import List, Optional, Set, Union +from typing import FrozenSet, List, Optional, Set, Type, Union import numpy as np import numpy.ma as ma @@ -363,9 +363,10 @@ class DataFrame(NDFrame): def _constructor(self): return DataFrame - _constructor_sliced = Series - _deprecations = NDFrame._deprecations | frozenset( - ['get_value', 'set_value', 'from_csv', 'from_items']) + _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] @property