From 8769366d9cbee0702c9d4740d75cc0d6624592db Mon Sep 17 00:00:00 2001 From: tp Date: Sat, 15 Jun 2019 20:24:43 +0200 Subject: [PATCH] Add type hints for (NDFrame|Series)._data --- pandas/core/generic.py | 12 +++++++++--- pandas/core/series.py | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 903fd7ffe706a..463659ca8ea44 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6,7 +6,7 @@ import operator import pickle from textwrap import dedent -from typing import Callable, FrozenSet, List, Set +from typing import Callable, FrozenSet, List, Optional, Set import warnings import weakref @@ -35,6 +35,7 @@ from pandas.core.dtypes.missing import isna, notna import pandas as pd +from pandas._typing import Dtype from pandas.core import missing, nanops import pandas.core.algorithms as algos from pandas.core.base import PandasObject, SelectionMixin @@ -118,12 +119,17 @@ class NDFrame(PandasObject, SelectionMixin): ]) # type: FrozenSet[str] _metadata = [] # type: List[str] _is_copy = None + _data = None # type: BlockManager # ---------------------------------------------------------------------- # Constructors - def __init__(self, data, axes=None, copy=False, dtype=None, - fastpath=False): + def __init__(self, + data: BlockManager, + axes: Optional[List[Index]] = None, + copy: bool = False, + dtype: Optional[Dtype] = None, + fastpath: bool = False): if not fastpath: if dtype is not None: diff --git a/pandas/core/series.py b/pandas/core/series.py index f0362596920a6..eaef1f525f3e4 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -142,6 +142,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame): # Override cache_readonly bc Series is mutable hasnans = property(base.IndexOpsMixin.hasnans.func, doc=base.IndexOpsMixin.hasnans.__doc__) + _data = None # type: SingleBlockManager # ---------------------------------------------------------------------- # Constructors