Skip to content

BUG: remove tab completion for deprecated functions #17683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pandas/core/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

class DirNamesMixin(object):
_accessors = frozenset([])
_deprecations = frozenset([])

def _dir_deletions(self):
""" delete unwanted __dir__ for this object """
return self._accessors
return self._accessors | self._deprecations

def _dir_additions(self):
""" add addtional __dir__ for this object """
Expand Down
8 changes: 1 addition & 7 deletions pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class Categorical(PandasObject):
# ops, which raise
__array_priority__ = 1000
_dtype = CategoricalDtype()
_deprecations = frozenset(['labels'])
_typ = 'categorical'

def __init__(self, values, categories=None, ordered=None, dtype=None,
Expand Down Expand Up @@ -412,13 +413,6 @@ def dtype(self):
"""The :ref:`~pandas.api.types.CategoricalDtype` for this instance"""
return self._dtype

def __dir__(self):
# Avoid IPython warnings for deprecated properties
# https://github.com/pandas-dev/pandas/issues/16409
rv = set(dir(type(self)))
rv.discard("labels")
return sorted(rv)

@property
def _constructor(self):
return Categorical
Expand Down
1 change: 1 addition & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ def _constructor(self):
return DataFrame

_constructor_sliced = Series
_deprecations = NDFrame._deprecations | frozenset(['sortlevel'])

@property
def _constructor_expanddim(self):
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class NDFrame(PandasObject, SelectionMixin):
'__array_interface__']
_internal_names_set = set(_internal_names)
_accessors = frozenset([])
_deprecations = frozenset(['as_blocks', 'blocks',
'consolidate', 'convert_objects'])
_metadata = []
is_copy = None

Expand Down
2 changes: 2 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
"""
_metadata = ['name']
_accessors = frozenset(['dt', 'cat', 'str'])
_deprecations = generic.NDFrame._deprecations | frozenset(
['sortlevel', 'reshape'])
_allow_index_ops = True

def __init__(self, data=None, index=None, dtype=None, name=None,
Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,14 @@ def _check_f(base, f):
# rename
f = lambda x: x.rename({1: 'foo'}, inplace=True)
_check_f(d.copy(), f)

def test_tab_complete_warning(self, ip):
# https://github.com/pandas-dev/pandas/issues/16409
pytest.importorskip('IPython', minversion="6.0.0")
from IPython.core.completer import provisionalcompleter

code = "import pandas as pd; df = pd.DataFrame()"
ip.run_code(code)
with tm.assert_produces_warning(None):
with provisionalcompleter('ignore'):
list(ip.Completer.completions('df.', 1))
11 changes: 11 additions & 0 deletions pandas/tests/series/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,14 @@ def test_empty_method(self):

for full_series in [pd.Series([1]), pd.Series(index=[1])]:
assert not full_series.empty

def test_tab_complete_warning(self, ip):
# https://github.com/pandas-dev/pandas/issues/16409
pytest.importorskip('IPython', minversion="6.0.0")
from IPython.core.completer import provisionalcompleter

code = "import pandas as pd; s = pd.Series()"
ip.run_code(code)
with tm.assert_produces_warning(None):
with provisionalcompleter('ignore'):
list(ip.Completer.completions('s.', 1))