diff --git a/moto/__init__.py b/moto/__init__.py index 36d294657..592a20b07 100644 --- a/moto/__init__.py +++ b/moto/__init__.py @@ -1,5 +1,5 @@ from __future__ import unicode_literals -import logging +# import logging # logging.getLogger('boto').setLevel(logging.CRITICAL) __title__ = 'moto' diff --git a/moto/cloudwatch/responses.py b/moto/cloudwatch/responses.py index bf176e1be..b9f20f559 100644 --- a/moto/cloudwatch/responses.py +++ b/moto/cloudwatch/responses.py @@ -96,11 +96,11 @@ class CloudWatchResponse(BaseResponse): extended_statistics = self._get_param('ExtendedStatistics') dimensions = self._get_param('Dimensions') if unit or extended_statistics or dimensions: - raise NotImplemented() + raise NotImplementedError() # TODO: this should instead throw InvalidParameterCombination if not statistics: - raise NotImplemented("Must specify either Statistics or ExtendedStatistics") + raise NotImplementedError("Must specify either Statistics or ExtendedStatistics") datapoints = self.cloudwatch_backend.get_metric_statistics(namespace, metric_name, start_time, end_time, period, statistics) template = self.response_template(GET_METRIC_STATISTICS_TEMPLATE) diff --git a/moto/dynamodb2/comparisons.py b/moto/dynamodb2/comparisons.py index 734cfeeb3..ab0eeb85d 100644 --- a/moto/dynamodb2/comparisons.py +++ b/moto/dynamodb2/comparisons.py @@ -1,7 +1,5 @@ from __future__ import unicode_literals import re -import six -import re from collections import deque from collections import namedtuple @@ -48,11 +46,11 @@ def get_expected(expected): path = AttributePath([key]) if 'Exists' in cond: if cond['Exists']: - conditions.append(FuncAttrExists(path)) + conditions.append(FuncAttrExists(path)) else: - conditions.append(FuncAttrNotExists(path)) + conditions.append(FuncAttrNotExists(path)) elif 'Value' in cond: - conditions.append(OpEqual(path, AttributeValue(cond['Value']))) + conditions.append(OpEqual(path, AttributeValue(cond['Value']))) elif 'ComparisonOperator' in cond: operator_name = cond['ComparisonOperator'] values = [ @@ -221,7 +219,6 @@ class ConditionExpressionParser: # -------------- LITERAL = 'LITERAL' - class Nonterminal: """Enum defining nonterminals for productions.""" @@ -240,7 +237,6 @@ class ConditionExpressionParser: RIGHT_PAREN = 'RIGHT_PAREN' WHITESPACE = 'WHITESPACE' - Node = namedtuple('Node', ['nonterminal', 'kind', 'text', 'value', 'children']) def _lex_condition_expression(self): @@ -286,11 +282,10 @@ class ConditionExpressionParser: if match: match_text = match.group() break - else: # pragma: no cover + else: # pragma: no cover raise ValueError("Cannot parse condition starting at: " + - remaining_expression) + remaining_expression) - value = match_text node = self.Node( nonterminal=nonterminal, kind=self.Kind.LITERAL, @@ -351,7 +346,6 @@ class ConditionExpressionParser: 'size', } - if name.lower() in reserved: # e.g. AND nonterminal = reserved[name.lower()] @@ -748,14 +742,13 @@ class ConditionExpressionParser: elif node.kind == self.Kind.FUNCTION: # size() function_node = node.children[0] - arguments = node.children[1:] + arguments = node.children[1:] function_name = function_node.value arguments = [self._make_operand(arg) for arg in arguments] return FUNC_CLASS[function_name](*arguments) - else: # pragma: no cover + else: # pragma: no cover raise ValueError("Unknown operand: %r" % node) - def _make_op_condition(self, node): if node.kind == self.Kind.OR: lhs, rhs = node.children @@ -796,7 +789,7 @@ class ConditionExpressionParser: return COMPARATOR_CLASS[comparator.value]( self._make_operand(lhs), self._make_operand(rhs)) - else: # pragma: no cover + else: # pragma: no cover raise ValueError("Unknown expression node kind %r" % node.kind) def _assert(self, condition, message, nodes): diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 10d6f2b28..69fd844fd 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -1229,7 +1229,7 @@ class AmiBackend(object): images = [ami for ami in images if ami.id in ami_ids] if len(images) == 0: - raise InvalidAMIIdError(ami_ids) + raise InvalidAMIIdError(ami_ids) else: # Limit images by launch permissions if exec_users: @@ -3720,8 +3720,8 @@ class VPNConnection(TaggedEC2Resource): self.static_routes = None def get_filter_value(self, filter_name): - return super(VPNConnection, self).get_filter_value( - filter_name, 'DescribeVpnConnections') + return super(VPNConnection, self).get_filter_value( + filter_name, 'DescribeVpnConnections') class VPNConnectionBackend(object): @@ -3950,8 +3950,8 @@ class VpnGateway(TaggedEC2Resource): super(VpnGateway, self).__init__() def get_filter_value(self, filter_name): - return super(VpnGateway, self).get_filter_value( - filter_name, 'DescribeVpnGateways') + return super(VpnGateway, self).get_filter_value( + filter_name, 'DescribeVpnGateways') class VpnGatewayAttachment(object): @@ -4015,8 +4015,8 @@ class CustomerGateway(TaggedEC2Resource): super(CustomerGateway, self).__init__() def get_filter_value(self, filter_name): - return super(CustomerGateway, self).get_filter_value( - filter_name, 'DescribeCustomerGateways') + return super(CustomerGateway, self).get_filter_value( + filter_name, 'DescribeCustomerGateways') class CustomerGatewayBackend(object): diff --git a/moto/ecs/models.py b/moto/ecs/models.py index 5aa9ae2cb..5ba420508 100644 --- a/moto/ecs/models.py +++ b/moto/ecs/models.py @@ -158,8 +158,8 @@ class TaskDefinition(BaseObject): if (original_resource.family != family or original_resource.container_definitions != container_definitions or original_resource.volumes != volumes): - # currently TaskRoleArn isn't stored at TaskDefinition - # instances + # currently TaskRoleArn isn't stored at TaskDefinition + # instances ecs_backend = ecs_backends[region_name] ecs_backend.deregister_task_definition(original_resource.arn) return ecs_backend.register_task_definition( diff --git a/moto/iotdata/models.py b/moto/iotdata/models.py index fec066f07..010017fc3 100644 --- a/moto/iotdata/models.py +++ b/moto/iotdata/models.py @@ -163,7 +163,7 @@ class IoTDataPlaneBackend(BaseBackend): raise InvalidRequestException('State contains an invalid node') if 'version' in payload and thing.thing_shadow.version != payload['version']: - raise ConflictException('Version conflict') + raise ConflictException('Version conflict') new_shadow = FakeShadow.create_from_previous_version(thing.thing_shadow, payload) thing.thing_shadow = new_shadow return thing.thing_shadow diff --git a/moto/rds2/models.py b/moto/rds2/models.py index cd56599e6..b9a250646 100644 --- a/moto/rds2/models.py +++ b/moto/rds2/models.py @@ -875,8 +875,8 @@ class RDS2Backend(BaseBackend): database = self.describe_databases(db_instance_identifier)[0] # todo: certain rds types not allowed to be stopped at this time. if database.is_replica or database.multi_az: - # todo: more db types not supported by stop/start instance api - raise InvalidDBClusterStateFaultError(db_instance_identifier) + # todo: more db types not supported by stop/start instance api + raise InvalidDBClusterStateFaultError(db_instance_identifier) if database.status != 'available': raise InvalidDBInstanceStateError(db_instance_identifier, 'stop') if db_snapshot_identifier: diff --git a/moto/resourcegroupstaggingapi/models.py b/moto/resourcegroupstaggingapi/models.py index 3f15017cc..68430a5bf 100644 --- a/moto/resourcegroupstaggingapi/models.py +++ b/moto/resourcegroupstaggingapi/models.py @@ -244,7 +244,7 @@ class ResourceGroupsTaggingAPIBackend(BaseBackend): def get_kms_tags(kms_key_id): result = [] for tag in self.kms_backend.list_resource_tags(kms_key_id): - result.append({'Key': tag['TagKey'], 'Value': tag['TagValue']}) + result.append({'Key': tag['TagKey'], 'Value': tag['TagValue']}) return result if not resource_type_filters or 'kms' in resource_type_filters: diff --git a/moto/ssm/models.py b/moto/ssm/models.py index 39bd63ede..e5e52c0c9 100644 --- a/moto/ssm/models.py +++ b/moto/ssm/models.py @@ -210,9 +210,9 @@ class Command(BaseModel): 'An error occurred (InvocationDoesNotExist) when calling the GetCommandInvocation operation') if plugin_name is not None and invocation['PluginName'] != plugin_name: - raise RESTError( - 'InvocationDoesNotExist', - 'An error occurred (InvocationDoesNotExist) when calling the GetCommandInvocation operation') + raise RESTError( + 'InvocationDoesNotExist', + 'An error occurred (InvocationDoesNotExist) when calling the GetCommandInvocation operation') return invocation diff --git a/tox.ini b/tox.ini index 570b5790f..1235a8e2b 100644 --- a/tox.ini +++ b/tox.ini @@ -15,5 +15,5 @@ commands = nosetests {posargs} [flake8] -ignore = E128,E501 +ignore = E128,E501,W504,W605 exclude = moto/packages,dist