From bc01d6655b3d58d68a741bb10b92de5be1608faf Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Sat, 15 Jun 2019 17:20:38 +0530 Subject: [PATCH 01/19] type a few functions --- pandas/core/frame.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d2d0525a0a0ff..8fea2173c918f 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -16,7 +16,7 @@ import sys import warnings from textwrap import dedent -from typing import FrozenSet, List, Optional, Set, Type, Union +from typing import FrozenSet, List, Optional, Set, Tuple, Type, Union import numpy as np import numpy.ma as ma @@ -358,7 +358,7 @@ class DataFrame(NDFrame): """ @property - def _constructor(self): + def _constructor(self) -> Type[DataFrame]: return DataFrame _constructor_sliced = Series # type: Type[Series] @@ -368,14 +368,18 @@ def _constructor(self): _accessors = set() # type: Set[str] @property - def _constructor_expanddim(self): + def _constructor_expanddim(self) -> None: raise NotImplementedError("Not supported for DataFrames!") # ---------------------------------------------------------------------- # Constructors - def __init__(self, data=None, index=None, columns=None, dtype=None, - copy=False): + def __init__(self, + data=None, + index: Index=None, + columns: Index=None, + dtype=None, + copy: bool=False) -> None: if data is None: data = {} if dtype is not None: @@ -471,7 +475,7 @@ def __init__(self, data=None, index=None, columns=None, dtype=None, # ---------------------------------------------------------------------- @property - def axes(self): + def axes(self) -> List[Index]: """ Return a list representing the axes of the DataFrame. @@ -488,7 +492,7 @@ def axes(self): return [self.index, self.columns] @property - def shape(self): + def shape(self) -> Tuple[int, int]: """ Return a tuple representing the dimensionality of the DataFrame. @@ -510,7 +514,7 @@ def shape(self): return len(self.index), len(self.columns) @property - def _is_homogeneous_type(self): + def _is_homogeneous_type(self) -> bool: """ Whether all the columns in a DataFrame have the same type. From 5e70e01530e80d236ce08938ea86c216a575af47 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Sat, 15 Jun 2019 17:23:46 +0530 Subject: [PATCH 02/19] fix flake errors --- pandas/core/frame.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 8fea2173c918f..885cb263ee772 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -358,7 +358,7 @@ class DataFrame(NDFrame): """ @property - def _constructor(self) -> Type[DataFrame]: + def _constructor(self) -> Type['DataFrame']: return DataFrame _constructor_sliced = Series # type: Type[Series] @@ -376,10 +376,10 @@ def _constructor_expanddim(self) -> None: def __init__(self, data=None, - index: Index=None, - columns: Index=None, + index: Index = None, + columns: Index = None, dtype=None, - copy: bool=False) -> None: + copy: bool = False) -> None: if data is None: data = {} if dtype is not None: From 305329e122c4b499bc14665600d30bf4dd230355 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Sat, 15 Jun 2019 19:10:16 +0530 Subject: [PATCH 03/19] minor changes --- pandas/core/frame.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 885cb263ee772..7bc8f080e1cb7 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -25,6 +25,8 @@ from pandas._libs import lib, algos as libalgos +from pandas._typing import ArrayLike, Dtype + from pandas.util._decorators import (Appender, Substitution, rewrite_axis_style_signature, deprecate_kwarg) @@ -368,7 +370,7 @@ def _constructor(self) -> Type['DataFrame']: _accessors = set() # type: Set[str] @property - def _constructor_expanddim(self) -> None: + def _constructor_expanddim(self): raise NotImplementedError("Not supported for DataFrames!") # ---------------------------------------------------------------------- @@ -376,9 +378,9 @@ def _constructor_expanddim(self) -> None: def __init__(self, data=None, - index: Index = None, - columns: Index = None, - dtype=None, + index: ArrayLike = None, + columns: ArrayLike = None, + dtype: Dtype = None, copy: bool = False) -> None: if data is None: data = {} @@ -475,7 +477,7 @@ def __init__(self, # ---------------------------------------------------------------------- @property - def axes(self) -> List[Index]: + def axes(self) -> List[ArrayLike]: """ Return a list representing the axes of the DataFrame. From 58a7da6567b0ada3b08f24776d8d648fafbdafa1 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Tue, 18 Jun 2019 00:59:12 +0530 Subject: [PATCH 04/19] create type for Axes in _typing and make parameters of __init__ optional --- pandas/_typing.py | 5 ++++- pandas/core/frame.py | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index a2bb168c1e2da..d49619ec6aa09 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -1,5 +1,5 @@ from pathlib import Path -from typing import IO, AnyStr, TypeVar, Union +from typing import IO, AnyStr, Iterable, TypeVar, Union import numpy as np @@ -22,3 +22,6 @@ Timedelta) Dtype = Union[str, np.dtype, ExtensionDtype] FilePathOrBuffer = Union[str, Path, IO[AnyStr]] + +# Type for index and columns of DataFrame +Axes = Iterable[Union[ABCIndexClass, Iterable[str]]] diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 7bc8f080e1cb7..10b46e348f5e6 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -25,7 +25,7 @@ from pandas._libs import lib, algos as libalgos -from pandas._typing import ArrayLike, Dtype +from pandas._typing import ArrayLike, Axes, Dtype from pandas.util._decorators import (Appender, Substitution, rewrite_axis_style_signature, @@ -378,10 +378,10 @@ def _constructor_expanddim(self): def __init__(self, data=None, - index: ArrayLike = None, - columns: ArrayLike = None, - dtype: Dtype = None, - copy: bool = False) -> None: + index: Optional[Axes] = None, + columns: Optional[Axes] = None, + dtype: Optional[Dtype] = None, + copy: Optional[bool] = False) -> None: if data is None: data = {} if dtype is not None: @@ -477,7 +477,7 @@ def __init__(self, # ---------------------------------------------------------------------- @property - def axes(self) -> List[ArrayLike]: + def axes(self) -> List[Index]: """ Return a list representing the axes of the DataFrame. From c54642fa541744f4a8135f991a01e6df361cf157 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Wed, 17 Jul 2019 19:01:43 +0530 Subject: [PATCH 05/19] WIP type for data --- pandas/_typing.py | 4 ++++ pandas/core/frame.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index 431c3e8e24d26..07ae70e51edf8 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -31,5 +31,9 @@ # Type for index and columns of DataFrame Axes = Iterable[Union[ABCIndexClass, Iterable[str]]] + +# Type for data of DataFrame +Data = TypeVar("Data", ABCDataFrame, dict, np.ndarray) + FrameOrSeries = TypeVar("FrameOrSeries", ABCSeries, ABCDataFrame) Scalar = Union[str, int, float] diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 4ffb617138f45..6836a5637dc92 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -80,7 +80,7 @@ ) from pandas.core.dtypes.missing import isna, notna -from pandas._typing import Axes, Dtype +from pandas._typing import Axes, Data, Dtype from pandas.core import algorithms, common as com, nanops, ops from pandas.core.accessor import CachedAccessor from pandas.core.arrays import Categorical, ExtensionArray @@ -391,7 +391,7 @@ def _constructor_expanddim(self): # Constructors def __init__(self, - data=None, + data: Optional[Data] = None, index: Optional[Axes] = None, columns: Optional[Axes] = None, dtype: Optional[Dtype] = None, From 0fd42eb6f16d986aa78871f3bd01a44343a1c2c8 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Wed, 24 Jul 2019 15:27:26 +0530 Subject: [PATCH 06/19] move types for 'data' in 'frame.py' from 'pandas._typing' --- pandas/_typing.py | 3 --- pandas/core/frame.py | 7 ++++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index 07ae70e51edf8..20042106588f9 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -32,8 +32,5 @@ # Type for index and columns of DataFrame Axes = Iterable[Union[ABCIndexClass, Iterable[str]]] -# Type for data of DataFrame -Data = TypeVar("Data", ABCDataFrame, dict, np.ndarray) - FrameOrSeries = TypeVar("FrameOrSeries", ABCSeries, ABCDataFrame) Scalar = Union[str, int, float] diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 6836a5637dc92..88575c5252873 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -15,7 +15,7 @@ import itertools import sys from textwrap import dedent -from typing import FrozenSet, List, Optional, Set, Tuple, Type, Union +from typing import Any, FrozenSet, Iterable, List, Optional, Set, Tuple, Type, Union import warnings import numpy as np @@ -80,7 +80,7 @@ ) from pandas.core.dtypes.missing import isna, notna -from pandas._typing import Axes, Data, Dtype +from pandas._typing import Axes, Dtype from pandas.core import algorithms, common as com, nanops, ops from pandas.core.accessor import CachedAccessor from pandas.core.arrays import Categorical, ExtensionArray @@ -391,7 +391,8 @@ def _constructor_expanddim(self): # Constructors def __init__(self, - data: Optional[Data] = None, + data: Optional[Union[np.ndarray, dict, + 'DataFrame']] = None, index: Optional[Axes] = None, columns: Optional[Axes] = None, dtype: Optional[Dtype] = None, From e413504ccf603c19b40f7c0875b6cc59829025db Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Thu, 25 Jul 2019 16:35:31 +0530 Subject: [PATCH 07/19] use ABCDataFrame instead of 'DataFrame' --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index ce0f23f21a4a1..9e53c23e01fea 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -396,7 +396,7 @@ def _constructor_expanddim(self): def __init__(self, data: Optional[Union[np.ndarray, dict, - 'DataFrame']] = None, + ABCDataFrame]] = None, index: Optional[Axes] = None, columns: Optional[Axes] = None, dtype: Optional[Dtype] = None, From 5ec1c87916d13683c0741a59472b3f5e410cf2db Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Fri, 26 Jul 2019 12:44:08 +0530 Subject: [PATCH 08/19] use Index instead of ABCIndex --- pandas/_typing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index cbc366de3ad4a..fb46c08a5f168 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -25,7 +25,7 @@ FilePathOrBuffer = Union[str, Path, IO[AnyStr]] # Type for index and columns of DataFrame -Axes = Iterable[Union[ABCIndexClass, Iterable[str]]] +Axes = Iterable[Union["Index", Iterable[str]]] FrameOrSeries = TypeVar("FrameOrSeries", "Series", "DataFrame") Scalar = Union[str, int, float] From 17214ea8f9a3f0ebd18bfbf780fc40eae1208ab5 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Fri, 26 Jul 2019 13:06:47 +0530 Subject: [PATCH 09/19] use typing.Dict instead of dict --- pandas/core/frame.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index a1a38c7b6ee76..909ea6ca21999 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -15,7 +15,7 @@ import itertools import sys from textwrap import dedent -from typing import FrozenSet, List, Optional, Set, Tuple, Type, Union +from typing import Dict, FrozenSet, List, Optional, Set, Tuple, Type, Union import warnings import numpy as np @@ -392,8 +392,8 @@ def _constructor_expanddim(self): # Constructors def __init__(self, - data: Optional[Union[np.ndarray, dict, - ABCDataFrame]] = None, + data: Optional[Union[np.ndarray, Dict, + "DataFrame"]] = None, index: Optional[Axes] = None, columns: Optional[Axes] = None, dtype: Optional[Dtype] = None, From fba0fcc964fc21705629965af69ee1b86add4784 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Mon, 29 Jul 2019 15:23:14 +0530 Subject: [PATCH 10/19] add more tyoes in data, error expected --- pandas/core/frame.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 909ea6ca21999..e48d908b7a6f8 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -15,7 +15,7 @@ import itertools import sys from textwrap import dedent -from typing import Dict, FrozenSet, List, Optional, Set, Tuple, Type, Union +from typing import Dict, FrozenSet, Iterable, List, Optional, Set, Tuple, Type, Union import warnings import numpy as np @@ -80,7 +80,7 @@ ) from pandas.core.dtypes.missing import isna, notna -from pandas._typing import Axes, Dtype +from pandas._typing import AnyArrayLike, Axes, Dtype from pandas.core import algorithms, common as com, nanops, ops from pandas.core.accessor import CachedAccessor from pandas.core.arrays import Categorical, ExtensionArray @@ -392,8 +392,8 @@ def _constructor_expanddim(self): # Constructors def __init__(self, - data: Optional[Union[np.ndarray, Dict, - "DataFrame"]] = None, + data: Optional[Union[np.ndarray, Iterable, Dict[str, AnyArrayLike], + "DataFrame"]] = None, index: Optional[Axes] = None, columns: Optional[Axes] = None, dtype: Optional[Dtype] = None, From 6da817c27e41f6a163a80f21d5d5c4e79192984b Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Mon, 26 Aug 2019 16:23:31 +0530 Subject: [PATCH 11/19] remove anootation of data as it's causing problems --- pandas/_typing.py | 4 ---- pandas/core/frame.py | 11 +++++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index 60b149d6db97a..07bbf35dcc9a6 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -23,10 +23,6 @@ DatetimeLikeScalar = TypeVar("DatetimeLikeScalar", "Period", "Timestamp", "Timedelta") Dtype = Union[str, np.dtype, "ExtensionDtype"] FilePathOrBuffer = Union[str, Path, IO[AnyStr]] - -# Type for index and columns of DataFrame -Axes = Iterable[Union["Index", Iterable[str]]] - FrameOrSeries = TypeVar("FrameOrSeries", "Series", "DataFrame") Scalar = Union[str, int, float] Axis = Union[str, int] diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3a19d93427515..a03e616b99168 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -80,7 +80,7 @@ ) from pandas.core.dtypes.missing import isna, notna -from pandas._typing import AnyArrayLike, Axes, Dtype +from pandas._typing import AnyArrayLike, Dtype from pandas.core import algorithms, common as com, nanops, ops from pandas.core.accessor import CachedAccessor from pandas.core.arrays import Categorical, ExtensionArray @@ -376,7 +376,7 @@ class DataFrame(NDFrame): """ @property - def _constructor(self) -> Type['DataFrame']: + def _constructor(self) -> Type["DataFrame"]: return DataFrame _constructor_sliced = Series # type: Type[Series] @@ -393,10 +393,9 @@ def _constructor_expanddim(self): # Constructors def __init__(self, - data: Optional[Union[np.ndarray, Iterable, Dict[str, AnyArrayLike], - "DataFrame"]] = None, - index: Optional[Axes] = None, - columns: Optional[Axes] = None, + data = None, + index: Optional[Iterable[Union["Index", Iterable[str]]]] = None, + columns: Optional[Iterable[Union["Index", Iterable[str]]]] = None, dtype: Optional[Dtype] = None, copy: Optional[bool] = False) -> None: if data is None: From c4ceab0d6306d78bc65623b033c857899ac7a50f Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Mon, 26 Aug 2019 16:25:22 +0530 Subject: [PATCH 12/19] remove unused import --- pandas/_typing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index 07bbf35dcc9a6..0b27c2e397ff3 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -1,5 +1,5 @@ from pathlib import Path -from typing import IO, TYPE_CHECKING, AnyStr, Iterable, Optional, TypeVar, Union +from typing import IO, TYPE_CHECKING, AnyStr, Optional, TypeVar, Union import numpy as np From 8830f54c04080b112ac54f8d9b7dd97d5a105923 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Mon, 26 Aug 2019 16:26:25 +0530 Subject: [PATCH 13/19] don't change anything in _typing --- pandas/_typing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/_typing.py b/pandas/_typing.py index 0b27c2e397ff3..837a7a89e0b83 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -23,6 +23,7 @@ DatetimeLikeScalar = TypeVar("DatetimeLikeScalar", "Period", "Timestamp", "Timedelta") Dtype = Union[str, np.dtype, "ExtensionDtype"] FilePathOrBuffer = Union[str, Path, IO[AnyStr]] + FrameOrSeries = TypeVar("FrameOrSeries", "Series", "DataFrame") Scalar = Union[str, int, float] Axis = Union[str, int] From 2e65291a90fbabaa4eb95f44f1d9c752876a4437 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Tue, 27 Aug 2019 18:50:59 +0530 Subject: [PATCH 14/19] put Axes back in pandas._typing --- pandas/_typing.py | 3 ++- pandas/core/frame.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index 837a7a89e0b83..93e31ecf4436d 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -1,5 +1,5 @@ from pathlib import Path -from typing import IO, TYPE_CHECKING, AnyStr, Optional, TypeVar, Union +from typing import IO, TYPE_CHECKING, AnyStr, Iterable, Optional, TypeVar, Union import numpy as np @@ -28,3 +28,4 @@ Scalar = Union[str, int, float] Axis = Union[str, int] Ordered = Optional[bool] +Axes = Iterable[Union["Index", Iterable[str]]] diff --git a/pandas/core/frame.py b/pandas/core/frame.py index a03e616b99168..936b42d38ce9b 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -15,7 +15,7 @@ import itertools import sys from textwrap import dedent -from typing import Dict, FrozenSet, Iterable, List, Optional, Set, Tuple, Type, Union +from typing import FrozenSet, List, Optional, Set, Tuple, Type, Union import warnings import numpy as np @@ -80,7 +80,7 @@ ) from pandas.core.dtypes.missing import isna, notna -from pandas._typing import AnyArrayLike, Dtype +from pandas._typing import Axes, Dtype from pandas.core import algorithms, common as com, nanops, ops from pandas.core.accessor import CachedAccessor from pandas.core.arrays import Categorical, ExtensionArray @@ -393,9 +393,9 @@ def _constructor_expanddim(self): # Constructors def __init__(self, - data = None, - index: Optional[Iterable[Union["Index", Iterable[str]]]] = None, - columns: Optional[Iterable[Union["Index", Iterable[str]]]] = None, + data=None, + index: Optional[Axes] = None, + columns: Optional[Axes] = None, dtype: Optional[Dtype] = None, copy: Optional[bool] = False) -> None: if data is None: From d99cc1a4c346e9d8e448452069f35251886c9563 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Wed, 28 Aug 2019 12:25:31 +0530 Subject: [PATCH 15/19] format with black --- pandas/core/frame.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 936b42d38ce9b..7a5454e8cd28a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -392,12 +392,14 @@ def _constructor_expanddim(self): # ---------------------------------------------------------------------- # Constructors - def __init__(self, - data=None, - index: Optional[Axes] = None, - columns: Optional[Axes] = None, - dtype: Optional[Dtype] = None, - copy: Optional[bool] = False) -> None: + def __init__( + self, + data=None, + index: Optional[Axes] = None, + columns: Optional[Axes] = None, + dtype: Optional[Dtype] = None, + copy: Optional[bool] = False, + ) -> None: if data is None: data = {} if dtype is not None: From 1740ef2fc3540bcbb0f76b9750efa6b701a8eb57 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Sat, 7 Sep 2019 12:41:59 +0530 Subject: [PATCH 16/19] use Collection for Axes --- pandas/_typing.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index 93e31ecf4436d..bb429d6636019 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -1,5 +1,15 @@ from pathlib import Path -from typing import IO, TYPE_CHECKING, AnyStr, Iterable, Optional, TypeVar, Union +from typing import ( + IO, + TYPE_CHECKING, + AnyStr, + Collection, + Hashable, + Iterable, + Optional, + TypeVar, + Union, +) import numpy as np @@ -28,4 +38,4 @@ Scalar = Union[str, int, float] Axis = Union[str, int] Ordered = Optional[bool] -Axes = Iterable[Union["Index", Iterable[str]]] +Axes = Iterable[Union["Index", Collection[Hashable]]] From f2edb32d16329d87d6149a76d93fabf4cc1e3115 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Tue, 10 Sep 2019 14:59:31 +0530 Subject: [PATCH 17/19] revert Axes with comment --- pandas/_typing.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index 253ae1f961a0a..4f89e270444bf 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -1,15 +1,5 @@ from pathlib import Path -from typing import ( - IO, - TYPE_CHECKING, - AnyStr, - Collection, - Hashable, - Iterable, - Optional, - TypeVar, - Union, -) +from typing import IO, TYPE_CHECKING, AnyStr, Iterable, Optional, TypeVar, Union import numpy as np @@ -38,7 +28,9 @@ Scalar = Union[str, int, float] Axis = Union[str, int] Ordered = Optional[bool] -Axes = Iterable[Union["Index", Collection[Hashable]]] + +# use Collection after we drop support for py35 +Axes = Iterable[Union["Index", Iterable[str]]] # to maintain type information across generic functions and parametrization _T = TypeVar("_T") From 112f550ccc29427996dadd06777043b1839abab5 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Wed, 11 Sep 2019 14:35:33 +0530 Subject: [PATCH 18/19] Apply suggestions from code review Co-Authored-By: Simon Hawkins --- pandas/core/frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index eb37b0c8867b5..5b5da090e5993 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -393,8 +393,8 @@ def __init__( index: Optional[Axes] = None, columns: Optional[Axes] = None, dtype: Optional[Dtype] = None, - copy: Optional[bool] = False, - ) -> None: + copy: bool = False, + ): if data is None: data = {} if dtype is not None: From d03e33ce4dac43fab00e87fdf348872a672ec693 Mon Sep 17 00:00:00 2001 From: William Ayd Date: Thu, 12 Sep 2019 08:57:26 -0700 Subject: [PATCH 19/19] Update _typing.py --- pandas/_typing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_typing.py b/pandas/_typing.py index 4f89e270444bf..de9fb5b944186 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -30,7 +30,7 @@ Ordered = Optional[bool] # use Collection after we drop support for py35 -Axes = Iterable[Union["Index", Iterable[str]]] +Axes = Iterable # to maintain type information across generic functions and parametrization _T = TypeVar("_T")