Use python 3 super

This commit is contained in:
Andrew Rabert 2018-11-26 19:24:30 -05:00
parent 11bc7079c0
commit a981861bf1
6 changed files with 21 additions and 21 deletions

View file

@ -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)

View file

@ -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):

View file

@ -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<status_code>\d+)', StatusHandler)],
**kwargs)

View file

@ -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)

View file

@ -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:

View file

@ -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)