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

CLN: Clean uses of super, part II #26230

Closed
wants to merge 1 commit into from

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Apr 28, 2019

Continuation from #26177. In addition to the uses of super dealt with in #26177, there were some more advanced uses of super in the code base, e.g. in classmethods and using super to jump to a specific point in the MRO-chain.

This PR specifically deals with:

  • super(..., self) in pyx-files
  • super(..., cls) in the whole code base
  • Changes some specific uses of super, se comments .

@pep8speaks
Copy link

pep8speaks commented Apr 28, 2019

Hello @topper-123! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-04-28 07:40:11 UTC

@@ -983,7 +983,7 @@ default 'raise'
return create_timestamp_from_ts(value, dts, _tzinfo, self.freq)

def isoformat(self, sep='T'):
base = super(_Timestamp, self).isoformat(sep=sep)
base = super().isoformat(sep=sep)
Copy link
Contributor Author

@topper-123 topper-123 Apr 28, 2019

Choose a reason for hiding this comment

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

This changes the first parameter in super to implivitly be TimeStamp rather than _Timestamp, which is ok in this case.

# We want PandasObject.__repr__, which dispatches to __unicode__
return super(ExtensionArray, self).__repr__()
# We want to bypass ExtensionArray.__repr__.
return str(self)
Copy link
Contributor Author

@topper-123 topper-123 Apr 28, 2019

Choose a reason for hiding this comment

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

This ends up in both master and this PR to call self.__unicode__. __unicode__ isn't needed anymore so should be cleaned up in a future PR.

@@ -6330,8 +6330,7 @@ def _aggregate(self, arg, axis=0, *args, **kwargs):
if axis == 1:
# NDFrame.aggregate returns a tuple, and we need to transpose
# only result
result, how = (super(DataFrame, self.T)
._aggregate(arg, *args, **kwargs))
result, how = self.T._aggregate(arg, *args, axis=0, **kwargs)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is clearer to read than the super version.

@@ -6342,7 +6341,7 @@ def _aggregate(self, arg, axis=0, *args, **kwargs):
def transform(self, func, axis=0, *args, **kwargs):
axis = self._get_axis_number(axis)
if axis == 1:
return super(DataFrame, self.T).transform(func, *args, **kwargs).T
return self.T.transform(func, *args, axis=0, **kwargs).T
return super().transform(func, *args, **kwargs)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is clearer to read than the super version.

@topper-123 topper-123 closed this Apr 28, 2019
@topper-123 topper-123 deleted the clean_super_II branch May 1, 2019 20:03
@topper-123 topper-123 restored the clean_super_II branch May 1, 2019 20:05
@topper-123 topper-123 deleted the clean_super_II branch May 1, 2019 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants