Bump to hacking 1.1.0

* Minor changes to fix some new checks.
* Use pycodestyle directly instead of pep8.

Change-Id: I5fbe877f8d05c1b25bf760e52ea8abdfd0a2d8d9
This commit is contained in:
Erik Olof Gunnar Andersson 2019-07-04 00:29:33 -07:00
parent 973cafd79b
commit 2c9e9f5f41
11 changed files with 44 additions and 50 deletions

View File

@ -17,7 +17,7 @@ import os
# Eventlet's GreenDNS Patching will prevent the resolution of names in # Eventlet's GreenDNS Patching will prevent the resolution of names in
# the /etc/hosts file, causing problems for installs. # the /etc/hosts file, causing problems for installs.
os.environ['EVENTLET_NO_GREENDNS'] = 'yes' os.environ['EVENTLET_NO_GREENDNS'] = 'yes' # noqa
from oslo_log import log from oslo_log import log
from oslo_concurrency import lockutils from oslo_concurrency import lockutils

View File

@ -207,8 +207,8 @@ class MaintenanceMiddleware(base.Middleware):
return None return None
# If the caller has the bypass role, let them through # If the caller has the bypass role, let them through
if ('context' in request.environ if ('context' in request.environ and
and self.role in request.environ['context'].roles): self.role in request.environ['context'].roles):
LOG.warning('Request authorized to bypass maintenance mode') LOG.warning('Request authorized to bypass maintenance mode')
return None return None

View File

@ -317,8 +317,8 @@ class Service(service.RPCService, service.Service):
raise exceptions.InvalidRecordSetName('Name too long') raise exceptions.InvalidRecordSetName('Name too long')
# RecordSets must be contained in the parent zone # RecordSets must be contained in the parent zone
if (recordset_name != zone['name'] if (recordset_name != zone['name'] and
and not recordset_name.endswith("." + zone['name'])): not recordset_name.endswith("." + zone['name'])):
raise exceptions.InvalidRecordSetLocation( raise exceptions.InvalidRecordSetLocation(
'RecordSet is not contained within it\'s parent zone') 'RecordSet is not contained within it\'s parent zone')
@ -340,8 +340,8 @@ class Service(service.RPCService, service.Service):
recordsets = self.storage.find_recordsets(context, criterion) recordsets = self.storage.find_recordsets(context, criterion)
if ((len(recordsets) == 1 and recordsets[0].id != recordset_id) if ((len(recordsets) == 1 and recordsets[0].id != recordset_id) or
or len(recordsets) > 1): len(recordsets) > 1):
raise exceptions.InvalidRecordSetLocation( raise exceptions.InvalidRecordSetLocation(
'CNAME recordsets may not share a name with any other records') 'CNAME recordsets may not share a name with any other records')

View File

@ -11,15 +11,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_config import cfg from oslo_config import cfg
CONF = cfg.CONF
from designate.conf import base # noqa from designate.conf import base # noqa
base.register_opts(CONF) # noqa
from designate.conf import akamai from designate.conf import akamai
from designate.conf import agent from designate.conf import agent
from designate.conf import api from designate.conf import api
@ -45,6 +39,9 @@ from designate.conf import sink
from designate.conf import storage from designate.conf import storage
from designate.conf import worker from designate.conf import worker
CONF = cfg.CONF
base.register_opts(CONF)
akamai.register_opts(CONF) akamai.register_opts(CONF)
agent.register_opts(CONF) agent.register_opts(CONF)
api.register_opts(CONF) api.register_opts(CONF)

View File

@ -14,8 +14,7 @@
# under the License. # under the License.
import re import re
import pep8 import pycodestyle
# D701: Default parameter value is a mutable type # D701: Default parameter value is a mutable type
# D702: Log messages require translation # D702: Log messages require translation
@ -27,7 +26,6 @@ import pep8
# D708: Do not use xrange. Use range, or six.moves.range for large loops. # D708: Do not use xrange. Use range, or six.moves.range for large loops.
# D709: LOG.audit is deprecated, please use LOG.info! # D709: LOG.audit is deprecated, please use LOG.info!
UNDERSCORE_IMPORT_FILES = [] UNDERSCORE_IMPORT_FILES = []
@ -47,7 +45,7 @@ graduated_oslo_libraries_import_re = re.compile(
def mutable_default_arguments(logical_line, physical_line, filename): def mutable_default_arguments(logical_line, physical_line, filename):
if pep8.noqa(physical_line): if pycodestyle.noqa(physical_line):
return return
if mutable_default_argument_check.match(logical_line): if mutable_default_argument_check.match(logical_line):

View File

@ -127,9 +127,10 @@ class NotifyEndpoint(base.BaseEndpoint):
response, retry_cnt = self._make_and_send_dns_message( response, retry_cnt = self._make_and_send_dns_message(
zone, host, port, timeout, retry_interval, retries_left) zone, host, port, timeout, retry_interval, retries_left)
if response and (response.rcode() in ( if response and (response.rcode() in (dns.rcode.NXDOMAIN,
dns.rcode.NXDOMAIN, dns.rcode.REFUSED, dns.rcode.SERVFAIL) dns.rcode.REFUSED,
or not bool(response.answer)): dns.rcode.SERVFAIL) or
not bool(response.answer)):
status = 'NO_ZONE' status = 'NO_ZONE'
if zone.serial == 0 and zone.action in ('DELETE', 'NONE'): if zone.serial == 0 and zone.action in ('DELETE', 'NONE'):
actual_serial = 0 actual_serial = 0

View File

@ -128,13 +128,13 @@ class DesignateObject(base.VersionedObject):
def __setattr__(self, name, value): def __setattr__(self, name, value):
"""Enforces all object attributes are private or well defined""" """Enforces all object attributes are private or well defined"""
if not (name[0:5] == '_obj_' if not (name[0:5] == '_obj_' or
or name[0:7] == '_change' name[0:7] == '_change' or
or name == '_context' name == '_context' or
or name in list(six.iterkeys(self.fields)) name in list(six.iterkeys(self.fields)) or
or name == 'FIELDS' name == 'FIELDS' or
or name == 'VERSION' name == 'VERSION' or
or name == 'fields'): name == 'fields'):
raise AttributeError( raise AttributeError(
"Designate object '%(type)s' has no" "Designate object '%(type)s' has no"
"attribute '%(name)s'" % { "attribute '%(name)s'" % {
@ -507,9 +507,9 @@ class DesignateRegistry(base.VersionedObjectRegistry):
self._changed_fields.add(name) self._changed_fields.add(name)
# TODO(daidv): _obj_original_values shoud be removed # TODO(daidv): _obj_original_values shoud be removed
# after OVO migration completed. # after OVO migration completed.
if (self.obj_attr_is_set(name) and value != getattr(self, name) if (self.obj_attr_is_set(name) and
and name not in list(six.iterkeys( value != getattr(self, name) and
self._obj_original_values))): name not in list(six.iterkeys(self._obj_original_values))): # noqa
self._obj_original_values[name] = getattr(self, name) self._obj_original_values[name] = getattr(self, name)
try: try:
return setattr(self, attrname, field_value) return setattr(self, attrname, field_value)

View File

@ -93,11 +93,9 @@ class IntegerFields(IntegerField):
class StringFields(ovoo_fields.StringField): class StringFields(ovoo_fields.StringField):
RE_HOSTNAME = r'^(?!.{255,})(?:(?:^\*|(?!\-)[A-Za-z0-9_\-]{1,63})(?<!\-)\.)+\Z' # noqa RE_HOSTNAME = r'^(?!.{255,})(?:(?:^\*|(?!\-)[A-Za-z0-9_\-]{1,63})(?<!\-)\.)+\Z' # noqa
RE_ZONENAME = r'^(?!.{255,})(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)\.)+\Z' RE_ZONENAME = r'^(?!.{255,})(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)\.)+\Z'
RE_SRV_HOST_NAME = r'^(?:(?!\-)(?:\_[A-Za-z0-9_\-]{1,63}\.){2})(?!.{255,})'\ RE_SRV_HOST_NAME = r'^(?:(?!\-)(?:\_[A-Za-z0-9_\-]{1,63}\.){2})(?!.{255,})(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)\.)+\Z' # noqa
r'(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)\.)+\Z'
RE_SSHFP_FINGERPRINT = r'^([0-9A-Fa-f]{10,40}|[0-9A-Fa-f]{64})\Z' RE_SSHFP_FINGERPRINT = r'^([0-9A-Fa-f]{10,40}|[0-9A-Fa-f]{64})\Z'
RE_TLDNAME = r'^(?!.{255,})(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-))' \ RE_TLDNAME = r'^(?!.{255,})(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-))(?:\.(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)))*\Z' # noqa
r'(?:\.(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)))*\Z'
RE_NAPTR_FLAGS = r'^(?!.*(.).*\1)[APSU]+$' RE_NAPTR_FLAGS = r'^(?!.*(.).*\1)[APSU]+$'
RE_NAPTR_SERVICE = r'^([A-Za-z]([A-Za-z0-9]*)(\+[A-Za-z]([A-Za-z0-9]{0,31}))*)?' # noqa RE_NAPTR_SERVICE = r'^([A-Za-z]([A-Za-z0-9]*)(\+[A-Za-z]([A-Za-z0-9]{0,31}))*)?' # noqa
RE_NAPTR_REGEXP = r'^([^0-9i\\])(.*)\1((.+)|(\\[1-9]))\1(i?)' RE_NAPTR_REGEXP = r'^([^0-9i\\])(.*)\1((.+)|(\\[1-9]))\1(i?)'

View File

@ -11,6 +11,17 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import functools
import threading
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_messaging.rpc import dispatcher as rpc_dispatcher
from oslo_serialization import jsonutils
from designate import objects
import designate.context
import designate.exceptions
__all__ = [ __all__ = [
'init', 'init',
@ -25,17 +36,6 @@ __all__ = [
'get_notifier', 'get_notifier',
] ]
import functools
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_messaging.rpc import dispatcher as rpc_dispatcher
from oslo_serialization import jsonutils
import threading
import designate.context
import designate.exceptions
from designate import objects
CONF = cfg.CONF CONF = cfg.CONF
EXPECTED_EXCEPTION = threading.local() EXPECTED_EXCEPTION = threading.local()
NOTIFICATION_TRANSPORT = None NOTIFICATION_TRANSPORT = None

View File

@ -23,8 +23,8 @@ def type_draft3(validator, types, instance, schema):
types = _utils.ensure_list(types) types = _utils.ensure_list(types)
# NOTE(kiall): A datetime object is not a string, but is still valid. # NOTE(kiall): A datetime object is not a string, but is still valid.
if ('format' in schema and schema['format'] == 'date-time' if ('format' in schema and schema['format'] == 'date-time' and
and isinstance(instance, datetime.datetime)): isinstance(instance, datetime.datetime)):
return return
all_errors = [] all_errors = []
@ -71,8 +71,8 @@ def type_draft4(validator, types, instance, schema):
types = _utils.ensure_list(types) types = _utils.ensure_list(types)
# NOTE(kiall): A datetime object is not a string, but is still valid. # NOTE(kiall): A datetime object is not a string, but is still valid.
if ('format' in schema and schema['format'] == 'date-time' if ('format' in schema and schema['format'] == 'date-time' and
and isinstance(instance, datetime.datetime)): isinstance(instance, datetime.datetime)):
return return
if not any(validator.is_type(instance, type) for type in types): if not any(validator.is_type(instance, type) for type in types):

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8 # Hacking already pins down pep8, pyflakes and flake8
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 hacking>=1.1.0,<1.2.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD
mock>=2.0.0 # BSD mock>=2.0.0 # BSD