diff --git a/.pylintrc b/.pylintrc index d343d72a641..595c3e53e68 100644 --- a/.pylintrc +++ b/.pylintrc @@ -27,11 +27,8 @@ disable= not-callable, no-value-for-parameter, super-on-old-class, - too-few-format-args, # "W" Warnings for stylistic problems or minor programming issues abstract-method, - anomalous-backslash-in-string, - anomalous-unicode-escape-in-string, arguments-differ, attribute-defined-outside-init, bad-builtin, diff --git a/neutron/agent/linux/ip_link_support.py b/neutron/agent/linux/ip_link_support.py index 146cd06ee23..77bd0afedfe 100644 --- a/neutron/agent/linux/ip_link_support.py +++ b/neutron/agent/linux/ip_link_support.py @@ -45,10 +45,10 @@ class IpLinkConstants(object): class IpLinkSupport(object): - VF_BLOCK_REGEX = "\[ vf NUM(?P.*) \] \]" + VF_BLOCK_REGEX = r"\[ vf NUM(?P.*) \] \]" - CAPABILITY_REGEX = "\[ %s (.*)" - SUB_CAPABILITY_REGEX = "\[ %(cap)s (.*) \[ %(subcap)s (.*)" + CAPABILITY_REGEX = r"\[ %s (.*)" + SUB_CAPABILITY_REGEX = r"\[ %(cap)s (.*) \[ %(subcap)s (.*)" @classmethod def get_vf_mgmt_section(cls, root_helper=None): diff --git a/neutron/api/v2/attributes.py b/neutron/api/v2/attributes.py index b9ac5730d95..7540509d8bf 100644 --- a/neutron/api/v2/attributes.py +++ b/neutron/api/v2/attributes.py @@ -143,7 +143,7 @@ def _validate_range(data, valid_values=None): def _validate_no_whitespace(data): """Validates that input has no whitespace.""" - if re.search('\s', data): + if re.search(r'\s', data): msg = _("'%s' contains whitespace") % data LOG.debug(msg) raise n_exc.InvalidInput(error_message=msg) diff --git a/neutron/extensions/loadbalancer.py b/neutron/extensions/loadbalancer.py index fdc23d8265e..40ef4d9be50 100644 --- a/neutron/extensions/loadbalancer.py +++ b/neutron/extensions/loadbalancer.py @@ -274,7 +274,7 @@ RESOURCE_ATTRIBUTE_MAP = { 'expected_codes': {'allow_post': True, 'allow_put': True, 'validate': { 'type:regex': - '^(\d{3}(\s*,\s*\d{3})*)$|^(\d{3}-\d{3})$'}, + r'^(\d{3}(\s*,\s*\d{3})*)$|^(\d{3}-\d{3})$'}, 'default': '200', 'is_visible': True}, 'admin_state_up': {'allow_post': True, 'allow_put': True, diff --git a/neutron/extensions/loadbalancerv2.py b/neutron/extensions/loadbalancerv2.py index 6b2f8eee50d..8ecb5b6833a 100644 --- a/neutron/extensions/loadbalancerv2.py +++ b/neutron/extensions/loadbalancerv2.py @@ -280,7 +280,7 @@ RESOURCE_ATTRIBUTE_MAP = { 'allow_post': True, 'allow_put': True, 'validate': { - 'type:regex': '^(\d{3}(\s*,\s*\d{3})*)$|^(\d{3}-\d{3})$' + 'type:regex': r'^(\d{3}(\s*,\s*\d{3})*)$|^(\d{3}-\d{3})$' }, 'default': '200', 'is_visible': True diff --git a/neutron/plugins/bigswitch/db/consistency_db.py b/neutron/plugins/bigswitch/db/consistency_db.py index f9dd8d1eacb..622ee3f5bf2 100644 --- a/neutron/plugins/bigswitch/db/consistency_db.py +++ b/neutron/plugins/bigswitch/db/consistency_db.py @@ -119,7 +119,7 @@ class HashHandler(object): return result.rowcount != 0 def _get_lock_owner(self, record): - matches = re.findall("^LOCKED_BY\[(\w+)\]", record) + matches = re.findall(r"^LOCKED_BY\[(\w+)\]", record) if not matches: return None return matches[0] diff --git a/neutron/plugins/midonet/midonet_lib.py b/neutron/plugins/midonet/midonet_lib.py index 863a858d1f1..b4d206a33ff 100644 --- a/neutron/plugins/midonet/midonet_lib.py +++ b/neutron/plugins/midonet/midonet_lib.py @@ -72,7 +72,7 @@ class MidoClient: def create_bridge(self, **kwargs): """Create a new bridge - :param \**kwargs: configuration of the new bridge + :param kwargs: configuration of the new bridge :returns: newly created bridge """ LOG.debug("MidoClient.create_bridge called: " @@ -106,7 +106,7 @@ class MidoClient: """Update a bridge of the given id with the new fields :param id: id of the bridge - :param \**kwargs: the fields to update and their values + :param kwargs: the fields to update and their values :returns: bridge object """ LOG.debug("MidoClient.update_bridge called: " @@ -250,7 +250,7 @@ class MidoClient: """Add a port on a bridge :param bridge: bridge to add a new port to - :param \**kwargs: configuration of the new port + :param kwargs: configuration of the new port :returns: newly created port """ LOG.debug("MidoClient.add_bridge_port called: " @@ -263,7 +263,7 @@ class MidoClient: """Update a port of the given id with the new fields :param id: id of the port - :param \**kwargs: the fields to update and their values + :param kwargs: the fields to update and their values """ LOG.debug("MidoClient.update_port called: " "id=%(id)s, kwargs=%(kwargs)s", @@ -278,7 +278,7 @@ class MidoClient: """Add a new port to an existing router. :param router: router to add a new port to - :param \**kwargs: configuration of the new port + :param kwargs: configuration of the new port :returns: newly created port """ return self._create_dto(self.mido_api.add_router_port(router), kwargs) @@ -287,7 +287,7 @@ class MidoClient: def create_router(self, **kwargs): """Create a new router - :param \**kwargs: configuration of the new router + :param kwargs: configuration of the new router :returns: newly created router """ LOG.debug("MidoClient.create_router called: " @@ -321,7 +321,7 @@ class MidoClient: """Update a router of the given id with the new name :param id: id of the router - :param \**kwargs: the fields to update and their values + :param kwargs: the fields to update and their values :returns: router object """ LOG.debug("MidoClient.update_router called: " diff --git a/neutron/plugins/ml2/drivers/cisco/apic/apic_topology.py b/neutron/plugins/ml2/drivers/cisco/apic/apic_topology.py index b747bb9a542..29b03eae9a3 100644 --- a/neutron/plugins/ml2/drivers/cisco/apic/apic_topology.py +++ b/neutron/plugins/ml2/drivers/cisco/apic/apic_topology.py @@ -42,8 +42,8 @@ from neutron.plugins.ml2.drivers import type_vlan # noqa from neutron import service ACI_PORT_DESCR_FORMATS = [ - 'topology/pod-1/node-(\d+)/sys/conng/path-\[eth(\d+)/(\d+)\]', - 'topology/pod-1/paths-(\d+)/pathep-\[eth(\d+)/(\d+)\]', + r'topology/pod-1/node-(\d+)/sys/conng/path-\[eth(\d+)/(\d+)\]', + r'topology/pod-1/paths-(\d+)/pathep-\[eth(\d+)/(\d+)\]', ] AGENT_FORCE_UPDATE_COUNT = 100 BINARY_APIC_SERVICE_AGENT = 'neutron-cisco-apic-service-agent' diff --git a/neutron/plugins/sriovnicagent/eswitch_manager.py b/neutron/plugins/sriovnicagent/eswitch_manager.py index bd1841fffd9..0f8e1080846 100644 --- a/neutron/plugins/sriovnicagent/eswitch_manager.py +++ b/neutron/plugins/sriovnicagent/eswitch_manager.py @@ -30,7 +30,7 @@ class PciOsWrapper(object): DEVICE_PATH = "/sys/class/net/%s/device" PCI_PATH = "/sys/class/net/%s/device/virtfn%s/net" - VIRTFN_FORMAT = "^virtfn(?P\d+)" + VIRTFN_FORMAT = r"^virtfn(?P\d+)" VIRTFN_REG_EX = re.compile(VIRTFN_FORMAT) MAC_VTAP_PREFIX = "upper_macvtap*" diff --git a/neutron/policy.py b/neutron/policy.py index f68dabfb007..11e4bf45b23 100644 --- a/neutron/policy.py +++ b/neutron/policy.py @@ -246,7 +246,7 @@ class OwnerCheck(policy.Check): def __init__(self, kind, match): # Process the match try: - self.target_field = re.findall('^\%\((.*)\)s$', + self.target_field = re.findall(r'^\%\((.*)\)s$', match)[0] except IndexError: err_reason = (_("Unable to identify a target field from:%s."