From 72da9e96c2eb63d4752116fa2cee5d1d2f624522 Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Thu, 21 Nov 2019 17:53:58 -0500 Subject: [PATCH] Lint. --- moto/batch/models.py | 4 +++- moto/cloudformation/responses.py | 4 +++- moto/datasync/responses.py | 2 +- moto/datasync/urls.py | 4 +--- moto/events/models.py | 3 +-- moto/events/responses.py | 10 ++-------- moto/iam/models.py | 4 +++- moto/iam/policy_validation.py | 4 +++- tests/test_apigateway/test_apigateway.py | 2 +- tests/test_dynamodb2/test_dynamodb.py | 4 ++-- tests/test_dynamodbstreams/test_dynamodbstreams.py | 5 ++++- tests/test_ecs/test_ecs_boto3.py | 4 +++- tests/test_iam/test_iam.py | 4 +--- 13 files changed, 28 insertions(+), 26 deletions(-) diff --git a/moto/batch/models.py b/moto/batch/models.py index ab52db54c..1a28fdcc5 100644 --- a/moto/batch/models.py +++ b/moto/batch/models.py @@ -302,7 +302,9 @@ class Job(threading.Thread, BaseModel): self.job_id = str(uuid.uuid4()) self.job_definition = job_def self.job_queue = job_queue - self.job_state = "SUBMITTED" # One of SUBMITTED | PENDING | RUNNABLE | STARTING | RUNNING | SUCCEEDED | FAILED + self.job_state = ( + "SUBMITTED" + ) # One of SUBMITTED | PENDING | RUNNABLE | STARTING | RUNNING | SUCCEEDED | FAILED self.job_queue.jobs.append(self) self.job_started_at = datetime.datetime(1970, 1, 1) self.job_stopped_at = datetime.datetime(1970, 1, 1) diff --git a/moto/cloudformation/responses.py b/moto/cloudformation/responses.py index f5e094c15..fe875fed5 100644 --- a/moto/cloudformation/responses.py +++ b/moto/cloudformation/responses.py @@ -177,7 +177,9 @@ class CloudFormationResponse(BaseResponse): start = stack_ids.index(token) + 1 else: start = 0 - max_results = 50 # using this to mske testing of paginated stacks more convenient than default 1 MB + max_results = ( + 50 + ) # using this to mske testing of paginated stacks more convenient than default 1 MB stacks_resp = stacks[start : start + max_results] next_token = None if len(stacks) > (start + max_results): diff --git a/moto/datasync/responses.py b/moto/datasync/responses.py index 23a480523..03811fb6e 100644 --- a/moto/datasync/responses.py +++ b/moto/datasync/responses.py @@ -153,7 +153,7 @@ class DataSyncResponse(BaseResponse): task_execution_arn = self._get_param("TaskExecutionArn") task_execution = self.datasync_backend._get_task_execution(task_execution_arn) result = json.dumps( - {"TaskExecutionArn": task_execution.arn, "Status": task_execution.status,} + {"TaskExecutionArn": task_execution.arn, "Status": task_execution.status} ) if task_execution.status == "SUCCESS": self.datasync_backend.tasks[task_execution.task_arn].status = "AVAILABLE" diff --git a/moto/datasync/urls.py b/moto/datasync/urls.py index b70a09f27..69ba3cccb 100644 --- a/moto/datasync/urls.py +++ b/moto/datasync/urls.py @@ -4,6 +4,4 @@ from .responses import DataSyncResponse url_bases = ["https?://(.*?)(datasync)(.*?).amazonaws.com"] -url_paths = { - "{0}/$": DataSyncResponse.dispatch, -} +url_paths = {"{0}/$": DataSyncResponse.dispatch} diff --git a/moto/events/models.py b/moto/events/models.py index be4153b9f..0298c7c69 100644 --- a/moto/events/models.py +++ b/moto/events/models.py @@ -316,8 +316,7 @@ class EventsBackend(BaseBackend): if not event_bus: raise JsonRESTError( - "ResourceNotFoundException", - "Event bus {} does not exist.".format(name), + "ResourceNotFoundException", "Event bus {} does not exist.".format(name) ) return event_bus diff --git a/moto/events/responses.py b/moto/events/responses.py index 98a33218a..b415564f8 100644 --- a/moto/events/responses.py +++ b/moto/events/responses.py @@ -261,10 +261,7 @@ class EventsHandler(BaseResponse): name = self._get_param("Name") event_bus = self.events_backend.describe_event_bus(name) - response = { - "Name": event_bus.name, - "Arn": event_bus.arn, - } + response = {"Name": event_bus.name, "Arn": event_bus.arn} if event_bus.policy: response["Policy"] = event_bus.policy @@ -285,10 +282,7 @@ class EventsHandler(BaseResponse): response = [] for event_bus in self.events_backend.list_event_buses(name_prefix): - event_bus_response = { - "Name": event_bus.name, - "Arn": event_bus.arn, - } + event_bus_response = {"Name": event_bus.name, "Arn": event_bus.arn} if event_bus.policy: event_bus_response["Policy"] = event_bus.policy diff --git a/moto/iam/models.py b/moto/iam/models.py index 73d58b996..9b6f4875c 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -788,7 +788,9 @@ class AccountSummary(BaseModel): self._groups_per_user_quota = 10 self._attached_policies_per_user_quota = 10 self._policies_quota = 1500 - self._account_mfa_enabled = 0 # Haven't found any information being able to activate MFA for the root account programmatically + self._account_mfa_enabled = ( + 0 + ) # Haven't found any information being able to activate MFA for the root account programmatically self._access_keys_per_user_quota = 2 self._assume_role_policy_size_quota = 2048 self._policy_versions_in_use_quota = 10000 diff --git a/moto/iam/policy_validation.py b/moto/iam/policy_validation.py index 95610ac4d..c1a16cc5d 100644 --- a/moto/iam/policy_validation.py +++ b/moto/iam/policy_validation.py @@ -88,7 +88,9 @@ class IAMPolicyDocumentValidator: self._policy_document = policy_document self._policy_json = {} self._statements = [] - self._resource_error = "" # the first resource error found that does not generate a legacy parsing error + self._resource_error = ( + "" + ) # the first resource error found that does not generate a legacy parsing error def validate(self): try: diff --git a/tests/test_apigateway/test_apigateway.py b/tests/test_apigateway/test_apigateway.py index de99f1fcf..8da5efa39 100644 --- a/tests/test_apigateway/test_apigateway.py +++ b/tests/test_apigateway/test_apigateway.py @@ -563,7 +563,7 @@ def test_create_stage(): api_id = response["id"] create_method_integration(client, api_id) - response = client.create_deployment(restApiId=api_id, stageName=stage_name,) + response = client.create_deployment(restApiId=api_id, stageName=stage_name) deployment_id = response["id"] response = client.get_deployment(restApiId=api_id, deploymentId=deployment_id) diff --git a/tests/test_dynamodb2/test_dynamodb.py b/tests/test_dynamodb2/test_dynamodb.py index 2b0833d98..456311028 100644 --- a/tests/test_dynamodb2/test_dynamodb.py +++ b/tests/test_dynamodb2/test_dynamodb.py @@ -3335,7 +3335,7 @@ def test_update_item_if_original_value_is_none(): table.update_item( Key={"job_id": "a"}, UpdateExpression="SET job_name = :output", - ExpressionAttributeValues={":output": "updated",}, + ExpressionAttributeValues={":output": "updated"}, ) table.scan()["Items"][0]["job_name"].should.equal("updated") @@ -3354,7 +3354,7 @@ def test_update_nested_item_if_original_value_is_none(): table.update_item( Key={"job_id": "a"}, UpdateExpression="SET job_details.job_name = :output", - ExpressionAttributeValues={":output": "updated",}, + ExpressionAttributeValues={":output": "updated"}, ) table.scan()["Items"][0]["job_details"]["job_name"].should.equal("updated") diff --git a/tests/test_dynamodbstreams/test_dynamodbstreams.py b/tests/test_dynamodbstreams/test_dynamodbstreams.py index e23302022..8fad0ff23 100644 --- a/tests/test_dynamodbstreams/test_dynamodbstreams.py +++ b/tests/test_dynamodbstreams/test_dynamodbstreams.py @@ -226,7 +226,10 @@ class TestEdges: with assert_raises(conn.exceptions.ResourceInUseException): resp = conn.update_table( TableName="test-streams", - StreamSpecification={"StreamViewType": "OLD_IMAGES", "StreamEnabled": True}, + StreamSpecification={ + "StreamViewType": "OLD_IMAGES", + "StreamEnabled": True, + }, ) def test_stream_with_range_key(self): diff --git a/tests/test_ecs/test_ecs_boto3.py b/tests/test_ecs/test_ecs_boto3.py index 224e6935b..38095bdc5 100644 --- a/tests/test_ecs/test_ecs_boto3.py +++ b/tests/test_ecs/test_ecs_boto3.py @@ -1924,7 +1924,9 @@ def test_attributes(): ) attrs = resp["attributes"] - NUM_CUSTOM_ATTRIBUTES = 4 # 2 specific to individual machines and 1 global, going to both machines (2 + 1*2) + NUM_CUSTOM_ATTRIBUTES = ( + 4 + ) # 2 specific to individual machines and 1 global, going to both machines (2 + 1*2) NUM_DEFAULT_ATTRIBUTES = 4 len(attrs).should.equal( NUM_CUSTOM_ATTRIBUTES + (NUM_DEFAULT_ATTRIBUTES * len(instances)) diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py index 366ea3620..5098de413 100644 --- a/tests/test_iam/test_iam.py +++ b/tests/test_iam/test_iam.py @@ -2526,9 +2526,7 @@ def test_get_account_summary(): ) client.create_instance_profile(InstanceProfileName="test-profile") - client.create_open_id_connect_provider( - Url="https://example.com", ThumbprintList=[], - ) + client.create_open_id_connect_provider(Url="https://example.com", ThumbprintList=[]) response_policy = client.create_policy( PolicyName="test-policy", PolicyDocument=MOCK_POLICY )