Skip to content
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

BUG: fix tab completion #37173

Merged
merged 4 commits into from Oct 26, 2020
Merged

BUG: fix tab completion #37173

merged 4 commits into from Oct 26, 2020

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Oct 16, 2020

Currently tab completion doesn't work on attributes defined on the instance, only ones defined on the class. This fixes that.

Example:

>>> class MyCls(pd.core.accessor.DirNamesMixin):
...     x = 1
... 
...     def __init__(self):
...         self.y = 2
...
>>> x = MyCls()
>>> "x" in dir(x)
True  # master and this PR
>>> "y" in dir(x)
False  # master
True  # this PR

Also some type fixups.

@jbrockmendel
Copy link
Member

LGTM pending green

@jreback jreback added Groupby Output-Formatting __repr__ of pandas objects, to_string labels Oct 16, 2020
@jreback
Copy link
Contributor

jreback commented Oct 16, 2020

I suppose worth a whatsnew note

@topper-123 topper-123 marked this pull request as ready for review October 17, 2020 07:23
@topper-123 topper-123 changed the title BUG/DRAFT: fix tab completion BUG: fix tab completion Oct 17, 2020
@topper-123
Copy link
Contributor Author

Updated. I´ve renamed _deprecations to _hidden_attribs, because being deprecated and hidden may be two different things.

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, one tangential question.

_hidden_attrs = PandasObject._hidden_attrs | {
"as_index",
"axis",
"dropna",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want these to be hidden? Okay with keeping the same behavior as master in this PR, but maybe an issue should be opened.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. From a user perspective, I think it's ok to hide them (helps users focus on groupby methods), but I also think there are situation where we want them to be visible (when developing, advanced use cases).

Maybe store them as not-hidden internal attributes (_as_index etc)?

@@ -489,6 +489,21 @@ def group_selection_context(groupby: "BaseGroupBy") -> Iterator["BaseGroupBy"]:
class BaseGroupBy(PandasObject, SelectionMixin, Generic[FrameOrSeries]):
_group_selection: Optional[IndexLabel] = None
_apply_allowlist: FrozenSet[str] = frozenset()
_hidden_attrs = PandasObject._hidden_attrs | {
"as_index",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah can you differentiate between deprecations that we are hiding and attributes that we are hing for another reason (e.g. these are private)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be deprecated attributes, that should not be hidden and vica versa. Also the deprecation log is in #30228, if we want to list deprecated attributes.

IMO it's ok to keep the concepts of hidden and deprecated attributes seperate.

@jreback jreback added this to the 1.2 milestone Oct 26, 2020
@jreback jreback merged commit 91a2711 into pandas-dev:master Oct 26, 2020
@jreback
Copy link
Contributor

jreback commented Oct 26, 2020

thanks @topper-123

@topper-123 topper-123 deleted the DirNameMixIn branch October 26, 2020 13:27
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Groupby Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants