diff --git a/pandas/core/base.py b/pandas/core/base.py index 40ff0640a5bc4..0685ce5c92815 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -4,7 +4,7 @@ import builtins import textwrap -from typing import Dict, FrozenSet, List, Optional, Union +from typing import Any, Dict, FrozenSet, List, Optional, Union import numpy as np @@ -49,6 +49,8 @@ class PandasObject(DirNamesMixin): Baseclass for various pandas objects. """ + _cache: Dict[str, Any] + @property def _constructor(self): """ @@ -63,7 +65,7 @@ def __repr__(self) -> str: # Should be overwritten by base classes return object.__repr__(self) - def _reset_cache(self, key=None): + def _reset_cache(self, key: Optional[str] = None) -> None: """ Reset cached properties. If ``key`` is passed, only clears that key. """ diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 31966489403f4..d73c5de0253e8 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1,7 +1,7 @@ from datetime import datetime import operator from textwrap import dedent -from typing import TYPE_CHECKING, Any, Dict, FrozenSet, Hashable, Union +from typing import TYPE_CHECKING, Any, FrozenSet, Hashable, Union import warnings import numpy as np @@ -250,7 +250,6 @@ def _outer_indexer(self, left, right): _typ = "index" _data: Union[ExtensionArray, np.ndarray] - _cache: Dict[str, Any] _id = None _name: Label = None # MultiIndex.levels previously allowed setting the index name. We