Fix keyword-arg-before-vararg warnings

The correct usage when using keyword and varargs is

def func(arg1, *args, arg2=None, **kwargs):

Otherwise you can end up in having multiple values passed
for the parameters in case the method is called with
keyword arguments.

Fixed two calls to _get_ports_query() that were not
passing the 'filters' argument correctly.

Start enforcing this as well.

TrivialFix

Change-Id: Id9d6d841133241bbc87a589117468c4e699c310a
This commit is contained in:
Brian Haley 2024-01-17 13:28:18 -05:00
parent 1e75d61bcf
commit bcf33e202f
5 changed files with 11 additions and 11 deletions

View File

@ -36,7 +36,6 @@ disable=
expression-not-assigned,
fixme,
global-statement,
keyword-arg-before-vararg,
non-parent-init-called,
not-callable,
protected-access,

View File

@ -40,7 +40,7 @@ IPV6_STR = "v6"
class DHCPResponderBase(base_oskenapp.BaseNeutronAgentOSKenApp):
def __init__(self, agent_api, ext_api, version=IPV4_STR, *args, **kwargs):
def __init__(self, agent_api, ext_api, *args, version=IPV4_STR, **kwargs):
super(DHCPResponderBase, self).__init__(*args, **kwargs)
self.agent_api = agent_api
self.int_br = self.agent_api.request_int_br()

View File

@ -1656,8 +1656,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
port = self._get_port(context, id, lazy_fields=lazy_fields)
return self._make_port_dict(port, fields)
def _get_ports_query(self, context, filters=None, lazy_fields=None,
*args, **kwargs):
def _get_ports_query(self, context, *args, filters=None, lazy_fields=None,
**kwargs):
Port = models_v2.Port
IPAllocation = models_v2.IPAllocation
@ -1713,7 +1713,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
@db_api.retry_if_session_inactive()
@db_api.CONTEXT_READER
def get_ports_count(self, context, filters=None):
return self._get_ports_query(context, filters).count()
return self._get_ports_query(context, filters=filters).count()
def _enforce_device_owner_not_router_intf_or_device_id(self, context,
device_owner,

View File

@ -2522,7 +2522,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
return port.id
return device
def _get_ports_query(self, context, filters=None, *args, **kwargs):
def _get_ports_query(self, context, *args, filters=None, **kwargs):
filters = filters or {}
security_groups = filters.pop("security_groups", None)
limit = kwargs.pop('limit', None)
@ -2538,8 +2538,9 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
filters['id'] = [entry['port_id'] for entry in port_bindings]
fixed_ips = filters.get('fixed_ips', {})
ip_addresses_s = fixed_ips.get('ip_address_substr')
query = super(Ml2Plugin, self)._get_ports_query(context, filters,
*args, **kwargs)
query = super(Ml2Plugin, self)._get_ports_query(context, *args,
filters=filters,
**kwargs)
if ip_addresses_s:
substr_filter = or_(*[models_v2.Port.fixed_ips.any(
models_v2.IPAllocation.ip_address.like('%%%s%%' % ip))

View File

@ -346,9 +346,9 @@ class Service(n_rpc.Service):
on topic. It also periodically runs tasks on the manager.
"""
def __init__(self, host, binary, topic, manager, report_interval=None,
periodic_interval=None, periodic_fuzzy_delay=None,
*args, **kwargs):
def __init__(self, host, binary, topic, manager, *args,
report_interval=None, periodic_interval=None,
periodic_fuzzy_delay=None, **kwargs):
self.binary = binary
self.manager_class_name = manager