Skip to content

Commit

Permalink
Run ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaily committed Jan 13, 2025
1 parent 73ad1cf commit 9493f42
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
8 changes: 2 additions & 6 deletions awscli/customizations/cloudformation/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ def has_stack(self, stack_name):
msg = str(e)

if f"Stack with id {stack_name} does not exist" in msg:
LOG.debug(
f"Stack with id {stack_name} does not exist"
)
LOG.debug(f"Stack with id {stack_name} does not exist")
return False
else:
# We don't know anything about this exception. Don't handle
Expand Down Expand Up @@ -239,9 +237,7 @@ def wait_for_execute(self, stack_name, changeset_type):
elif changeset_type == "UPDATE":
waiter = self._client.get_waiter("stack_update_complete")
else:
raise RuntimeError(
f"Invalid changeset type {changeset_type}"
)
raise RuntimeError(f"Invalid changeset type {changeset_type}")

# Poll every 30 seconds. Polling too frequently risks hitting rate limits
# on CloudFormation's DescribeStacks API
Expand Down
42 changes: 23 additions & 19 deletions awscli/customizations/cloudtrail/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def assert_cloudtrail_arn_is_valid(trail_arn):
ARNs look like: arn:aws:cloudtrail:us-east-1:123456789012:trail/foo"""
pattern = re.compile(r'arn:.+:cloudtrail:.+:\d{12}:trail/.+')
if not pattern.match(trail_arn):
raise ParamValidationError(
f'Invalid trail ARN provided: {trail_arn}'
)
raise ParamValidationError(f'Invalid trail ARN provided: {trail_arn}')


def create_digest_traverser(
Expand Down Expand Up @@ -589,19 +587,15 @@ def _load_and_validate_digest(self, public_keys, bucket, key):
or digest_data['digestS3Object'] != key
):
raise DigestError(

f'Digest file\ts3://{bucket}/{key}\tINVALID: has been moved from its '
'original location'

f'Digest file\ts3://{bucket}/{key}\tINVALID: has been moved from its '
'original location'
)
# Get the public keys in the given time range.
fingerprint = digest_data['digestPublicKeyFingerprint']
if fingerprint not in public_keys:
raise DigestError(

f'Digest file\ts3://{bucket}/{key}\tINVALID: public key not found in '
f'region {self.digest_provider.trail_home_region} for fingerprint {fingerprint}'

f'Digest file\ts3://{bucket}/{key}\tINVALID: public key not found in '
f'region {self.digest_provider.trail_home_region} for fingerprint {fingerprint}'
)
public_key_hex = public_keys[fingerprint]['Value']
self._digest_validator.validate(
Expand Down Expand Up @@ -649,7 +643,9 @@ def validate(self, bucket, key, public_key, digest_data, inflated_digest):
(
'Digest file\ts3://{}/{}\tINVALID: Unable to load PKCS #1 key'
' with fingerprint {}'
).format(bucket, key, digest_data['digestPublicKeyFingerprint'])
).format(
bucket, key, digest_data['digestPublicKeyFingerprint']
)
)

to_sign = self._create_string_to_sign(digest_data, inflated_digest)
Expand Down Expand Up @@ -889,7 +885,9 @@ def _call(self):
self._track_found_times(digest)
self._valid_digests += 1
self._write_status(
'Digest file\ts3://{}/{}\tvalid'.format(digest['digestS3Bucket'], digest['digestS3Object'])
'Digest file\ts3://{}/{}\tvalid'.format(
digest['digestS3Bucket'], digest['digestS3Object']
)
)
if not digest['logFiles']:
continue
Expand Down Expand Up @@ -931,9 +929,9 @@ def _download_log(self, log):
else:
self._valid_logs += 1
self._write_status(

'Log file\ts3://{}/{}\tvalid'.format(log['s3Bucket'], log['s3Object'])

'Log file\ts3://{}/{}\tvalid'.format(
log['s3Bucket'], log['s3Object']
)
)
except ClientError as e:
if e.response['Error']['Code'] != 'NoSuchKey':
Expand Down Expand Up @@ -1010,21 +1008,27 @@ def _on_invalid_log_format(self, log_data):
self._invalid_logs += 1
self._write_status(
(
'Log file\ts3://{}/{}\tINVALID: invalid format'.format(log_data['s3Bucket'], log_data['s3Object'])
'Log file\ts3://{}/{}\tINVALID: invalid format'.format(
log_data['s3Bucket'], log_data['s3Object']
)
),
True,
)

def _on_log_invalid(self, log_data):
self._invalid_logs += 1
self._write_status(
"Log file\ts3://{}/{}\tINVALID: hash value doesn't match".format(log_data['s3Bucket'], log_data['s3Object']),
"Log file\ts3://{}/{}\tINVALID: hash value doesn't match".format(
log_data['s3Bucket'], log_data['s3Object']
),
True,
)

def _on_missing_log(self, log_data):
self._invalid_logs += 1
self._write_status(
'Log file\ts3://{}/{}\tINVALID: not found'.format(log_data['s3Bucket'], log_data['s3Object']),
'Log file\ts3://{}/{}\tINVALID: not found'.format(
log_data['s3Bucket'], log_data['s3Object']
),
True,
)
8 changes: 6 additions & 2 deletions awscli/customizations/configservice/getstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,9 @@ def _check_last_status(self, status, status_name=''):
last_status = status['lastStatus']
sys.stdout.write(f'last {status_name}status: {last_status}\n')
if last_status == "FAILURE":
sys.stdout.write('error code: {}\n'.format(status['lastErrorCode']))
sys.stdout.write('message: {}\n'.format(status['lastErrorMessage']))
sys.stdout.write(
'error code: {}\n'.format(status['lastErrorCode'])
)
sys.stdout.write(
'message: {}\n'.format(status['lastErrorMessage'])
)
4 changes: 1 addition & 3 deletions awscli/customizations/configure/addmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ def get_model_location(session, service_definition, service_name=None):
# not the one set by AWS_DATA_PATH)
data_path = session.get_component('data_loader').CUSTOMER_DATA_PATH
# Use the version of the model to determine the file's naming convention.
service_model_name = (
f"service-{int(float(service_definition.get('version', '2.0'))):d}.json"
)
service_model_name = f"service-{int(float(service_definition.get('version', '2.0'))):d}.json"
return os.path.join(
data_path, service_name, api_version, service_model_name
)
Expand Down
4 changes: 1 addition & 3 deletions awscli/customizations/configure/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ def _insert_new_values(self, line_number, contents, new_values, indent=''):
subindent = indent + ' '
new_contents.append(f'{indent}{key} =\n')
for subkey, subval in list(value.items()):
new_contents.append(
f'{subindent}{subkey} = {subval}\n'
)
new_contents.append(f'{subindent}{subkey} = {subval}\n')
else:
new_contents.append(f'{indent}{key} = {value}\n')
del new_values[key]
Expand Down

0 comments on commit 9493f42

Please sign in to comment.