From 822f3bd94ba6cd4770ef89fd3ef13913823269b4 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sat, 19 Oct 2024 23:23:10 +0900 Subject: [PATCH] Run pyupgrade to clean up Python 2 syntaxes Update all .py source files by $ pyupgrade --py3-only $(git ls-files | grep ".py$") to modernize the code according to Python 3 syntaxes. Also add the pyupgrade hook to pre-commit to avoid merging additional Python 2 syntaxes. Change-Id: I2adc97da3ef11ee18e30ed92e9ca5992d384fdb1 --- .pre-commit-config.yaml | 14 +++++--- doc/source/conf.py | 1 - oslo_service/eventlet_backdoor.py | 13 ++++---- oslo_service/loopingcall.py | 6 ++-- oslo_service/periodic_task.py | 4 +-- oslo_service/service.py | 46 +++++++++++++------------- oslo_service/systemd.py | 2 +- oslo_service/tests/base.py | 2 +- oslo_service/tests/eventlet_service.py | 1 - oslo_service/tests/test_fixture.py | 2 +- oslo_service/tests/test_loopingcall.py | 4 +-- oslo_service/tests/test_periodic.py | 10 +++--- oslo_service/tests/test_service.py | 24 +++++++------- oslo_service/tests/test_sslutils.py | 2 +- oslo_service/tests/test_systemd.py | 4 +-- oslo_service/tests/test_threadgroup.py | 2 +- oslo_service/tests/test_wsgi.py | 12 +++---- oslo_service/threadgroup.py | 4 +-- oslo_service/wsgi.py | 10 +++--- releasenotes/source/conf.py | 1 - 20 files changed, 83 insertions(+), 81 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b58fbc2..436d44c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: trailing-whitespace # Replaces or checks mixed line ending @@ -19,17 +19,21 @@ repos: - id: check-yaml files: .*\.(yaml|yml)$ - repo: https://opendev.org/openstack/hacking - rev: 6.1.0 + rev: 7.0.0 hooks: - id: hacking additional_dependencies: [] - repo: https://github.com/PyCQA/bandit - rev: 1.7.6 + rev: 1.7.10 hooks: - id: bandit args: ['-x', 'tests'] - repo: https://github.com/PyCQA/doc8 - rev: v1.1.1 + rev: v1.1.2 hooks: - id: doc8 - + - repo: https://github.com/asottile/pyupgrade + rev: v3.18.0 + hooks: + - id: pyupgrade + args: [--py3-only] diff --git a/doc/source/conf.py b/doc/source/conf.py index f0ff4d1c..2fe575ee 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2020 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/oslo_service/eventlet_backdoor.py b/oslo_service/eventlet_backdoor.py index ada9a938..b50c08a1 100644 --- a/oslo_service/eventlet_backdoor.py +++ b/oslo_service/eventlet_backdoor.py @@ -40,7 +40,7 @@ class EventletBackdoorConfigValueError(Exception): msg = (_('Invalid backdoor_port configuration %(range)s: %(ex)s. ' '%(help)s') % {'range': port_range, 'ex': ex, 'help': help_msg}) - super(EventletBackdoorConfigValueError, self).__init__(msg) + super().__init__(msg) self.port_range = port_range @@ -50,7 +50,7 @@ def _dont_use_this(): def _dump_frame(f, frame_chapter): co = f.f_code - print(" %s Frame: %s" % (frame_chapter, co.co_name)) + print(" {} Frame: {}".format(frame_chapter, co.co_name)) print(" File: %s" % (co.co_filename)) print(" Captured at line number: %s" % (f.f_lineno)) co_locals = set(co.co_varnames) @@ -64,7 +64,8 @@ def _dump_frame(f, frame_chapter): if set_locals: print(" %s set local variables:" % (len(set_locals))) for var_name in sorted(set_locals.keys()): - print(" %s => %r" % (var_name, f.f_locals[var_name])) + print(" {} => {!r}".format( + var_name, f.f_locals[var_name])) else: print(" 0 set local variables.") if not_set: @@ -80,7 +81,7 @@ def _dump_frame(f, frame_chapter): def _detailed_dump_frames(f, thread_index): i = 0 while f is not None: - _dump_frame(f, "%s.%s" % (thread_index, i + 1)) + _dump_frame(f, "{}.{}".format(thread_index, i + 1)) f = f.f_back i += 1 @@ -164,7 +165,7 @@ def _listen(host, start_port, end_port): while True: try: return _listen_func(host, try_port) - except socket.error as exc: + except OSError as exc: if (exc.errno != errno.EADDRINUSE or try_port >= end_port): raise @@ -174,7 +175,7 @@ def _listen(host, start_port, end_port): def _try_open_unix_domain_socket(socket_path): try: return eventlet.listen(socket_path, socket.AF_UNIX) - except socket.error as e: + except OSError as e: if e.errno != errno.EADDRINUSE: # NOTE(harlowja): Some other non-address in use error # occurred, since we aren't handling those, re-raise diff --git a/oslo_service/loopingcall.py b/oslo_service/loopingcall.py index 794f0cfd..783c1e5e 100644 --- a/oslo_service/loopingcall.py +++ b/oslo_service/loopingcall.py @@ -76,7 +76,7 @@ def _safe_wrapper(f, kind, func_name): return func -class LoopingCallBase(object): +class LoopingCallBase: _KIND = _("Unknown looping call") _RUN_ONLY_ONE_MESSAGE = _("A looping call can only run one function" @@ -315,7 +315,7 @@ class BackOffLoopingCall(LoopingCallBase): " only run one function at a time") def __init__(self, f=None, *args, **kw): - super(BackOffLoopingCall, self).__init__(f=f, *args, **kw) + super().__init__(f=f, *args, **kw) self._error_time = 0 self._interval = 1 @@ -355,7 +355,7 @@ class BackOffLoopingCall(LoopingCallBase): return self._start(_idle_for, initial_delay=initial_delay) -class RetryDecorator(object): +class RetryDecorator: """Decorator for retrying a function upon suggested exceptions. The decorated function is retried for the given number of times, and the diff --git a/oslo_service/periodic_task.py b/oslo_service/periodic_task.py index 5e284749..212145be 100644 --- a/oslo_service/periodic_task.py +++ b/oslo_service/periodic_task.py @@ -125,7 +125,7 @@ class _PeriodicTasksMeta(type): def __init__(cls, names, bases, dict_): """Metaclass that allows us to collect decorated periodic tasks.""" - super(_PeriodicTasksMeta, cls).__init__(names, bases, dict_) + super().__init__(names, bases, dict_) # NOTE(sirp): if the attribute is not present then we must be the base # class, so, go ahead an initialize it. If the attribute is present, @@ -170,7 +170,7 @@ def _nearest_boundary(last_run, spacing): class PeriodicTasks(metaclass=_PeriodicTasksMeta): def __init__(self, conf): - super(PeriodicTasks, self).__init__() + super().__init__() self.conf = conf self.conf.register_opts(_options.periodic_opts) self._periodic_last_run = {} diff --git a/oslo_service/service.py b/oslo_service/service.py index 416ad59e..25f19dba 100644 --- a/oslo_service/service.py +++ b/oslo_service/service.py @@ -120,7 +120,7 @@ class Singleton(type): def __call__(cls, *args, **kwargs): with lockutils.lock('singleton_lock', semaphores=cls._semaphores): if cls not in cls._instances: - cls._instances[cls] = super(Singleton, cls).__call__( + cls._instances[cls] = super().__call__( *args, **kwargs) return cls._instances[cls] @@ -128,20 +128,20 @@ class Singleton(type): class SignalHandler(metaclass=Singleton): def __init__(self, *args, **kwargs): - super(SignalHandler, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.__setup_signal_interruption() # Map all signal names to signal integer values and create a # reverse mapping (for easier + quick lookup). self._ignore_signals = ('SIG_DFL', 'SIG_IGN') - self._signals_by_name = dict((name, getattr(signal, name)) - for name in dir(signal) - if name.startswith("SIG") and - name not in self._ignore_signals) - self.signals_to_name = dict( - (sigval, name) - for (name, sigval) in self._signals_by_name.items()) + self._signals_by_name = {name: getattr(signal, name) + for name in dir(signal) + if name.startswith("SIG") and + name not in self._ignore_signals} + self.signals_to_name = { + sigval: name + for (name, sigval) in self._signals_by_name.items()} self._signal_handlers = collections.defaultdict(list) self.clear() @@ -193,7 +193,7 @@ class SignalHandler(metaclass=Singleton): interrupted_frame.filename == self.__hub_module_file) or (interrupted_frame.function == 'do_sleep' and interrupted_frame.filename == __file__)): - raise IOError(errno.EINTR, 'Interrupted') + raise OSError(errno.EINTR, 'Interrupted') def __setup_signal_interruption(self): """Set up to do the Right Thing with signals during poll() and sleep(). @@ -227,7 +227,7 @@ class SignalHandler(metaclass=Singleton): def sleep_wrapper(seconds): try: return do_sleep(time_sleep, seconds) - except (IOError, InterruptedError) as err: + except (OSError, InterruptedError) as err: if err.errno != errno.EINTR: raise @@ -244,7 +244,7 @@ class SignalHandler(metaclass=Singleton): return sig_name in self._signals_by_name -class Launcher(object): +class Launcher: """Launch one or more services and wait for them to complete.""" def __init__(self, conf, restart_method='reload'): @@ -311,7 +311,7 @@ class Launcher(object): class SignalExit(SystemExit): def __init__(self, signo, exccode=1): - super(SignalExit, self).__init__(exccode) + super().__init__(exccode) self.signo = signo @@ -323,7 +323,7 @@ class ServiceLauncher(Launcher): :param conf: an instance of ConfigOpts :param restart_method: passed to super """ - super(ServiceLauncher, self).__init__( + super().__init__( conf, restart_method=restart_method) self.signal_handler = SignalHandler() @@ -364,7 +364,7 @@ class ServiceLauncher(Launcher): self.conf.log_opt_values(LOG, logging.DEBUG) try: - super(ServiceLauncher, self).wait() + super().wait() except SignalExit as exc: signame = self.signal_handler.signals_to_name[exc.signo] LOG.info('Caught %s, handling', signame) @@ -391,11 +391,11 @@ class ServiceLauncher(Launcher): break self.restart() - super(ServiceLauncher, self).wait() + super().wait() return status -class ServiceWrapper(object): +class ServiceWrapper: def __init__(self, service, workers): self.service = service self.workers = workers @@ -403,7 +403,7 @@ class ServiceWrapper(object): self.forktimes = [] -class ProcessLauncher(object): +class ProcessLauncher: """Launch a service with a given number of workers.""" def __init__(self, conf, wait_interval=0.01, restart_method='reload'): @@ -672,8 +672,8 @@ class ProcessLauncher(object): elif self.restart_method == 'mutate': self.conf.mutate_config_files() child_signal = signal.SIGHUP - for service in set( - [wrap.service for wrap in self.children.values()]): + for service in { + wrap.service for wrap in self.children.values()}: service.reset() for pid in self.children: @@ -697,8 +697,8 @@ class ProcessLauncher(object): self.running = False LOG.debug("Stop services.") - for service in set( - [wrap.service for wrap in self.children.values()]): + for service in { + wrap.service for wrap in self.children.values()}: service.stop() LOG.debug("Killing children.") @@ -741,7 +741,7 @@ class Service(ServiceBase): self.tg.wait() -class Services(object): +class Services: def __init__(self, restart_method='reload'): if restart_method not in _LAUNCHER_RESTART_METHODS: diff --git a/oslo_service/systemd.py b/oslo_service/systemd.py index ee11dab2..9ac2e9e6 100644 --- a/oslo_service/systemd.py +++ b/oslo_service/systemd.py @@ -43,7 +43,7 @@ def _sd_notify(unset_env, msg): sock.sendall(msg) if unset_env: del os.environ['NOTIFY_SOCKET'] - except EnvironmentError: + except OSError: LOG.debug("Systemd notification failed", exc_info=True) diff --git a/oslo_service/tests/base.py b/oslo_service/tests/base.py index 7a45b63d..8536e102 100644 --- a/oslo_service/tests/base.py +++ b/oslo_service/tests/base.py @@ -23,7 +23,7 @@ from oslo_service import sslutils class ServiceBaseTestCase(test_base.BaseTestCase): def setUp(self): - super(ServiceBaseTestCase, self).setUp() + super().setUp() self.conf_fixture = self.useFixture(config.Config()) self.conf_fixture.register_opts(_options.eventlet_backdoor_opts) self.conf_fixture.register_opts(_options.service_opts) diff --git a/oslo_service/tests/eventlet_service.py b/oslo_service/tests/eventlet_service.py index 2af12cc6..ffd0ddee 100644 --- a/oslo_service/tests/eventlet_service.py +++ b/oslo_service/tests/eventlet_service.py @@ -1,4 +1,3 @@ - # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at diff --git a/oslo_service/tests/test_fixture.py b/oslo_service/tests/test_fixture.py index 6b2670e7..45e1bd37 100644 --- a/oslo_service/tests/test_fixture.py +++ b/oslo_service/tests/test_fixture.py @@ -20,7 +20,7 @@ from oslo_service import loopingcall class FixtureTestCase(test_base.BaseTestCase): def setUp(self): - super(FixtureTestCase, self).setUp() + super().setUp() self.sleepfx = self.useFixture(fixture.SleepFixture()) def test_sleep_fixture(self): diff --git a/oslo_service/tests/test_loopingcall.py b/oslo_service/tests/test_loopingcall.py index c1baccf9..e63e5869 100644 --- a/oslo_service/tests/test_loopingcall.py +++ b/oslo_service/tests/test_loopingcall.py @@ -25,7 +25,7 @@ from oslo_service import loopingcall class LoopingCallTestCase(test_base.BaseTestCase): def setUp(self): - super(LoopingCallTestCase, self).setUp() + super().setUp() self.num_runs = 0 def test_return_true(self): @@ -159,7 +159,7 @@ class LoopingCallTestCase(test_base.BaseTestCase): class DynamicLoopingCallTestCase(test_base.BaseTestCase): def setUp(self): - super(DynamicLoopingCallTestCase, self).setUp() + super().setUp() self.num_runs = 0 def test_return_true(self): diff --git a/oslo_service/tests/test_periodic.py b/oslo_service/tests/test_periodic.py index 2f9e2155..7cd380b9 100644 --- a/oslo_service/tests/test_periodic.py +++ b/oslo_service/tests/test_periodic.py @@ -41,7 +41,7 @@ class PeriodicTasksTestCase(base.ServiceBaseTestCase): # the periodic task decorator class AService(periodic_task.PeriodicTasks): def __init__(self, conf): - super(AService, self).__init__(conf) + super().__init__(conf) self.called = {'doit': 0, 'urg': 0, 'ticks': 0, 'tocks': 0} @periodic_task.periodic_task @@ -134,7 +134,7 @@ class PeriodicTasksTestCase(base.ServiceBaseTestCase): # the periodic task decorator class AService(periodic_task.PeriodicTasks): def __init__(self, conf): - super(AService, self).__init__(conf) + super().__init__(conf) self.called = {'ticks': 0} @periodic_task.periodic_task(spacing=test_spacing) @@ -155,7 +155,7 @@ class PeriodicTasksTestCase(base.ServiceBaseTestCase): class AService(periodic_task.PeriodicTasks): def __init__(self, conf): - super(AService, self).__init__(conf) + super().__init__(conf) self.called = {'urg': 0, } @periodic_task.periodic_task @@ -174,7 +174,7 @@ class PeriodicTasksTestCase(base.ServiceBaseTestCase): def test_name(self): class AService(periodic_task.PeriodicTasks): def __init__(self, conf): - super(AService, self).__init__(conf) + super().__init__(conf) @periodic_task.periodic_task(name='better-name') def tick(self, context): @@ -234,7 +234,7 @@ class ManagerMetaTestCase(base.ServiceBaseTestCase): class ManagerTestCase(base.ServiceBaseTestCase): """Tests the periodic tasks portion of the manager class.""" def setUp(self): - super(ManagerTestCase, self).setUp() + super().setUp() def test_periodic_tasks_with_idle(self): class Manager(periodic_task.PeriodicTasks): diff --git a/oslo_service/tests/test_service.py b/oslo_service/tests/test_service.py index fad33e93..9404d39c 100644 --- a/oslo_service/tests/test_service.py +++ b/oslo_service/tests/test_service.py @@ -52,18 +52,18 @@ class ServiceManagerTestCase(test_base.BaseTestCase): class ServiceWithTimer(service.Service): def __init__(self, ready_event=None): - super(ServiceWithTimer, self).__init__() + super().__init__() self.ready_event = ready_event def start(self): - super(ServiceWithTimer, self).start() + super().start() self.timer_fired = 0 self.tg.add_timer(1, self.timer_expired) def wait(self): if self.ready_event: self.ready_event.set() - super(ServiceWithTimer, self).wait() + super().wait() def timer_expired(self): self.timer_fired = self.timer_fired + 1 @@ -71,7 +71,7 @@ class ServiceWithTimer(service.Service): class ServiceCrashOnStart(ServiceWithTimer): def start(self): - super(ServiceCrashOnStart, self).start() + super().start() raise ValueError @@ -123,7 +123,7 @@ class ServiceTestBase(base.ServiceBaseTestCase): time.sleep(.1) def setUp(self): - super(ServiceTestBase, self).setUp() + super().setUp() # NOTE(markmc): ConfigOpts.log_opt_values() uses CONF.config-file self.conf(args=[], default_config_files=[]) self.addCleanup(self.conf.reset) @@ -335,7 +335,7 @@ class ServiceRestartTest(ServiceTestBase): class _Service(service.Service): def __init__(self): - super(_Service, self).__init__() + super().__init__() self.init = event.Event() self.cleaned_up = False @@ -344,7 +344,7 @@ class _Service(service.Service): def stop(self): self.cleaned_up = True - super(_Service, self).stop() + super().stop() class LauncherTest(base.ServiceBaseTestCase): @@ -418,7 +418,7 @@ class LauncherTest(base.ServiceBaseTestCase): initialize_if_enabled_mock.return_value = None launcher = service.Launcher(self.conf) - class FooService(object): + class FooService: def __init__(self): pass serv = FooService() @@ -552,7 +552,7 @@ class ProcessLauncherTest(base.ServiceBaseTestCase): pipe_mock.return_value = [None, None] launcher = service.ProcessLauncher(self.conf) - class FooService(object): + class FooService: def __init__(self): pass serv = FooService() @@ -593,7 +593,7 @@ class ProcessLauncherTest(base.ServiceBaseTestCase): class GracefulShutdownTestService(service.Service): def __init__(self): - super(GracefulShutdownTestService, self).__init__() + super().__init__() self.finished_task = event.Event() def start(self, sleep_amount): @@ -628,7 +628,7 @@ class ServiceTest(test_base.BaseTestCase): class EventletServerProcessLauncherTest(base.ServiceBaseTestCase): def setUp(self): - super(EventletServerProcessLauncherTest, self).setUp() + super().setUp() self.conf(args=[], default_config_files=[]) self.addCleanup(self.conf.reset) self.workers = 3 @@ -708,5 +708,5 @@ class EventletServerProcessLauncherTest(base.ServiceBaseTestCase): class EventletServerServiceLauncherTest(EventletServerProcessLauncherTest): def setUp(self): - super(EventletServerServiceLauncherTest, self).setUp() + super().setUp() self.workers = 1 diff --git a/oslo_service/tests/test_sslutils.py b/oslo_service/tests/test_sslutils.py index ddc77e5a..cdffd068 100644 --- a/oslo_service/tests/test_sslutils.py +++ b/oslo_service/tests/test_sslutils.py @@ -33,7 +33,7 @@ class SslutilsTestCase(base.ServiceBaseTestCase): """Test cases for sslutils.""" def setUp(self): - super(SslutilsTestCase, self).setUp() + super().setUp() self.cert_file_name = os.path.join(SSL_CERT_DIR, 'certificate.crt') self.key_file_name = os.path.join(SSL_CERT_DIR, 'privatekey.key') self.ca_file_name = os.path.join(SSL_CERT_DIR, 'ca.crt') diff --git a/oslo_service/tests/test_systemd.py b/oslo_service/tests/test_systemd.py index ceddca94..b35ec903 100644 --- a/oslo_service/tests/test_systemd.py +++ b/oslo_service/tests/test_systemd.py @@ -27,14 +27,14 @@ class SystemdTestCase(test_base.BaseTestCase): def test__abstractify(self): sock_name = '@fake_socket' res = systemd._abstractify(sock_name) - self.assertEqual('\0{0}'.format(sock_name[1:]), res) + self.assertEqual('\0{}'.format(sock_name[1:]), res) @mock.patch.object(os, 'getenv', return_value='@fake_socket') def _test__sd_notify(self, getenv_mock, unset_env=False): self.ready = False self.closed = False - class FakeSocket(object): + class FakeSocket: def __init__(self, family, type): pass diff --git a/oslo_service/tests/test_threadgroup.py b/oslo_service/tests/test_threadgroup.py index 81ca9d40..47c121fb 100644 --- a/oslo_service/tests/test_threadgroup.py +++ b/oslo_service/tests/test_threadgroup.py @@ -29,7 +29,7 @@ from oslo_service import threadgroup class ThreadGroupTestCase(test_base.BaseTestCase): """Test cases for thread group.""" def setUp(self): - super(ThreadGroupTestCase, self).setUp() + super().setUp() self.tg = threadgroup.ThreadGroup() self.addCleanup(self.tg.stop) diff --git a/oslo_service/tests/test_wsgi.py b/oslo_service/tests/test_wsgi.py index 80d3043a..923e31f6 100644 --- a/oslo_service/tests/test_wsgi.py +++ b/oslo_service/tests/test_wsgi.py @@ -45,7 +45,7 @@ class WsgiTestCase(base.ServiceBaseTestCase): """Base class for WSGI tests.""" def setUp(self): - super(WsgiTestCase, self).setUp() + super().setUp() self.conf(args=[], default_config_files=[]) @@ -53,7 +53,7 @@ class TestLoaderNothingExists(WsgiTestCase): """Loader tests where os.path.exists always returns False.""" def setUp(self): - super(TestLoaderNothingExists, self).setUp() + super().setUp() mock_patcher = mock.patch.object(os.path, 'exists', lambda _: False) mock_patcher.start() @@ -86,7 +86,7 @@ document_root = /tmp """ def setUp(self): - super(TestLoaderNormalFilesystem, self).setUp() + super().setUp() self.paste_config = tempfile.NamedTemporaryFile(mode="w+t") self.paste_config.write(self._paste_config.lstrip()) self.paste_config.seek(0) @@ -111,14 +111,14 @@ document_root = /tmp def tearDown(self): self.paste_config.close() - super(TestLoaderNormalFilesystem, self).tearDown() + super().tearDown() class TestWSGIServer(WsgiTestCase): """WSGI server tests.""" def setUp(self): - super(TestWSGIServer, self).setUp() + super().setUp() def test_no_app(self): server = wsgi.Server(self.conf, "test_app", None) @@ -287,7 +287,7 @@ class TestWSGIServerWithSSL(WsgiTestCase): """WSGI server with SSL tests.""" def setUp(self): - super(TestWSGIServerWithSSL, self).setUp() + super().setUp() cert_file_name = os.path.join(SSL_CERT_DIR, 'certificate.crt') key_file_name = os.path.join(SSL_CERT_DIR, 'privatekey.key') eventlet.monkey_patch(os=False, thread=False) diff --git a/oslo_service/threadgroup.py b/oslo_service/threadgroup.py index 51a0711c..f12244e4 100644 --- a/oslo_service/threadgroup.py +++ b/oslo_service/threadgroup.py @@ -35,7 +35,7 @@ def _on_thread_done(_greenthread, group, thread): group.thread_done(thread) -class Thread(object): +class Thread: """Wrapper around a greenthread. Holds a reference to the :class:`ThreadGroup`. The Thread will notify @@ -72,7 +72,7 @@ class Thread(object): self.thread.cancel(*throw_args) -class ThreadGroup(object): +class ThreadGroup: """A group of greenthreads and timers. The point of the ThreadGroup class is to: diff --git a/oslo_service/wsgi.py b/oslo_service/wsgi.py index 8b518bd2..63235ed3 100644 --- a/oslo_service/wsgi.py +++ b/oslo_service/wsgi.py @@ -139,7 +139,7 @@ class Server(service.ServiceBase): try: sock = eventlet.listen(bind_addr, family, backlog=backlog) - except EnvironmentError: + except OSError: LOG.error("Could not bind to %(host)s:%(port)s", {'host': host, 'port': port}) raise @@ -245,7 +245,7 @@ class Request(webob.Request): pass -class Router(object): +class Router: """WSGI middleware that maps incoming requests to WSGI apps.""" def __init__(self, mapper): @@ -305,17 +305,17 @@ class Router(object): class ConfigNotFound(Exception): def __init__(self, path): msg = _('Could not find config at %(path)s') % {'path': path} - super(ConfigNotFound, self).__init__(msg) + super().__init__(msg) class PasteAppNotFound(Exception): def __init__(self, name, path): msg = (_("Could not load paste app '%(name)s' from %(path)s") % {'name': name, 'path': path}) - super(PasteAppNotFound, self).__init__(msg) + super().__init__(msg) -class Loader(object): +class Loader: """Used to load WSGI applications from paste configurations.""" def __init__(self, conf): diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index da135d3e..b773e170 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2020 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License");