diff --git a/.github/workflows/cicd-pipeline.yml b/.github/workflows/cicd-pipeline.yml index 132bd35..dcd8a31 100644 --- a/.github/workflows/cicd-pipeline.yml +++ b/.github/workflows/cicd-pipeline.yml @@ -24,8 +24,6 @@ jobs: with: python-version: '3.10' - name: Run Pur - env: - SHOW_ERRORS: true run: bash <(curl -s https://raw.githubusercontent.com/CICDToolbox/pur/master/pipeline.sh) pycodestyle: @@ -40,6 +38,18 @@ jobs: - name: Run Pycodestyle run: bash <(curl -s https://raw.githubusercontent.com/CICDToolbox/pycodestyle/master/pipeline.sh) + pylint: + runs-on: ubuntu-latest + name: Pylint + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Run Pylint + run: bash <(curl -s https://raw.githubusercontent.com/CICDToolbox/pylint/master/pipeline.sh) + awesomebot: name: Awesomebot runs-on: ubuntu-latest @@ -83,6 +93,7 @@ jobs: - bandit - pur - pycodestyle + - pylint - awesomebot - shellcheck - yaml-lint diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..734dcfc --- /dev/null +++ b/.pylintrc @@ -0,0 +1,5 @@ +[FORMAT] +max-line-length=240 + +[MESSAGES CONTROL] +disable=broad-except diff --git a/CHANGELOG.md b/CHANGELOG.md index 04d47a9..c5ce933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ This changelog was automatically generated using [Caretaker](https://github.com/ ### [Unreleased](https://github.com/AWSToolbox/list-rds-instances/compare/v0.1.1...HEAD) -- Add greetings [`[head]`](https://github.com/AWSToolbox/list-rds-instances/commit/) +- Added pylint [`[head]`](https://github.com/AWSToolbox/list-rds-instances/commit/) + +- Add greetings [`[2a800b5]`](https://github.com/AWSToolbox/list-rds-instances/commit/2a800b5d7ffd960ce9bab0c471192bc1d66aaac4) - Fix codeql errors [`[bdb4d42]`](https://github.com/AWSToolbox/list-rds-instances/commit/bdb4d428b5deaffad0a856dd47006ec2c1d7f5e4) diff --git a/src/list-rds-instances.py b/src/list-rds-instances.py index e40abfd..16e70e9 100755 --- a/src/list-rds-instances.py +++ b/src/list-rds-instances.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# pylint: disable=C0103 """ Example Usage: @@ -9,8 +10,9 @@ from __future__ import print_function import argparse -import boto3 import sys +import boto3 +import botocore from prettytable import PrettyTable @@ -35,7 +37,7 @@ def main(cmdline=None) -> None: else: client = boto3.client('rds') - results = query_api(client, args) + results = query_api(client) display_results(results) @@ -51,7 +53,7 @@ def make_parser(): return parser -def query_api(client, args): +def query_api(client): """ Query the API """ @@ -60,8 +62,8 @@ def query_api(client, args): try: response = client.describe_db_instances() - except EndpointConnectionError as e: - print("ERROR: %s (Probably an invalid region!)" % e) + except botocore.exceptions.EndpointConnectionError as e: + print(f'ERROR: {e} (Probably an invalid region!)') except Exception as e: print("Unknown error: " + str(e)) else: @@ -69,7 +71,7 @@ def query_api(client, args): for parts in response['DBInstances']: if 'AvailabilityZone' in parts: if 'SecondaryAvailabilityZone' in parts: - AZS = '%s & %s' % (parts['AvailabilityZone'], parts['SecondaryAvailabilityZone']) + AZS = f'{parts["AvailabilityZone"]} & {parts["SecondaryAvailabilityZone"]}' else: AZS = parts['AvailabilityZone'] else: @@ -117,7 +119,7 @@ def display_results(results): parts['Status'], parts['AvailabilityZone'], parts['PubliclyAccessible'], - '%s GB' % parts['AllocatedStorage'], + f'{parts["AllocatedStorage"]} GB', parts['StorageEncrypted'], parts['Engine'], parts['EngineVersion'],