Skip to content

Commit

Permalink
Minor sanity test fixes. (ansible-collections#1410)
Browse files Browse the repository at this point in the history
Minor sanity test fixes (new devel)

SUMMARY
ansible-devel has added a new PEP test (missing whitespace after keyword), this adds the fixes before the devel sanity tests are 'voting'.
Additionally fixes:

unused variables
broad catching of Exception

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/modules/autoscaling_group_info.py
plugins/modules/cloudfront_distribution.py
plugins/modules/cloudfront_origin_access_identity.py
plugins/modules/cloudtrail.py
plugins/modules/ec2_vpc_nacl.py
plugins/modules/eks_fargate_profile.py
plugins/modules/redshift.py
plugins/modules/s3_bucket_info.py
ADDITIONAL INFORMATION
cloudfront_distribution still has a lot of catch Exception but it's part of parameter validation which should be overhauled separately, unfortunately the tests are rather b0rked.

Reviewed-by: Alina Buzachis <None>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@3d4736b
  • Loading branch information
tremble authored and alinabuzachis committed Oct 2, 2023
1 parent 90744e0 commit ced0cd5
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions plugins/modules/s3_bucket_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def get_bucket_list(module, connection, name="", name_filter=""):
final_buckets = filtered_buckets
else:
final_buckets = buckets
return(final_buckets)
return final_buckets


def get_buckets_facts(connection, buckets, requested_facts, transform_location):
Expand All @@ -457,7 +457,7 @@ def get_buckets_facts(connection, buckets, requested_facts, transform_location):
bucket.update(get_bucket_details(connection, bucket['name'], requested_facts, transform_location))
full_bucket_list.append(bucket)

return(full_bucket_list)
return full_bucket_list


def get_bucket_details(connection, name, requested_facts, transform_location):
Expand Down Expand Up @@ -490,7 +490,7 @@ def get_bucket_details(connection, name, requested_facts, transform_location):
except botocore.exceptions.ClientError:
pass

return(all_facts)
return all_facts


@AWSRetry.jittered_backoff(max_delay=120, catch_extra_error_codes=['NoSuchBucket', 'OperationAborted'])
Expand All @@ -508,11 +508,8 @@ def get_bucket_location(name, connection, transform_location=False):
except KeyError:
pass
# Strip response metadata (not needed)
try:
data.pop('ResponseMetadata')
return(data)
except KeyError:
return(data)
data.pop('ResponseMetadata', None)
return data


@AWSRetry.jittered_backoff(max_delay=120, catch_extra_error_codes=['NoSuchBucket', 'OperationAborted'])
Expand All @@ -524,14 +521,11 @@ def get_bucket_tagging(name, connection):

try:
bucket_tags = boto3_tag_list_to_ansible_dict(data['TagSet'])
return(bucket_tags)
return bucket_tags
except KeyError:
# Strip response metadata (not needed)
try:
data.pop('ResponseMetadata')
return(data)
except KeyError:
return(data)
data.pop('ResponseMetadata', None)
return data


@AWSRetry.jittered_backoff(max_delay=120, catch_extra_error_codes=['NoSuchBucket', 'OperationAborted'])
Expand All @@ -544,11 +538,8 @@ def get_bucket_property(name, connection, get_api_name):
data = api_function(Bucket=name)

# Strip response metadata (not needed)
try:
data.pop('ResponseMetadata')
return(data)
except KeyError:
return(data)
data.pop('ResponseMetadata', None)
return data


def main():
Expand Down

0 comments on commit ced0cd5

Please sign in to comment.