Skip to content

Commit

Permalink
CLN: Clean DirNameMixin (#28957)
Browse files Browse the repository at this point in the history
  • Loading branch information
topper-123 authored and WillAyd committed Oct 16, 2019
1 parent fdc322a commit b63f829
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
6 changes: 2 additions & 4 deletions pandas/core/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
that can be mixed into or pinned onto other pandas classes.
"""
from typing import Set
from typing import FrozenSet, Set
import warnings

from pandas.util._decorators import Appender


class DirNamesMixin:
_accessors = set() # type: Set[str]
_deprecations = frozenset(
["asobject", "base", "data", "flags", "itemsize", "strides"]
)
_deprecations = frozenset() # type: FrozenSet[str]

def _dir_deletions(self):
"""
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ class Categorical(ExtensionArray, PandasObject):
__array_priority__ = 1000
_dtype = CategoricalDtype(ordered=False)
# tolist is not actually deprecated, just suppressed in the __dir__
_deprecations = PandasObject._deprecations | frozenset(["tolist", "get_values"])
_deprecations = PandasObject._deprecations | frozenset(
["tolist", "itemsize", "get_values"]
)
_typ = "categorical"

def __init__(
Expand Down
14 changes: 12 additions & 2 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import builtins
from collections import OrderedDict
import textwrap
from typing import Dict, Optional
from typing import Dict, FrozenSet, Optional
import warnings

import numpy as np
Expand Down Expand Up @@ -651,7 +651,17 @@ class IndexOpsMixin:

# ndarray compatibility
__array_priority__ = 1000
_deprecations = frozenset(["item"])
_deprecations = frozenset(
[
"tolist", # tolist is not deprecated, just suppressed in the __dir__
"base",
"data",
"item",
"itemsize",
"flags",
"strides",
]
) # type: FrozenSet[str]

def transpose(self, *args, **kwargs):
"""
Expand Down
12 changes: 6 additions & 6 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime
import operator
from textwrap import dedent
from typing import Union
from typing import FrozenSet, Union
import warnings

import numpy as np
Expand Down Expand Up @@ -63,7 +63,7 @@
from pandas.core.dtypes.missing import array_equivalent, isna

from pandas.core import ops
from pandas.core.accessor import CachedAccessor, DirNamesMixin
from pandas.core.accessor import CachedAccessor
import pandas.core.algorithms as algos
from pandas.core.arrays import ExtensionArray
from pandas.core.base import IndexOpsMixin, PandasObject
Expand Down Expand Up @@ -206,10 +206,10 @@ class Index(IndexOpsMixin, PandasObject):

# tolist is not actually deprecated, just suppressed in the __dir__
_deprecations = (
IndexOpsMixin._deprecations
| DirNamesMixin._deprecations
| frozenset(["tolist", "contains", "dtype_str", "get_values", "set_value"])
)
PandasObject._deprecations
| IndexOpsMixin._deprecations
| frozenset(["asobject", "contains", "dtype_str", "get_values", "set_value"])
) # type: FrozenSet[str]

# To hand over control to subclasses
_join_precedence = 1
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

import pandas as pd
from pandas.core import algorithms, base, generic, nanops, ops
from pandas.core.accessor import CachedAccessor, DirNamesMixin
from pandas.core.accessor import CachedAccessor
from pandas.core.arrays import ExtensionArray
from pandas.core.arrays.categorical import Categorical, CategoricalAccessor
from pandas.core.arrays.sparse import SparseAccessor
Expand Down Expand Up @@ -178,10 +178,8 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
_deprecations = (
base.IndexOpsMixin._deprecations
| generic.NDFrame._deprecations
| DirNamesMixin._deprecations
| frozenset(
[
"tolist", # tolist is not deprecated, just suppressed in the __dir__
"asobject",
"compress",
"valid",
Expand Down

0 comments on commit b63f829

Please sign in to comment.