diff options
author | Erik Olof Gunnar Andersson <eandersson@blizzard.com> | 2019-07-04 00:29:33 -0700 |
---|---|---|
committer | Erik Olof Gunnar Andersson <eandersson@blizzard.com> | 2019-07-04 00:33:00 -0700 |
commit | 2c9e9f5f41d4fdf6a5f4f9870e0bb261c53d4e94 (patch) | |
tree | f185bfc502f352d8cfef47c68bb4f6d595115b90 | |
parent | 973cafd79b8f4a0866a3474383e74a4e56d0f881 (diff) | |
download | designate-2c9e9f5f41d4fdf6a5f4f9870e0bb261c53d4e94.tar.gz |
Bump to hacking 1.1.0
* Minor changes to fix some new checks.
* Use pycodestyle directly instead of pep8.
Change-Id: I5fbe877f8d05c1b25bf760e52ea8abdfd0a2d8d9
-rw-r--r-- | designate/__init__.py | 2 | ||||
-rw-r--r-- | designate/api/middleware.py | 4 | ||||
-rw-r--r-- | designate/central/service.py | 8 | ||||
-rw-r--r-- | designate/conf/__init__.py | 9 | ||||
-rw-r--r-- | designate/hacking/checks.py | 6 | ||||
-rw-r--r-- | designate/mdns/notify.py | 7 | ||||
-rw-r--r-- | designate/objects/base.py | 20 | ||||
-rw-r--r-- | designate/objects/fields.py | 6 | ||||
-rw-r--r-- | designate/rpc.py | 22 | ||||
-rw-r--r-- | designate/schema/_validators.py | 8 | ||||
-rw-r--r-- | test-requirements.txt | 2 |
11 files changed, 44 insertions, 50 deletions
diff --git a/designate/__init__.py b/designate/__init__.py index d68a08c7..45dfced4 100644 --- a/designate/__init__.py +++ b/designate/__init__.py @@ -17,7 +17,7 @@ import os # Eventlet's GreenDNS Patching will prevent the resolution of names in # 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_concurrency import lockutils diff --git a/designate/api/middleware.py b/designate/api/middleware.py index a67c452a..5860594b 100644 --- a/designate/api/middleware.py +++ b/designate/api/middleware.py @@ -207,8 +207,8 @@ class MaintenanceMiddleware(base.Middleware): return None # If the caller has the bypass role, let them through - if ('context' in request.environ - and self.role in request.environ['context'].roles): + if ('context' in request.environ and + self.role in request.environ['context'].roles): LOG.warning('Request authorized to bypass maintenance mode') return None diff --git a/designate/central/service.py b/designate/central/service.py index 892805d3..169f7fbe 100644 --- a/designate/central/service.py +++ b/designate/central/service.py @@ -317,8 +317,8 @@ class Service(service.RPCService, service.Service): raise exceptions.InvalidRecordSetName('Name too long') # RecordSets must be contained in the parent zone - if (recordset_name != zone['name'] - and not recordset_name.endswith("." + zone['name'])): + if (recordset_name != zone['name'] and + not recordset_name.endswith("." + zone['name'])): raise exceptions.InvalidRecordSetLocation( '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) - if ((len(recordsets) == 1 and recordsets[0].id != recordset_id) - or len(recordsets) > 1): + if ((len(recordsets) == 1 and recordsets[0].id != recordset_id) or + len(recordsets) > 1): raise exceptions.InvalidRecordSetLocation( 'CNAME recordsets may not share a name with any other records') diff --git a/designate/conf/__init__.py b/designate/conf/__init__.py index 063889e1..5c402980 100644 --- a/designate/conf/__init__.py +++ b/designate/conf/__init__.py @@ -11,15 +11,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - from oslo_config import cfg -CONF = cfg.CONF - from designate.conf import base # noqa - -base.register_opts(CONF) # noqa - from designate.conf import akamai from designate.conf import agent from designate.conf import api @@ -45,6 +39,9 @@ from designate.conf import sink from designate.conf import storage from designate.conf import worker +CONF = cfg.CONF + +base.register_opts(CONF) akamai.register_opts(CONF) agent.register_opts(CONF) api.register_opts(CONF) diff --git a/designate/hacking/checks.py b/designate/hacking/checks.py index e092a0d4..e2bf40ed 100644 --- a/designate/hacking/checks.py +++ b/designate/hacking/checks.py @@ -14,8 +14,7 @@ # under the License. import re -import pep8 - +import pycodestyle # D701: Default parameter value is a mutable type # 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. # D709: LOG.audit is deprecated, please use LOG.info! - UNDERSCORE_IMPORT_FILES = [] @@ -47,7 +45,7 @@ graduated_oslo_libraries_import_re = re.compile( def mutable_default_arguments(logical_line, physical_line, filename): - if pep8.noqa(physical_line): + if pycodestyle.noqa(physical_line): return if mutable_default_argument_check.match(logical_line): diff --git a/designate/mdns/notify.py b/designate/mdns/notify.py index 4aa017d1..a8f54b05 100644 --- a/designate/mdns/notify.py +++ b/designate/mdns/notify.py @@ -127,9 +127,10 @@ class NotifyEndpoint(base.BaseEndpoint): response, retry_cnt = self._make_and_send_dns_message( zone, host, port, timeout, retry_interval, retries_left) - if response and (response.rcode() in ( - dns.rcode.NXDOMAIN, dns.rcode.REFUSED, dns.rcode.SERVFAIL) - or not bool(response.answer)): + if response and (response.rcode() in (dns.rcode.NXDOMAIN, + dns.rcode.REFUSED, + dns.rcode.SERVFAIL) or + not bool(response.answer)): status = 'NO_ZONE' if zone.serial == 0 and zone.action in ('DELETE', 'NONE'): actual_serial = 0 diff --git a/designate/objects/base.py b/designate/objects/base.py index 10f29ed1..de7fa822 100644 --- a/designate/objects/base.py +++ b/designate/objects/base.py @@ -128,13 +128,13 @@ class DesignateObject(base.VersionedObject): def __setattr__(self, name, value): """Enforces all object attributes are private or well defined""" - if not (name[0:5] == '_obj_' - or name[0:7] == '_change' - or name == '_context' - or name in list(six.iterkeys(self.fields)) - or name == 'FIELDS' - or name == 'VERSION' - or name == 'fields'): + if not (name[0:5] == '_obj_' or + name[0:7] == '_change' or + name == '_context' or + name in list(six.iterkeys(self.fields)) or + name == 'FIELDS' or + name == 'VERSION' or + name == 'fields'): raise AttributeError( "Designate object '%(type)s' has no" "attribute '%(name)s'" % { @@ -507,9 +507,9 @@ class DesignateRegistry(base.VersionedObjectRegistry): self._changed_fields.add(name) # TODO(daidv): _obj_original_values shoud be removed # after OVO migration completed. - if (self.obj_attr_is_set(name) and value != getattr(self, name) - and name not in list(six.iterkeys( - self._obj_original_values))): + if (self.obj_attr_is_set(name) and + value != getattr(self, name) and + name not in list(six.iterkeys(self._obj_original_values))): # noqa self._obj_original_values[name] = getattr(self, name) try: return setattr(self, attrname, field_value) diff --git a/designate/objects/fields.py b/designate/objects/fields.py index 6fa9a691..19a52c0d 100644 --- a/designate/objects/fields.py +++ b/designate/objects/fields.py @@ -93,11 +93,9 @@ class IntegerFields(IntegerField): class StringFields(ovoo_fields.StringField): RE_HOSTNAME = r'^(?!.{255,})(?:(?:^\*|(?!\-)[A-Za-z0-9_\-]{1,63})(?<!\-)\.)+\Z' # noqa RE_ZONENAME = r'^(?!.{255,})(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)\.)+\Z' - RE_SRV_HOST_NAME = r'^(?:(?!\-)(?:\_[A-Za-z0-9_\-]{1,63}\.){2})(?!.{255,})'\ - r'(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)\.)+\Z' + RE_SRV_HOST_NAME = r'^(?:(?!\-)(?:\_[A-Za-z0-9_\-]{1,63}\.){2})(?!.{255,})(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)\.)+\Z' # noqa 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}(?<!\-))' \ - r'(?:\.(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)))*\Z' + RE_TLDNAME = r'^(?!.{255,})(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-))(?:\.(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)))*\Z' # noqa 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_REGEXP = r'^([^0-9i\\])(.*)\1((.+)|(\\[1-9]))\1(i?)' diff --git a/designate/rpc.py b/designate/rpc.py index 74b9231f..97b4ad45 100644 --- a/designate/rpc.py +++ b/designate/rpc.py @@ -11,6 +11,17 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # 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__ = [ 'init', @@ -25,17 +36,6 @@ __all__ = [ '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 EXPECTED_EXCEPTION = threading.local() NOTIFICATION_TRANSPORT = None diff --git a/designate/schema/_validators.py b/designate/schema/_validators.py index 072c0fcc..8180a086 100644 --- a/designate/schema/_validators.py +++ b/designate/schema/_validators.py @@ -23,8 +23,8 @@ def type_draft3(validator, types, instance, schema): types = _utils.ensure_list(types) # NOTE(kiall): A datetime object is not a string, but is still valid. - if ('format' in schema and schema['format'] == 'date-time' - and isinstance(instance, datetime.datetime)): + if ('format' in schema and schema['format'] == 'date-time' and + isinstance(instance, datetime.datetime)): return all_errors = [] @@ -71,8 +71,8 @@ def type_draft4(validator, types, instance, schema): types = _utils.ensure_list(types) # NOTE(kiall): A datetime object is not a string, but is still valid. - if ('format' in schema and schema['format'] == 'date-time' - and isinstance(instance, datetime.datetime)): + if ('format' in schema and schema['format'] == 'date-time' and + isinstance(instance, datetime.datetime)): return if not any(validator.is_type(instance, type) for type in types): diff --git a/test-requirements.txt b/test-requirements.txt index 237bfa3a..da11a6a6 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,7 @@ # process, which may cause wedges in the gate later. # 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 fixtures>=3.0.0 # Apache-2.0/BSD mock>=2.0.0 # BSD |