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

Update super usage #5806

Merged
merged 1 commit into from Oct 13, 2020
Merged

Update super usage #5806

merged 1 commit into from Oct 13, 2020

Conversation

rahulporuri
Copy link
Contributor

This commit updates the super usage. Because Python 2 is not supported anymore, super usage can be updated such that super is called without any arguments in the default case where super is called with the class name and self e.g. super(NotebookApp, self) called within class NotebookApp(...):.

The changes in this PR were done using automated regex-based search and replace. The regex used was - (super)+\(+(\w+)(,)+\s(self)+\)+. After the automated search and replace happened, each change was checked individually before being staged in git.

Note that all usage of super has not been updated - a few cases which smelled funny have been ignored. The two uses of super that smelled funny can be found below

diff --git a/notebook/base/zmqhandlers.py b/notebook/base/zmqhandlers.py
index dc3a7b69e..7b002c960 100644
--- a/notebook/base/zmqhandlers.py
+++ b/notebook/base/zmqhandlers.py
@@ -165,7 +165,7 @@ class WebSocketMixin(object):
                 self.send_ping, self.ping_interval,
             )
             self.ping_callback.start()
-        return super(WebSocketMixin, self).open(*args, **kwargs)
+        return super().open(*args, **kwargs)

     def send_ping(self):
         """send a ping to keep the websocket alive"""
@@ -201,7 +201,7 @@ class ZMQStreamHandler(WebSocketMixin, WebSocketHandler):
         """Backport send_error from tornado 4.1 to 4.0"""
         def send_error(self, *args, **kwargs):
             if self.stream is None:
-                super(WebSocketHandler, self).send_error(*args, **kwargs)
+                super().send_error(*args, **kwargs)
             else:
                 # If we get an uncaught exception during the handshake,
                 # we have no choice but to abruptly close the connection.

This commit updates the super usage. Because Python 2 is not supported
anymore, super usage can be updated such that super is called without
any arguments in the default case where super is called with the class
name and self.

Note that all usage of super has not been updated - a few cases which
smelled funny have been ignored.
Copy link
Member

@kevin-bates kevin-bates left a comment

Choose a reason for hiding this comment

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

These changes look good. Thank you for the great write-up. I agree with your assessment and approach for the two areas that were left unchanged.

@kevin-bates kevin-bates merged commit 18e4834 into jupyter:master Oct 13, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants