Skip to content

Commit b63f829

Browse files
topper-123WillAyd
authored andcommitted
CLN: Clean DirNameMixin (pandas-dev#28957)
1 parent fdc322a commit b63f829

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

pandas/core/accessor.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
that can be mixed into or pinned onto other pandas classes.
55
66
"""
7-
from typing import Set
7+
from typing import FrozenSet, Set
88
import warnings
99

1010
from pandas.util._decorators import Appender
1111

1212

1313
class DirNamesMixin:
1414
_accessors = set() # type: Set[str]
15-
_deprecations = frozenset(
16-
["asobject", "base", "data", "flags", "itemsize", "strides"]
17-
)
15+
_deprecations = frozenset() # type: FrozenSet[str]
1816

1917
def _dir_deletions(self):
2018
"""

pandas/core/arrays/categorical.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ class Categorical(ExtensionArray, PandasObject):
331331
__array_priority__ = 1000
332332
_dtype = CategoricalDtype(ordered=False)
333333
# tolist is not actually deprecated, just suppressed in the __dir__
334-
_deprecations = PandasObject._deprecations | frozenset(["tolist", "get_values"])
334+
_deprecations = PandasObject._deprecations | frozenset(
335+
["tolist", "itemsize", "get_values"]
336+
)
335337
_typ = "categorical"
336338

337339
def __init__(

pandas/core/base.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import builtins
55
from collections import OrderedDict
66
import textwrap
7-
from typing import Dict, Optional
7+
from typing import Dict, FrozenSet, Optional
88
import warnings
99

1010
import numpy as np
@@ -651,7 +651,17 @@ class IndexOpsMixin:
651651

652652
# ndarray compatibility
653653
__array_priority__ = 1000
654-
_deprecations = frozenset(["item"])
654+
_deprecations = frozenset(
655+
[
656+
"tolist", # tolist is not deprecated, just suppressed in the __dir__
657+
"base",
658+
"data",
659+
"item",
660+
"itemsize",
661+
"flags",
662+
"strides",
663+
]
664+
) # type: FrozenSet[str]
655665

656666
def transpose(self, *args, **kwargs):
657667
"""

pandas/core/indexes/base.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import datetime
22
import operator
33
from textwrap import dedent
4-
from typing import Union
4+
from typing import FrozenSet, Union
55
import warnings
66

77
import numpy as np
@@ -63,7 +63,7 @@
6363
from pandas.core.dtypes.missing import array_equivalent, isna
6464

6565
from pandas.core import ops
66-
from pandas.core.accessor import CachedAccessor, DirNamesMixin
66+
from pandas.core.accessor import CachedAccessor
6767
import pandas.core.algorithms as algos
6868
from pandas.core.arrays import ExtensionArray
6969
from pandas.core.base import IndexOpsMixin, PandasObject
@@ -206,10 +206,10 @@ class Index(IndexOpsMixin, PandasObject):
206206

207207
# tolist is not actually deprecated, just suppressed in the __dir__
208208
_deprecations = (
209-
IndexOpsMixin._deprecations
210-
| DirNamesMixin._deprecations
211-
| frozenset(["tolist", "contains", "dtype_str", "get_values", "set_value"])
212-
)
209+
PandasObject._deprecations
210+
| IndexOpsMixin._deprecations
211+
| frozenset(["asobject", "contains", "dtype_str", "get_values", "set_value"])
212+
) # type: FrozenSet[str]
213213

214214
# To hand over control to subclasses
215215
_join_precedence = 1

pandas/core/series.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
import pandas as pd
5656
from pandas.core import algorithms, base, generic, nanops, ops
57-
from pandas.core.accessor import CachedAccessor, DirNamesMixin
57+
from pandas.core.accessor import CachedAccessor
5858
from pandas.core.arrays import ExtensionArray
5959
from pandas.core.arrays.categorical import Categorical, CategoricalAccessor
6060
from pandas.core.arrays.sparse import SparseAccessor
@@ -178,10 +178,8 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
178178
_deprecations = (
179179
base.IndexOpsMixin._deprecations
180180
| generic.NDFrame._deprecations
181-
| DirNamesMixin._deprecations
182181
| frozenset(
183182
[
184-
"tolist", # tolist is not deprecated, just suppressed in the __dir__
185183
"asobject",
186184
"compress",
187185
"valid",

0 commit comments

Comments
 (0)