Merge "Run pyupgrade to clean up Python 2 syntaxes"
This commit is contained in:
commit
a9c03bdf1e
@ -28,3 +28,8 @@ repos:
|
||||
hooks:
|
||||
- id: bandit
|
||||
args: ['-x', 'tests,tools']
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.18.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py3-only]
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2020 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# Copyright 2013 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
|
@ -49,7 +49,7 @@ class RpcContext(rpc_common.CommonRpcContext):
|
||||
def __init__(self, **kwargs):
|
||||
self.msg_id = kwargs.pop('msg_id', None)
|
||||
self.reply_q = kwargs.pop('reply_q', None)
|
||||
super(RpcContext, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def deepcopy(self):
|
||||
values = self.to_dict()
|
||||
@ -91,7 +91,7 @@ def pack_context(msg, context):
|
||||
for (key, value) in context_d)
|
||||
|
||||
|
||||
class _MsgIdCache(object):
|
||||
class _MsgIdCache:
|
||||
"""This class checks any duplicate messages."""
|
||||
|
||||
# NOTE: This value is considered can be a configuration item, but
|
||||
|
@ -68,7 +68,7 @@ def keyify(address, service=SERVICE_RPC):
|
||||
return "String:{%s}" % address
|
||||
|
||||
|
||||
class Addresser(object):
|
||||
class Addresser:
|
||||
"""Base class message bus address generator. Used to convert an
|
||||
oslo.messaging address into an AMQP 1.0 address string used over the
|
||||
connection to the message bus.
|
||||
@ -118,7 +118,7 @@ class LegacyAddresser(Addresser):
|
||||
"""
|
||||
def __init__(self, default_exchange, server_prefix, broadcast_prefix,
|
||||
group_prefix, vhost):
|
||||
super(LegacyAddresser, self).__init__(default_exchange)
|
||||
super().__init__(default_exchange)
|
||||
self._server_prefix = server_prefix
|
||||
self._broadcast_prefix = broadcast_prefix
|
||||
self._group_prefix = group_prefix
|
||||
@ -181,7 +181,7 @@ class RoutableAddresser(Addresser):
|
||||
def __init__(self, default_exchange, rpc_exchange, rpc_prefix,
|
||||
notify_exchange, notify_prefix, unicast_tag, multicast_tag,
|
||||
anycast_tag, vhost):
|
||||
super(RoutableAddresser, self).__init__(default_exchange)
|
||||
super().__init__(default_exchange)
|
||||
if not self._default_exchange:
|
||||
self._default_exchange = "openstack"
|
||||
|
||||
@ -260,7 +260,7 @@ class RoutableAddresser(Addresser):
|
||||
else self._notify_prefix)
|
||||
|
||||
|
||||
class AddresserFactory(object):
|
||||
class AddresserFactory:
|
||||
"""Generates the proper Addresser based on configuration and the type of
|
||||
message bus the driver is connected to.
|
||||
"""
|
||||
|
@ -52,7 +52,7 @@ from oslo_messaging import transport
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Task(object):
|
||||
class Task:
|
||||
"""Run a command on the eventloop thread, wait until it completes
|
||||
"""
|
||||
|
||||
@ -74,7 +74,7 @@ class SubscribeTask(Task):
|
||||
arriving from the target are given to the listener.
|
||||
"""
|
||||
def __init__(self, target, listener, notifications=False):
|
||||
super(SubscribeTask, self).__init__()
|
||||
super().__init__()
|
||||
self._target = target() # mutable - need a copy
|
||||
self._subscriber_id = listener.id
|
||||
self._in_queue = listener.incoming
|
||||
@ -95,7 +95,7 @@ class SendTask(Task):
|
||||
"""
|
||||
def __init__(self, name, message, target, deadline, retry,
|
||||
wait_for_ack, notification=False):
|
||||
super(SendTask, self).__init__()
|
||||
super().__init__()
|
||||
self.name = name
|
||||
# note: target can be either a Target class or a string
|
||||
# target is mutable - make copy
|
||||
@ -195,18 +195,18 @@ class RPCCallTask(SendTask):
|
||||
the destination.
|
||||
"""
|
||||
def __init__(self, target, message, deadline, retry, wait_for_ack):
|
||||
super(RPCCallTask, self).__init__("RPC Call", message, target,
|
||||
deadline, retry, wait_for_ack)
|
||||
super().__init__("RPC Call", message, target,
|
||||
deadline, retry, wait_for_ack)
|
||||
self._reply_link = None
|
||||
self._reply_msg = None
|
||||
self._msg_id = None
|
||||
|
||||
def wait(self):
|
||||
error = super(RPCCallTask, self).wait()
|
||||
error = super().wait()
|
||||
return error or self._reply_msg
|
||||
|
||||
def _prepare(self, sender):
|
||||
super(RPCCallTask, self)._prepare(sender)
|
||||
super()._prepare(sender)
|
||||
# reserve a message id for mapping the received response
|
||||
if self._msg_id:
|
||||
# already set so this is a re-transmit. To be safe cancel the old
|
||||
@ -224,7 +224,7 @@ class RPCCallTask(SendTask):
|
||||
|
||||
def _on_ack(self, state, info):
|
||||
if state != pyngus.SenderLink.ACCEPTED:
|
||||
super(RPCCallTask, self)._on_ack(state, info)
|
||||
super()._on_ack(state, info)
|
||||
# must wait for reply if ACCEPTED
|
||||
|
||||
def _cleanup(self):
|
||||
@ -232,7 +232,7 @@ class RPCCallTask(SendTask):
|
||||
self._reply_link.cancel_response(self._msg_id)
|
||||
self._msg_id = None
|
||||
self._reply_link = None
|
||||
super(RPCCallTask, self)._cleanup()
|
||||
super()._cleanup()
|
||||
|
||||
|
||||
class RPCMonitoredCallTask(RPCCallTask):
|
||||
@ -243,8 +243,8 @@ class RPCMonitoredCallTask(RPCCallTask):
|
||||
"""
|
||||
def __init__(self, target, message, deadline, call_monitor_timeout,
|
||||
retry, wait_for_ack):
|
||||
super(RPCMonitoredCallTask, self).__init__(target, message, deadline,
|
||||
retry, wait_for_ack)
|
||||
super().__init__(target, message, deadline,
|
||||
retry, wait_for_ack)
|
||||
assert call_monitor_timeout is not None # nosec
|
||||
self._monitor_timeout = call_monitor_timeout
|
||||
self._monitor_timer = None
|
||||
@ -254,7 +254,7 @@ class RPCMonitoredCallTask(RPCCallTask):
|
||||
self._set_alarm = controller.processor.defer
|
||||
self._monitor_timer = self._set_alarm(self._call_timeout,
|
||||
self._monitor_timeout)
|
||||
super(RPCMonitoredCallTask, self)._execute(controller)
|
||||
super()._execute(controller)
|
||||
|
||||
def _call_timeout(self):
|
||||
# monitor_timeout expired
|
||||
@ -274,14 +274,14 @@ class RPCMonitoredCallTask(RPCCallTask):
|
||||
self._monitor_timer = self._set_alarm(self._call_timeout,
|
||||
self._monitor_timeout)
|
||||
else:
|
||||
super(RPCMonitoredCallTask, self)._on_reply(message)
|
||||
super()._on_reply(message)
|
||||
|
||||
def _cleanup(self):
|
||||
self._set_alarm = None
|
||||
if self._monitor_timer:
|
||||
self._monitor_timer.cancel()
|
||||
self._monitor_timer = None
|
||||
super(RPCMonitoredCallTask, self)._cleanup()
|
||||
super()._cleanup()
|
||||
|
||||
|
||||
class MessageDispositionTask(Task):
|
||||
@ -289,7 +289,7 @@ class MessageDispositionTask(Task):
|
||||
for a Server
|
||||
"""
|
||||
def __init__(self, disposition, released=False):
|
||||
super(MessageDispositionTask, self).__init__()
|
||||
super().__init__()
|
||||
self._disposition = disposition
|
||||
self._released = released
|
||||
|
||||
@ -311,7 +311,7 @@ class Sender(pyngus.SenderEventHandler):
|
||||
"""A link for sending to a particular destination on the message bus.
|
||||
"""
|
||||
def __init__(self, destination, scheduler, delay, service):
|
||||
super(Sender, self).__init__()
|
||||
super().__init__()
|
||||
self._destination = destination
|
||||
self._service = service
|
||||
self._address = None
|
||||
@ -537,8 +537,8 @@ class Sender(pyngus.SenderEventHandler):
|
||||
self._send(self._pending_sends.popleft())
|
||||
|
||||
def _open_link(self):
|
||||
name = "openstack.org/om/sender/[%s]/%s" % (self._address,
|
||||
uuid.uuid4().hex)
|
||||
name = "openstack.org/om/sender/[{}]/{}".format(self._address,
|
||||
uuid.uuid4().hex)
|
||||
link = self._connection.create_sender(name=name,
|
||||
source_address=self._address,
|
||||
target_address=self._address,
|
||||
@ -685,7 +685,8 @@ class Server(pyngus.ReceiverEventHandler):
|
||||
"""
|
||||
self._connection = connection
|
||||
for a in self._addresses:
|
||||
name = "openstack.org/om/receiver/[%s]/%s" % (a, uuid.uuid4().hex)
|
||||
name = "openstack.org/om/receiver/[{}]/{}".format(
|
||||
a, uuid.uuid4().hex)
|
||||
r = self._open_link(a, name)
|
||||
self._receivers.append(r)
|
||||
|
||||
@ -786,8 +787,8 @@ class Server(pyngus.ReceiverEventHandler):
|
||||
class RPCServer(Server):
|
||||
"""Subscribes to RPC addresses"""
|
||||
def __init__(self, target, incoming, scheduler, delay, capacity):
|
||||
super(RPCServer, self).__init__(target, incoming, scheduler, delay,
|
||||
capacity)
|
||||
super().__init__(target, incoming, scheduler, delay,
|
||||
capacity)
|
||||
|
||||
def attach(self, connection, addresser):
|
||||
# Generate the AMQP 1.0 addresses for the base class
|
||||
@ -797,14 +798,14 @@ class RPCServer(Server):
|
||||
addresser.anycast_address(self._target, SERVICE_RPC)
|
||||
]
|
||||
# now invoke the base class with the generated addresses
|
||||
super(RPCServer, self).attach(connection)
|
||||
super().attach(connection)
|
||||
|
||||
|
||||
class NotificationServer(Server):
|
||||
"""Subscribes to Notification addresses"""
|
||||
def __init__(self, target, incoming, scheduler, delay, capacity):
|
||||
super(NotificationServer, self).__init__(target, incoming, scheduler,
|
||||
delay, capacity)
|
||||
super().__init__(target, incoming, scheduler,
|
||||
delay, capacity)
|
||||
|
||||
def attach(self, connection, addresser):
|
||||
# Generate the AMQP 1.0 addresses for the base class
|
||||
@ -812,10 +813,10 @@ class NotificationServer(Server):
|
||||
addresser.anycast_address(self._target, SERVICE_NOTIFY)
|
||||
]
|
||||
# now invoke the base class with the generated addresses
|
||||
super(NotificationServer, self).attach(connection)
|
||||
super().attach(connection)
|
||||
|
||||
|
||||
class Hosts(object):
|
||||
class Hosts:
|
||||
"""An order list of TransportHost addresses. Connection failover progresses
|
||||
from one host to the next. The default realm comes from the configuration
|
||||
and is only used if no realm is present in the URL.
|
||||
|
@ -44,7 +44,7 @@ def compute_timeout(offset):
|
||||
return math.ceil(time.monotonic() + offset)
|
||||
|
||||
|
||||
class _SocketConnection(object):
|
||||
class _SocketConnection:
|
||||
"""Associates a pyngus Connection with a python network socket,
|
||||
and handles all connection-related I/O and timer events.
|
||||
"""
|
||||
@ -71,7 +71,7 @@ class _SocketConnection(object):
|
||||
try:
|
||||
pyngus.read_socket_input(self.pyngus_conn, self.socket)
|
||||
self.pyngus_conn.process(time.monotonic())
|
||||
except (socket.timeout, socket.error) as e:
|
||||
except (socket.timeout, OSError) as e:
|
||||
# pyngus handles EAGAIN/EWOULDBLOCK and EINTER
|
||||
self.pyngus_conn.close_input()
|
||||
self.pyngus_conn.close_output()
|
||||
@ -83,7 +83,7 @@ class _SocketConnection(object):
|
||||
try:
|
||||
pyngus.write_socket_output(self.pyngus_conn, self.socket)
|
||||
self.pyngus_conn.process(time.monotonic())
|
||||
except (socket.timeout, socket.error) as e:
|
||||
except (socket.timeout, OSError) as e:
|
||||
# pyngus handles EAGAIN/EWOULDBLOCK and EINTER
|
||||
self.pyngus_conn.close_output()
|
||||
self.pyngus_conn.close_input()
|
||||
@ -104,7 +104,7 @@ class _SocketConnection(object):
|
||||
my_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
try:
|
||||
my_socket.connect(addr[0][4])
|
||||
except socket.error as e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.EINPROGRESS:
|
||||
error = "Socket connect failure '%s'" % str(e)
|
||||
LOG.error("Socket connect failure '%s'", str(e))
|
||||
@ -159,10 +159,10 @@ class _SocketConnection(object):
|
||||
self.socket = None
|
||||
|
||||
|
||||
class Scheduler(object):
|
||||
class Scheduler:
|
||||
"""Schedule callables to be run in the future.
|
||||
"""
|
||||
class Event(object):
|
||||
class Event:
|
||||
# simply hold a reference to a callback that can be set to None if the
|
||||
# alarm is canceled
|
||||
def __init__(self, callback):
|
||||
@ -229,7 +229,7 @@ class Scheduler(object):
|
||||
pass
|
||||
|
||||
|
||||
class Requests(object):
|
||||
class Requests:
|
||||
"""A queue of callables to execute from the eventloop thread's main
|
||||
loop.
|
||||
"""
|
||||
@ -273,7 +273,7 @@ class Thread(threading.Thread):
|
||||
threads.
|
||||
"""
|
||||
def __init__(self, container_name, node, command, pid):
|
||||
super(Thread, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
# callables from other threads:
|
||||
self._requests = Requests()
|
||||
@ -325,7 +325,8 @@ class Thread(threading.Thread):
|
||||
|
||||
def connect(self, host, handler, properties):
|
||||
"""Get a _SocketConnection to a peer represented by url."""
|
||||
key = "openstack.org/om/connection/%s:%s/" % (host.hostname, host.port)
|
||||
key = "openstack.org/om/connection/{}:{}/".format(
|
||||
host.hostname, host.port)
|
||||
# return pre-existing
|
||||
conn = self._container.get_connection(key)
|
||||
if conn:
|
||||
@ -379,7 +380,7 @@ class Thread(threading.Thread):
|
||||
# and now we wait...
|
||||
try:
|
||||
select.select(readfds, writefds, [], timeout)
|
||||
except select.error as serror:
|
||||
except OSError as serror:
|
||||
if serror[0] == errno.EINTR:
|
||||
LOG.warning("ignoring interrupt from select(): %s",
|
||||
str(serror))
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# Copyright 2013 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -42,7 +41,7 @@ ACK_REQUEUE_EVERY_SECONDS_MIN = 0.001
|
||||
ACK_REQUEUE_EVERY_SECONDS_MAX = 5.0
|
||||
|
||||
|
||||
class QManager(object):
|
||||
class QManager:
|
||||
"""Queue Manager to build queue name for reply (and fanout) type.
|
||||
This class is used only when use_queue_manager is set to True in config
|
||||
file.
|
||||
@ -61,8 +60,9 @@ class QManager(object):
|
||||
self.hostname = hostname
|
||||
self.processname = processname
|
||||
# This is where the counter is kept
|
||||
self.file_name = '/dev/shm/%s_%s_qmanager' % (self.hostname, # nosec
|
||||
self.processname)
|
||||
self.file_name = '/dev/shm/{}_{}_qmanager'.format( # nosec
|
||||
self.hostname,
|
||||
self.processname)
|
||||
# We use the process group to restart the counter on service restart
|
||||
self.pg = os.getpgrp()
|
||||
|
||||
@ -70,18 +70,19 @@ class QManager(object):
|
||||
# parse start time (in jiffies) since system boot
|
||||
#
|
||||
# https://www.man7.org/linux/man-pages//man5/proc_pid_stat.5.html
|
||||
with open(f'/proc/{self.pg}/stat', 'r') as f:
|
||||
with open(f'/proc/{self.pg}/stat') as f:
|
||||
self.start_time = int(f.read().split()[21])
|
||||
|
||||
def get(self):
|
||||
lock_name = 'oslo_read_shm_%s_%s' % (self.hostname, self.processname)
|
||||
lock_name = 'oslo_read_shm_{}_{}'.format(
|
||||
self.hostname, self.processname)
|
||||
|
||||
@lockutils.synchronized(lock_name, external=True)
|
||||
def read_from_shm():
|
||||
# Grab the counter from shm
|
||||
# This function is thread and process safe thanks to lockutils
|
||||
try:
|
||||
with open(self.file_name, 'r') as f:
|
||||
with open(self.file_name) as f:
|
||||
pg, counter, start_time = f.readline().split(':')
|
||||
pg = int(pg)
|
||||
counter = int(counter)
|
||||
@ -110,14 +111,14 @@ class QManager(object):
|
||||
return self.hostname + ":" + self.processname + ":" + str(counter)
|
||||
|
||||
|
||||
class MessageOperationsHandler(object):
|
||||
class MessageOperationsHandler:
|
||||
"""Queue used by message operations to ensure that all tasks are
|
||||
serialized and run in the same thread, since underlying drivers like kombu
|
||||
are not thread safe.
|
||||
"""
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = "%s (%s)" % (name, hex(id(self)))
|
||||
self.name = "{} ({})".format(name, hex(id(self)))
|
||||
self._tasks = queue.Queue()
|
||||
|
||||
self._shutdown = eventletutils.Event()
|
||||
@ -159,7 +160,7 @@ class AMQPIncomingMessage(base.RpcIncomingMessage):
|
||||
def __init__(self, listener, ctxt, message, unique_id, msg_id, reply_q,
|
||||
client_timeout, obsolete_reply_queues,
|
||||
message_operations_handler):
|
||||
super(AMQPIncomingMessage, self).__init__(ctxt, message, msg_id)
|
||||
super().__init__(ctxt, message, msg_id)
|
||||
self.orig_msg_id = msg_id
|
||||
self.listener = listener
|
||||
|
||||
@ -317,7 +318,7 @@ class NotificationAMQPIncomingMessage(AMQPIncomingMessage):
|
||||
self._message_operations_handler.do(_do_requeue)
|
||||
|
||||
|
||||
class ObsoleteReplyQueuesCache(object):
|
||||
class ObsoleteReplyQueuesCache:
|
||||
"""Cache of reply queue id that doesn't exist anymore.
|
||||
|
||||
NOTE(sileht): In case of a broker restart/failover
|
||||
@ -365,7 +366,7 @@ class AMQPListener(base.PollStyleListener):
|
||||
use_cache = False
|
||||
|
||||
def __init__(self, driver, conn):
|
||||
super(AMQPListener, self).__init__(driver.prefetch_size)
|
||||
super().__init__(driver.prefetch_size)
|
||||
self.driver = driver
|
||||
self.conn = conn
|
||||
self.msg_id_cache = rpc_amqp._MsgIdCache()
|
||||
@ -493,14 +494,14 @@ class RpcAMQPListener(AMQPListener):
|
||||
# succeeds there is no guarantee the broker actually gets the ACK
|
||||
# since acknowledge() simply writes the ACK to the socket (there is
|
||||
# no ACK confirmation coming back from the broker)
|
||||
super(RpcAMQPListener, self).__call__(message)
|
||||
super().__call__(message)
|
||||
|
||||
|
||||
class NotificationAMQPListener(AMQPListener):
|
||||
message_cls = NotificationAMQPIncomingMessage
|
||||
|
||||
|
||||
class ReplyWaiters(object):
|
||||
class ReplyWaiters:
|
||||
|
||||
def __init__(self):
|
||||
self._queues = {}
|
||||
@ -547,7 +548,7 @@ class ReplyWaiters(object):
|
||||
del self._queues[msg_id]
|
||||
|
||||
|
||||
class ReplyWaiter(object):
|
||||
class ReplyWaiter:
|
||||
def __init__(self, reply_q, conn, allowed_remote_exmods):
|
||||
self.conn = conn
|
||||
self.allowed_remote_exmods = allowed_remote_exmods
|
||||
@ -675,8 +676,8 @@ class AMQPDriverBase(base.BaseDriver):
|
||||
|
||||
def __init__(self, conf, url, connection_pool,
|
||||
default_exchange=None, allowed_remote_exmods=None):
|
||||
super(AMQPDriverBase, self).__init__(conf, url, default_exchange,
|
||||
allowed_remote_exmods)
|
||||
super().__init__(conf, url, default_exchange,
|
||||
allowed_remote_exmods)
|
||||
|
||||
self._default_exchange = default_exchange
|
||||
|
||||
@ -768,15 +769,15 @@ class AMQPDriverBase(base.BaseDriver):
|
||||
'topic': target.topic})
|
||||
conn.notify_send(exchange, target.topic, msg, retry=retry)
|
||||
elif target.fanout:
|
||||
log_msg += "FANOUT topic '%(topic)s'" % {
|
||||
'topic': target.topic}
|
||||
log_msg += "FANOUT topic '{topic}'".format(
|
||||
topic=target.topic)
|
||||
LOG.debug(log_msg)
|
||||
conn.fanout_send(target.topic, msg, retry=retry)
|
||||
else:
|
||||
topic = target.topic
|
||||
exchange = self._get_exchange(target)
|
||||
if target.server:
|
||||
topic = '%s.%s' % (target.topic, target.server)
|
||||
topic = '{}.{}'.format(target.topic, target.server)
|
||||
LOG.debug(log_msg + "exchange '%(exchange)s'"
|
||||
" topic '%(topic)s'", {'exchange': exchange,
|
||||
'topic': topic})
|
||||
@ -813,8 +814,8 @@ class AMQPDriverBase(base.BaseDriver):
|
||||
topic=target.topic,
|
||||
callback=listener)
|
||||
conn.declare_topic_consumer(exchange_name=self._get_exchange(target),
|
||||
topic='%s.%s' % (target.topic,
|
||||
target.server),
|
||||
topic='{}.{}'.format(target.topic,
|
||||
target.server),
|
||||
callback=listener)
|
||||
conn.declare_fanout_consumer(target.topic, listener)
|
||||
|
||||
@ -829,7 +830,7 @@ class AMQPDriverBase(base.BaseDriver):
|
||||
for target, priority in targets_and_priorities:
|
||||
conn.declare_topic_consumer(
|
||||
exchange_name=self._get_exchange(target),
|
||||
topic='%s.%s' % (target.topic, priority),
|
||||
topic='{}.{}'.format(target.topic, priority),
|
||||
callback=listener, queue_name=pool)
|
||||
return base.PollStyleListenerAdapter(listener, batch_size,
|
||||
batch_timeout)
|
||||
|
@ -66,7 +66,7 @@ class TransportDriverError(exceptions.MessagingException):
|
||||
"""Base class for transport driver specific exceptions."""
|
||||
|
||||
|
||||
class IncomingMessage(object, metaclass=abc.ABCMeta):
|
||||
class IncomingMessage(metaclass=abc.ABCMeta):
|
||||
"""The IncomingMessage class represents a single message received from the
|
||||
messaging backend. Instances of this class are passed to up a server's
|
||||
messaging processing logic. The backend driver must provide a concrete
|
||||
@ -173,7 +173,7 @@ class RpcIncomingMessage(IncomingMessage, metaclass=abc.ABCMeta):
|
||||
"""
|
||||
|
||||
|
||||
class PollStyleListener(object, metaclass=abc.ABCMeta):
|
||||
class PollStyleListener(metaclass=abc.ABCMeta):
|
||||
"""A PollStyleListener is used to transfer received messages to a server
|
||||
for processing. A polling pattern is used to retrieve messages. A
|
||||
PollStyleListener uses a separate thread to run the polling loop. A
|
||||
@ -229,7 +229,7 @@ class PollStyleListener(object, metaclass=abc.ABCMeta):
|
||||
pass
|
||||
|
||||
|
||||
class Listener(object, metaclass=abc.ABCMeta):
|
||||
class Listener(metaclass=abc.ABCMeta):
|
||||
"""A Listener is used to transfer incoming messages from the driver to a
|
||||
server for processing. A callback is used by the driver to transfer the
|
||||
messages.
|
||||
@ -287,7 +287,7 @@ class PollStyleListenerAdapter(Listener):
|
||||
"""
|
||||
|
||||
def __init__(self, poll_style_listener, batch_size, batch_timeout):
|
||||
super(PollStyleListenerAdapter, self).__init__(
|
||||
super().__init__(
|
||||
batch_size, batch_timeout, poll_style_listener.prefetch_size
|
||||
)
|
||||
self._poll_style_listener = poll_style_listener
|
||||
@ -296,7 +296,7 @@ class PollStyleListenerAdapter(Listener):
|
||||
self._started = False
|
||||
|
||||
def start(self, on_incoming_callback):
|
||||
super(PollStyleListenerAdapter, self).start(on_incoming_callback)
|
||||
super().start(on_incoming_callback)
|
||||
self._started = True
|
||||
self._listen_thread.start()
|
||||
|
||||
@ -323,13 +323,13 @@ class PollStyleListenerAdapter(Listener):
|
||||
self._started = False
|
||||
self._poll_style_listener.stop()
|
||||
self._listen_thread.join()
|
||||
super(PollStyleListenerAdapter, self).stop()
|
||||
super().stop()
|
||||
|
||||
def cleanup(self):
|
||||
self._poll_style_listener.cleanup()
|
||||
|
||||
|
||||
class BaseDriver(object, metaclass=abc.ABCMeta):
|
||||
class BaseDriver(metaclass=abc.ABCMeta):
|
||||
"""Defines the backend driver interface. Each backend driver implementation
|
||||
must provide a concrete derivation of this class implementing the backend
|
||||
specific logic for its public methods.
|
||||
|
@ -91,7 +91,7 @@ class RPCException(Exception):
|
||||
# at least get the core message out if something happened
|
||||
message = self.msg_fmt
|
||||
|
||||
super(RPCException, self).__init__(message)
|
||||
super().__init__(message)
|
||||
|
||||
|
||||
class Timeout(RPCException):
|
||||
@ -115,7 +115,7 @@ class Timeout(RPCException):
|
||||
self.info = info
|
||||
self.topic = topic
|
||||
self.method = method
|
||||
super(Timeout, self).__init__(
|
||||
super().__init__(
|
||||
None,
|
||||
info=info or '<unknown>',
|
||||
topic=topic or '<unknown>',
|
||||
@ -144,7 +144,7 @@ class RpcVersionCapError(RPCException):
|
||||
msg_fmt = "Specified RPC version cap, %(version_cap)s, is too low"
|
||||
|
||||
|
||||
class Connection(object):
|
||||
class Connection:
|
||||
"""A connection, returned by rpc.create_connection().
|
||||
|
||||
This class represents a connection to the message bus used for rpc.
|
||||
@ -235,7 +235,7 @@ def deserialize_remote_exception(data, allowed_remote_exmods):
|
||||
str_override = lambda self: message
|
||||
new_ex_type = type(ex_type.__name__ + _REMOTE_POSTFIX, (ex_type,),
|
||||
{'__str__': str_override, '__unicode__': str_override})
|
||||
new_ex_type.__module__ = '%s%s' % (module, _REMOTE_POSTFIX)
|
||||
new_ex_type.__module__ = '{}{}'.format(module, _REMOTE_POSTFIX)
|
||||
try:
|
||||
# NOTE(ameade): Dynamically create a new exception type and swap it in
|
||||
# as the new type for the exception. This only works on user defined
|
||||
@ -250,7 +250,7 @@ def deserialize_remote_exception(data, allowed_remote_exmods):
|
||||
return failure
|
||||
|
||||
|
||||
class CommonRpcContext(object):
|
||||
class CommonRpcContext:
|
||||
def __init__(self, **kwargs):
|
||||
self.values = kwargs
|
||||
|
||||
@ -339,7 +339,7 @@ def deserialize_msg(msg):
|
||||
return raw_msg
|
||||
|
||||
|
||||
class DecayingTimer(object):
|
||||
class DecayingTimer:
|
||||
def __init__(self, duration=None):
|
||||
self._watch = timeutils.StopWatch(duration=duration)
|
||||
|
||||
|
@ -110,7 +110,7 @@ def unmarshal_request(message):
|
||||
class ProtonIncomingMessage(base.RpcIncomingMessage):
|
||||
def __init__(self, listener, message, disposition):
|
||||
request, ctxt, client_timeout = unmarshal_request(message)
|
||||
super(ProtonIncomingMessage, self).__init__(ctxt, request)
|
||||
super().__init__(ctxt, request)
|
||||
self.listener = listener
|
||||
self.client_timeout = client_timeout
|
||||
self._reply_to = message.reply_to
|
||||
@ -170,7 +170,7 @@ class ProtonIncomingMessage(base.RpcIncomingMessage):
|
||||
|
||||
|
||||
@removals.removed_class("Queue")
|
||||
class Queue(object):
|
||||
class Queue:
|
||||
def __init__(self):
|
||||
self._queue = collections.deque()
|
||||
self._lock = threading.Lock()
|
||||
@ -202,7 +202,7 @@ class Queue(object):
|
||||
@removals.removed_class("ProtonListener")
|
||||
class ProtonListener(base.PollStyleListener):
|
||||
def __init__(self, driver):
|
||||
super(ProtonListener, self).__init__(driver.prefetch_size)
|
||||
super().__init__(driver.prefetch_size)
|
||||
self.driver = driver
|
||||
self.incoming = Queue()
|
||||
self.id = uuid.uuid4().hex
|
||||
@ -232,8 +232,8 @@ class ProtonDriver(base.BaseDriver):
|
||||
if proton is None or controller is None:
|
||||
raise NotImplementedError("Proton AMQP C libraries not installed")
|
||||
|
||||
super(ProtonDriver, self).__init__(conf, url, default_exchange,
|
||||
allowed_remote_exmods)
|
||||
super().__init__(conf, url, default_exchange,
|
||||
allowed_remote_exmods)
|
||||
|
||||
opt_group = cfg.OptGroup(name='oslo_messaging_amqp',
|
||||
title='AMQP 1.0 driver options')
|
||||
@ -429,7 +429,7 @@ class ProtonDriver(base.BaseDriver):
|
||||
# this is how the destination target is created by the notifier,
|
||||
# see MessagingDriver.notify in oslo_messaging/notify/messaging.py
|
||||
for target, priority in targets_and_priorities:
|
||||
topic = '%s.%s' % (target.topic, priority)
|
||||
topic = '{}.{}'.format(target.topic, priority)
|
||||
# Sooo... the exchange is simply discarded? (see above comment)
|
||||
task = controller.SubscribeTask(Target(topic=topic),
|
||||
listener, notifications=True)
|
||||
|
@ -27,7 +27,7 @@ from oslo_messaging._drivers import base
|
||||
|
||||
class FakeIncomingMessage(base.RpcIncomingMessage):
|
||||
def __init__(self, ctxt, message, reply_q, requeue):
|
||||
super(FakeIncomingMessage, self).__init__(ctxt, message)
|
||||
super().__init__(ctxt, message)
|
||||
self.requeue_callback = requeue
|
||||
self._reply_q = reply_q
|
||||
|
||||
@ -46,7 +46,7 @@ class FakeIncomingMessage(base.RpcIncomingMessage):
|
||||
class FakeListener(base.PollStyleListener):
|
||||
|
||||
def __init__(self, exchange_manager, targets, pool=None):
|
||||
super(FakeListener, self).__init__()
|
||||
super().__init__()
|
||||
self._exchange_manager = exchange_manager
|
||||
self._targets = targets
|
||||
self._pool = pool
|
||||
@ -87,7 +87,7 @@ class FakeListener(base.PollStyleListener):
|
||||
self._stopped.set()
|
||||
|
||||
|
||||
class FakeExchange(object):
|
||||
class FakeExchange:
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
@ -145,7 +145,7 @@ class FakeExchange(object):
|
||||
return queue.pop(0) if queue else (None, None, None, None)
|
||||
|
||||
|
||||
class FakeExchangeManager(object):
|
||||
class FakeExchangeManager:
|
||||
_exchanges_lock = threading.Lock()
|
||||
_exchanges = {}
|
||||
|
||||
@ -173,8 +173,8 @@ class FakeDriver(base.BaseDriver):
|
||||
|
||||
def __init__(self, conf, url, default_exchange=None,
|
||||
allowed_remote_exmods=None):
|
||||
super(FakeDriver, self).__init__(conf, url, default_exchange,
|
||||
allowed_remote_exmods)
|
||||
super().__init__(conf, url, default_exchange,
|
||||
allowed_remote_exmods)
|
||||
|
||||
self._exchange_manager = FakeExchangeManager(default_exchange)
|
||||
|
||||
@ -248,7 +248,7 @@ class FakeDriver(base.BaseDriver):
|
||||
batch_size, batch_timeout):
|
||||
targets = [
|
||||
oslo_messaging.Target(
|
||||
topic='%s.%s' % (target.topic, priority),
|
||||
topic='{}.{}'.format(target.topic, priority),
|
||||
exchange=target.exchange)
|
||||
for target, priority in targets_and_priorities]
|
||||
listener = FakeListener(self._exchange_manager, targets, pool)
|
||||
|
@ -77,12 +77,12 @@ class ConsumerTimeout(KafkaException):
|
||||
pass
|
||||
|
||||
|
||||
class AssignedPartition(object):
|
||||
class AssignedPartition:
|
||||
"""This class is used by the ConsumerConnection to track the
|
||||
assigned partitions.
|
||||
"""
|
||||
def __init__(self, topic, partition):
|
||||
super(AssignedPartition, self).__init__()
|
||||
super().__init__()
|
||||
self.topic = topic
|
||||
self.partition = partition
|
||||
self.skey = '%s %d' % (self.topic, self.partition)
|
||||
@ -91,7 +91,7 @@ class AssignedPartition(object):
|
||||
return {'topic': self.topic, 'partition': self.partition}
|
||||
|
||||
|
||||
class Connection(object):
|
||||
class Connection:
|
||||
"""This is the base class for consumer and producer connections for
|
||||
transport attributes.
|
||||
"""
|
||||
@ -126,8 +126,8 @@ class Connection(object):
|
||||
LOG.warning("Different transport usernames detected")
|
||||
|
||||
if host.hostname:
|
||||
hostaddr = "%s:%s" % (netutils.escape_ipv6(host.hostname),
|
||||
host.port)
|
||||
hostaddr = "{}:{}".format(netutils.escape_ipv6(host.hostname),
|
||||
host.port)
|
||||
|
||||
self.hostaddrs.append(hostaddr)
|
||||
|
||||
@ -141,7 +141,7 @@ class ConsumerConnection(Connection):
|
||||
"""
|
||||
def __init__(self, conf, url):
|
||||
|
||||
super(ConsumerConnection, self).__init__(conf, url)
|
||||
super().__init__(conf, url)
|
||||
self.consumer = None
|
||||
self.consumer_timeout = self.driver_conf.kafka_consumer_timeout
|
||||
self.max_fetch_bytes = self.driver_conf.kafka_max_fetch_bytes
|
||||
@ -262,7 +262,7 @@ class ProducerConnection(Connection):
|
||||
|
||||
def __init__(self, conf, url):
|
||||
|
||||
super(ProducerConnection, self).__init__(conf, url)
|
||||
super().__init__(conf, url)
|
||||
self.batch_size = self.driver_conf.producer_batch_size
|
||||
self.linger_ms = self.driver_conf.producer_batch_timeout * 1000
|
||||
self.compression_codec = self.driver_conf.compression_codec
|
||||
@ -356,7 +356,7 @@ class ProducerConnection(Connection):
|
||||
class OsloKafkaMessage(base.RpcIncomingMessage):
|
||||
|
||||
def __init__(self, ctxt, message):
|
||||
super(OsloKafkaMessage, self).__init__(ctxt, message)
|
||||
super().__init__(ctxt, message)
|
||||
|
||||
def requeue(self):
|
||||
LOG.warning("requeue is not supported")
|
||||
@ -371,7 +371,7 @@ class OsloKafkaMessage(base.RpcIncomingMessage):
|
||||
class KafkaListener(base.PollStyleListener):
|
||||
|
||||
def __init__(self, conn):
|
||||
super(KafkaListener, self).__init__()
|
||||
super().__init__()
|
||||
self._stopped = eventletutils.Event()
|
||||
self.conn = conn
|
||||
self.incoming_queue = []
|
||||
@ -411,7 +411,7 @@ class KafkaDriver(base.BaseDriver):
|
||||
def __init__(self, conf, url, default_exchange=None,
|
||||
allowed_remote_exmods=None):
|
||||
conf = kafka_options.register_opts(conf, url)
|
||||
super(KafkaDriver, self).__init__(
|
||||
super().__init__(
|
||||
conf, url, default_exchange, allowed_remote_exmods)
|
||||
|
||||
self.listeners = []
|
||||
|
@ -367,7 +367,7 @@ def _get_queue_arguments(rabbit_ha_queues, rabbit_queue_ttl,
|
||||
|
||||
class RabbitMessage(dict):
|
||||
def __init__(self, raw_message):
|
||||
super(RabbitMessage, self).__init__(
|
||||
super().__init__(
|
||||
rpc_common.deserialize_msg(raw_message.payload))
|
||||
LOG.trace('RabbitMessage.Init: message %s', self)
|
||||
self._raw_message = raw_message
|
||||
@ -381,7 +381,7 @@ class RabbitMessage(dict):
|
||||
self._raw_message.requeue()
|
||||
|
||||
|
||||
class Consumer(object):
|
||||
class Consumer:
|
||||
"""Consumer class."""
|
||||
|
||||
def __init__(self, exchange_name, queue_name, routing_key, type, durable,
|
||||
@ -724,7 +724,7 @@ class ConnectionLock(DummyConnectionLock):
|
||||
self.release()
|
||||
|
||||
|
||||
class Connection(object):
|
||||
class Connection:
|
||||
"""Connection object."""
|
||||
|
||||
def __init__(self, conf, url, purpose, retry=None):
|
||||
@ -1006,7 +1006,7 @@ class Connection(object):
|
||||
default_password='', default_hostname=''):
|
||||
transport = url.transport.replace('kombu+', '')
|
||||
transport = transport.replace('rabbit', 'amqp')
|
||||
return '%s://%s:%s@%s:%s/%s' % (
|
||||
return '{}://{}:{}@{}:{}/{}'.format(
|
||||
transport,
|
||||
parse.quote(host.username or default_username),
|
||||
parse.quote(host.password or default_password),
|
||||
@ -1309,7 +1309,7 @@ class Connection(object):
|
||||
sock.setsockopt(socket.IPPROTO_TCP,
|
||||
TCP_USER_TIMEOUT,
|
||||
int(math.ceil(timeout)))
|
||||
except socket.error as error:
|
||||
except OSError as error:
|
||||
code = error[0]
|
||||
# TCP_USER_TIMEOUT not defined on kernels <2.6.37
|
||||
if code != errno.ENOPROTOOPT:
|
||||
@ -1527,7 +1527,7 @@ class Connection(object):
|
||||
unique = self._q_manager.get()
|
||||
else:
|
||||
unique = uuid.uuid4().hex
|
||||
queue_name = '%s_fanout_%s' % (topic, unique)
|
||||
queue_name = '{}_fanout_{}'.format(topic, unique)
|
||||
LOG.debug('Creating fanout queue: %s', queue_name)
|
||||
|
||||
is_durable = (self.rabbit_transient_quorum_queue or
|
||||
@ -1573,8 +1573,8 @@ class Connection(object):
|
||||
# the connection's socket while it is in an error state will cause
|
||||
# py-amqp to attempt reconnecting.
|
||||
ci = self.connection.info()
|
||||
info = dict([(k, ci.get(k)) for k in
|
||||
['hostname', 'port', 'transport']])
|
||||
info = {k: ci.get(k) for k in
|
||||
['hostname', 'port', 'transport']}
|
||||
client_port = None
|
||||
if (not conn_error and self.channel and
|
||||
hasattr(self.channel.connection, 'sock') and
|
||||
@ -1788,7 +1788,7 @@ class RabbitDriver(amqpdriver.AMQPDriverBase):
|
||||
conf, max_size, min_size, ttl,
|
||||
url, Connection)
|
||||
|
||||
super(RabbitDriver, self).__init__(
|
||||
super().__init__(
|
||||
conf, url,
|
||||
connection_pool,
|
||||
default_exchange,
|
||||
|
@ -24,7 +24,7 @@ from oslo_messaging._drivers import common
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Pool(object, metaclass=abc.ABCMeta):
|
||||
class Pool(metaclass=abc.ABCMeta):
|
||||
"""A thread-safe object pool.
|
||||
|
||||
Modelled after the eventlet.pools.Pool interface, but designed to be safe
|
||||
@ -35,7 +35,7 @@ class Pool(object, metaclass=abc.ABCMeta):
|
||||
"""
|
||||
|
||||
def __init__(self, max_size=4, min_size=2, ttl=1200, on_expire=None):
|
||||
super(Pool, self).__init__()
|
||||
super().__init__()
|
||||
self._min_size = min_size
|
||||
self._max_size = max_size
|
||||
self._item_ttl = ttl
|
||||
@ -122,8 +122,8 @@ class ConnectionPool(Pool):
|
||||
self.connection_cls = connection_cls
|
||||
self.conf = conf
|
||||
self.url = url
|
||||
super(ConnectionPool, self).__init__(max_size, min_size, ttl,
|
||||
self._on_expire)
|
||||
super().__init__(max_size, min_size, ttl,
|
||||
self._on_expire)
|
||||
|
||||
def _on_expire(self, connection):
|
||||
connection.close()
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# Copyright 2020 LINE Corp.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -65,7 +64,7 @@ oslo_messaging_metrics = [
|
||||
cfg.CONF.register_opts(oslo_messaging_metrics, group='oslo_messaging_metrics')
|
||||
|
||||
|
||||
class MetricsCollectorClient(object):
|
||||
class MetricsCollectorClient:
|
||||
|
||||
def __init__(self, conf, metrics_type, **kwargs):
|
||||
self.conf = conf.oslo_messaging_metrics
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# Copyright 2013 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -70,7 +69,7 @@ def version_is_compatible(imp_version, version):
|
||||
return True
|
||||
|
||||
|
||||
class DummyLock(object):
|
||||
class DummyLock:
|
||||
def acquire(self):
|
||||
pass
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# Copyright 2013 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -120,7 +119,7 @@ class ConfFixture(fixtures.Fixture):
|
||||
self.conf.clear_override = self.conf.clear_override.wrapped
|
||||
|
||||
def setUp(self):
|
||||
super(ConfFixture, self).setUp()
|
||||
super().setUp()
|
||||
self._setup_decorator()
|
||||
self.addCleanup(self._teardown_decorator)
|
||||
self.addCleanup(self.conf.reset)
|
||||
|
@ -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
|
||||
@ -19,7 +18,7 @@ __all__ = [
|
||||
]
|
||||
|
||||
|
||||
class DispatcherBase(object, metaclass=abc.ABCMeta):
|
||||
class DispatcherBase(metaclass=abc.ABCMeta):
|
||||
"Base class for dispatcher"
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# Copyright 2013 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -34,7 +33,7 @@ class InvalidTarget(MessagingException, ValueError):
|
||||
|
||||
def __init__(self, msg, target):
|
||||
msg = msg + ":" + str(target)
|
||||
super(InvalidTarget, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
self.target = target
|
||||
|
||||
|
||||
@ -42,7 +41,7 @@ class MessageUndeliverable(Exception):
|
||||
"""Raised if message is not routed with mandatory flag"""
|
||||
|
||||
def __init__(self, exception, exchange, routing_key, message):
|
||||
super(MessageUndeliverable, self).__init__()
|
||||
super().__init__()
|
||||
self.exception = exception
|
||||
self.exchange = exchange
|
||||
self.routing_key = routing_key
|
||||
|
@ -91,7 +91,7 @@ class CheckForLoggingIssues(BaseASTChecker):
|
||||
version = '1.0'
|
||||
|
||||
def __init__(self, tree, filename):
|
||||
super(CheckForLoggingIssues, self).__init__(tree, filename)
|
||||
super().__init__(tree, filename)
|
||||
|
||||
self.logger_names = []
|
||||
self.logger_module_names = []
|
||||
@ -120,13 +120,13 @@ class CheckForLoggingIssues(BaseASTChecker):
|
||||
def visit_Import(self, node):
|
||||
for alias in node.names:
|
||||
self._filter_imports(alias.name, alias)
|
||||
return super(CheckForLoggingIssues, self).generic_visit(node)
|
||||
return super().generic_visit(node)
|
||||
|
||||
def visit_ImportFrom(self, node):
|
||||
for alias in node.names:
|
||||
full_name = '%s.%s' % (node.module, alias.name)
|
||||
full_name = '{}.{}'.format(node.module, alias.name)
|
||||
self._filter_imports(full_name, alias)
|
||||
return super(CheckForLoggingIssues, self).generic_visit(node)
|
||||
return super().generic_visit(node)
|
||||
|
||||
def _find_name(self, node):
|
||||
"""Return the fully qualified name or a Name or Attribute."""
|
||||
@ -155,7 +155,7 @@ class CheckForLoggingIssues(BaseASTChecker):
|
||||
if (len(node.targets) != 1 or
|
||||
not isinstance(node.targets[0], attr_node_types)):
|
||||
# say no to: "x, y = ..."
|
||||
return super(CheckForLoggingIssues, self).generic_visit(node)
|
||||
return super().generic_visit(node)
|
||||
|
||||
target_name = self._find_name(node.targets[0])
|
||||
|
||||
@ -170,17 +170,17 @@ class CheckForLoggingIssues(BaseASTChecker):
|
||||
if not isinstance(node.value, ast.Call):
|
||||
# node.value must be a call to getLogger
|
||||
self.assignments.pop(target_name, None)
|
||||
return super(CheckForLoggingIssues, self).generic_visit(node)
|
||||
return super().generic_visit(node)
|
||||
|
||||
if isinstance(node.value.func, ast.Name):
|
||||
self.assignments[target_name] = node.value.func.id
|
||||
return super(CheckForLoggingIssues, self).generic_visit(node)
|
||||
return super().generic_visit(node)
|
||||
|
||||
if (not isinstance(node.value.func, ast.Attribute) or
|
||||
not isinstance(node.value.func.value, attr_node_types)):
|
||||
# function must be an attribute on an object like
|
||||
# logging.getLogger
|
||||
return super(CheckForLoggingIssues, self).generic_visit(node)
|
||||
return super().generic_visit(node)
|
||||
|
||||
object_name = self._find_name(node.value.func.value)
|
||||
func_name = node.value.func.attr
|
||||
@ -189,7 +189,7 @@ class CheckForLoggingIssues(BaseASTChecker):
|
||||
func_name == 'getLogger'):
|
||||
self.logger_names.append(target_name)
|
||||
|
||||
return super(CheckForLoggingIssues, self).generic_visit(node)
|
||||
return super().generic_visit(node)
|
||||
|
||||
def visit_Call(self, node):
|
||||
"""Look for the 'LOG.*' calls."""
|
||||
@ -202,7 +202,7 @@ class CheckForLoggingIssues(BaseASTChecker):
|
||||
obj_name = self._find_name(node.func.value)
|
||||
method_name = node.func.attr
|
||||
else: # could be Subscript, Call or many more
|
||||
return super(CheckForLoggingIssues, self).generic_visit(node)
|
||||
return super().generic_visit(node)
|
||||
|
||||
# if dealing with a logger the method can't be "warn"
|
||||
if obj_name in self.logger_names and method_name == 'warn':
|
||||
@ -211,16 +211,16 @@ class CheckForLoggingIssues(BaseASTChecker):
|
||||
|
||||
# must be a logger instance and one of the support logging methods
|
||||
if obj_name not in self.logger_names:
|
||||
return super(CheckForLoggingIssues, self).generic_visit(node)
|
||||