From a981861bf197f5123ea77c3020f7f7c7ca224e6e Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Mon, 26 Nov 2018 19:24:30 -0500 Subject: [PATCH] Use python 3 super --- README.rst | 2 +- docs/api.rst | 6 +++--- examples.py | 2 +- sprockets/http/app.py | 6 +++--- sprockets/http/mixins.py | 6 +++--- tests.py | 20 ++++++++++---------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.rst b/README.rst index 74c55c1..722b2d7 100644 --- a/README.rst +++ b/README.rst @@ -54,7 +54,7 @@ class instead of writing a ``make_app`` function: handlers = [ # insert your handlers ] - super(Application, self).__init__(handlers, *args, **kwargs) + super().__init__(handlers, *args, **kwargs) if __name__ == '__main__': sprockets.http.run(Application) diff --git a/docs/api.rst b/docs/api.rst index d6c895d..65bccf9 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -43,7 +43,7 @@ when the application starts. handlers = [ # insert your handlers here ] - super(Application, self).__init__(handlers, *args, **kwargs) + super().__init__(handlers, *args, **kwargs) self.ready_to_serve = locks.Event() self.ready_to_serve.clear() self.on_start_callbacks.append(self._connect_to_database) @@ -72,7 +72,7 @@ the event: class StatusHandler(web.RequestHandler): @gen.coroutine def prepare(self): - maybe_future = super(StatusHandler, self).prepare() + maybe_future = super().prepare() if concurrent.is_future(maybe_future): yield maybe_future if not self._finished and not self.application.ready_to_serve.is_set(): @@ -144,7 +144,7 @@ written the following instead: class MyHandler(web.RequestHandler): def initialize(self): - super(MyHandler, self).initialize() + super().initialize() self.logger = logging.getLogger('MyHandler') def get(self): diff --git a/examples.py b/examples.py index 984b710..306c288 100644 --- a/examples.py +++ b/examples.py @@ -31,7 +31,7 @@ class Application(app.Application): def __init__(self, **kwargs): kwargs['debug'] = True - super(Application, self).__init__( + super().__init__( [web.url(r'/status/(?P\d+)', StatusHandler)], **kwargs) diff --git a/sprockets/http/app.py b/sprockets/http/app.py index 59fc56c..ef42a03 100644 --- a/sprockets/http/app.py +++ b/sprockets/http/app.py @@ -76,7 +76,7 @@ class CallbackManager: def __init__(self, tornado_application, *args, **kwargs): self.runner_callbacks = kwargs.pop('runner_callbacks', {}) - super(CallbackManager, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._tornado_application = tornado_application self.logger = logging.getLogger(self.__class__.__name__) @@ -199,7 +199,7 @@ class Application(CallbackManager, web.Application): """ def __init__(self, *args, **kwargs): - super(Application, self).__init__(self, *args, **kwargs) + super().__init__(self, *args, **kwargs) class _ApplicationAdapter(CallbackManager): @@ -220,7 +220,7 @@ class _ApplicationAdapter(CallbackManager): def __init__(self, application): self._application = application self.settings = self._application.settings - super(_ApplicationAdapter, self).__init__( + super().__init__( self._application, runner_callbacks=getattr(application, 'runner_callbacks', {})) setattr(self._application, 'runner_callbacks', self.runner_callbacks) diff --git a/sprockets/http/mixins.py b/sprockets/http/mixins.py index b51a889..f916f75 100644 --- a/sprockets/http/mixins.py +++ b/sprockets/http/mixins.py @@ -32,7 +32,7 @@ class LoggingHandler: """ def initialize(self): - super(LoggingHandler, self).initialize() + super().initialize() if not hasattr(self, 'logger'): self.logger = logging.getLogger(self.__class__.__name__) @@ -58,7 +58,7 @@ class ErrorLogger(LoggingHandler): else: # Oh, and make non-standard HTTP status codes NOT explode! kwargs['reason'] = _get_http_reason(status_code) - super(ErrorLogger, self).send_error(status_code, **kwargs) + super().send_error(status_code, **kwargs) def write_error(self, status_code, **kwargs): log_function = self.logger.debug @@ -71,7 +71,7 @@ class ErrorLogger(LoggingHandler): log_function('%s %s failed with %s: %s', self.request.method, self.request.uri, status_code, kwargs.get('log_message', kwargs['reason'])) - super(ErrorLogger, self).write_error(status_code, **kwargs) + super().write_error(status_code, **kwargs) class ErrorWriter: diff --git a/tests.py b/tests.py index f078294..a451a45 100644 --- a/tests.py +++ b/tests.py @@ -18,7 +18,7 @@ import examples class RecordingHandler(logging.Handler): def __init__(self): - super(RecordingHandler, self).__init__() + super().__init__() self.emitted = [] def emit(self, record): @@ -37,11 +37,11 @@ class RaisingHandler(sprockets.http.mixins.ErrorLogger, class MockHelper(unittest.TestCase): def setUp(self): - super(MockHelper, self).setUp() + super().setUp() self._mocks = [] def tearDown(self): - super(MockHelper, self).tearDown() + super().tearDown() for mocker in self._mocks: mocker.stop() del self._mocks[:] @@ -69,13 +69,13 @@ def override_environment_variable(name, value): class ErrorLoggerTests(testing.AsyncHTTPTestCase): def setUp(self): - super(ErrorLoggerTests, self).setUp() + super().setUp() self.recorder = RecordingHandler() root_logger = logging.getLogger() root_logger.addHandler(self.recorder) def tearDown(self): - super(ErrorLoggerTests, self).tearDown() + super().tearDown() logging.getLogger().removeHandler(self.recorder) def get_app(self): @@ -129,7 +129,7 @@ class ErrorWriterTests(testing.AsyncHTTPTestCase): def setUp(self): self._application = None - super(ErrorWriterTests, self).setUp() + super().setUp() @property def application(self): @@ -219,7 +219,7 @@ class ErrorWriterTests(testing.AsyncHTTPTestCase): class RunTests(MockHelper, unittest.TestCase): def setUp(self): - super(RunTests, self).setUp() + super().setUp() self.runner_cls = self.start_mock('sprockets.http.runner.Runner') self.get_logging_config = self.start_mock( 'sprockets.http._get_logging_config') @@ -293,7 +293,7 @@ class RunTests(MockHelper, unittest.TestCase): class CallbackTests(MockHelper, unittest.TestCase): def setUp(self): - super(CallbackTests, self).setUp() + super().setUp() self.shutdown_callback = mock.Mock() self.before_run_callback = mock.Mock() self.application = self.make_application() @@ -361,7 +361,7 @@ class CallbackTests(MockHelper, unittest.TestCase): class RunnerTests(MockHelper, unittest.TestCase): def setUp(self): - super(RunnerTests, self).setUp() + super().setUp() self.application = mock.Mock() self.application.settings = { 'xheaders': True, @@ -498,7 +498,7 @@ class AsyncRunTests(unittest.TestCase): class RunCommandTests(MockHelper, unittest.TestCase): def setUp(self): - super(RunCommandTests, self).setUp() + super().setUp() self.distribution = mock.Mock(spec=distutils.dist.Distribution, verbose=3)