Skip to main content

Start running flake8 over the scripts in this repo

ID
1f22853
date
2023-11-12 00:53:03+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
9973088
message
Start running flake8 over the scripts in this repo
changed files
10 files, 51 additions, 15 deletions

Changed files

.github/workflows/test.yml (0) → .github/workflows/test.yml (918)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..b46f788
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,35 @@
+name: Test
+
+on:
+  push:
+    branches:
+    - main
+
+  pull_request:
+    branches:
+    - main
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: ["3.12"]
+    steps:
+    - uses: actions/checkout@v3
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v4
+      with:
+        python-version: ${{ matrix.python-version }}
+    - name: Install dependencies
+      run: |
+        pip install -r requirements.txt
+    - name: Run linting
+      run: |
+        # E501 = line too long; anything up to 100-ish is fine in my book
+        # (the "ish" is intentional; see https://www.youtube.com/watch?v=wf-BqAjZb8M)
+        #
+        # W503 = line break before binary operator; this is something added
+        # by black and I don't have a strong opinion on, so I'm going to trust
+        # black and have flake8 ignore it.
+        flake8 --ignore=E501,W503

aws/bulk_sns_publish.py (4614) → aws/bulk_sns_publish.py (4541)

diff --git a/aws/bulk_sns_publish.py b/aws/bulk_sns_publish.py
index b14c436..97c780f 100755
--- a/aws/bulk_sns_publish.py
+++ b/aws/bulk_sns_publish.py
@@ -29,7 +29,6 @@ import sys
 import uuid
 
 import boto3
-import more_itertools
 import tqdm
 
 from _common import ACCOUNT_NAMES
@@ -37,7 +36,7 @@ from _common import ACCOUNT_NAMES
 # https://github.com/alexwlchan/concurrently
 sys.path.append(os.path.join(os.environ["HOME"], "repos", "concurrently"))
 
-from concurrently import concurrently
+from concurrently import concurrently  # noqa: E402
 
 
 def get_aws_session(*, role_arn):
@@ -61,10 +60,6 @@ def get_session(*, topic_arn):
     If it recognises the account which contains the topic, it will pick
     the appropriate IAM role, otherwise it use the default boto3 Session.
     """
-    account_names = {
-        "760097843905": "platform",
-    }
-
     # The arn format of an SNS topic is:
     #
     #       arn:aws:sns:{region}:{account_id}:{topic_name}

aws/download_sqs_messages.py (2121) → aws/download_sqs_messages.py (2111)

diff --git a/aws/download_sqs_messages.py b/aws/download_sqs_messages.py
index 201dcda..3582189 100755
--- a/aws/download_sqs_messages.py
+++ b/aws/download_sqs_messages.py
@@ -1,7 +1,6 @@
 #!/usr/bin/env python3
 
 import json
-import os
 import sys
 
 import boto3
@@ -75,10 +74,9 @@ if __name__ == "__main__":
     except IndexError:
         queue_url = None
 
-
     if queue_url is not None:
         for message in tqdm.tqdm(download_messages(queue_url=queue_url)):
             print(json.dumps(message))
     else:
         for queue_url in list_queue_urls():
-            print(queue_url)
\ No newline at end of file
+            print(queue_url)

aws/dynamols.py (4898) → aws/dynamols.py (4888)

diff --git a/aws/dynamols.py b/aws/dynamols.py
index 033f6cd..2f70cbf 100755
--- a/aws/dynamols.py
+++ b/aws/dynamols.py
@@ -22,7 +22,6 @@ import concurrent.futures
 import decimal
 import json
 import itertools
-import os
 import sys
 
 import boto3

aws/s3_unfreeze.py (2148) → aws/s3_unfreeze.py (2162)

diff --git a/aws/s3_unfreeze.py b/aws/s3_unfreeze.py
index 73a877c..6be4a32 100755
--- a/aws/s3_unfreeze.py
+++ b/aws/s3_unfreeze.py
@@ -19,7 +19,7 @@ import tqdm
 from _common import create_s3_session
 
 sys.path.append(os.path.join(os.environ["HOME"], "repos", "concurrently"))
-from concurrently import concurrently
+from concurrently import concurrently  # noqa: E402
 
 
 def restore_object(s3_client, s3_uri):

aws/s3hash.py (1118) → aws/s3hash.py (1100)

diff --git a/aws/s3hash.py b/aws/s3hash.py
index 032ef4b..cde810c 100755
--- a/aws/s3hash.py
+++ b/aws/s3hash.py
@@ -9,7 +9,7 @@ import os
 
 import tqdm
 
-from _common import create_link_text, create_s3_session, parse_s3_uri
+from _common import create_s3_session, parse_s3_uri
 
 
 def parse_args():

aws/s3rm.py (2534) → aws/s3rm.py (2562)

diff --git a/aws/s3rm.py b/aws/s3rm.py
index f92c440..0108f4b 100755
--- a/aws/s3rm.py
+++ b/aws/s3rm.py
@@ -17,7 +17,7 @@ from s3ls import get_objects, get_object_versions
 # https://github.com/alexwlchan/concurrently
 sys.path.append(os.path.join(os.environ["HOME"], "repos", "concurrently"))
 
-from concurrently import concurrently
+from concurrently import concurrently  # noqa: E402
 
 
 def parse_args():
@@ -65,7 +65,7 @@ def delete_objects(sess, iterator):
         ):
             total_deleted_count += len(batch)
             total_deleted_size += sum(s3_obj['Size'] for s3_obj in batch)
-    except:
+    except:  # noqa: E722
         print_result()
         raise
     else:

aws/sqs_stats.py (3885) → aws/sqs_stats.py (3899)

diff --git a/aws/sqs_stats.py b/aws/sqs_stats.py
index b923f49..671ca26 100755
--- a/aws/sqs_stats.py
+++ b/aws/sqs_stats.py
@@ -27,7 +27,7 @@ from _common import create_link_text
 # https://github.com/alexwlchan/concurrently
 sys.path.append(os.path.join(os.environ["HOME"], "repos", "concurrently"))
 
-from concurrently import concurrently
+from concurrently import concurrently  # noqa: E402
 
 
 def list_queue_urls_in_account(sess, *, prefixes):

requirements.in (7) → requirements.in (14)

diff --git a/requirements.in b/requirements.in
index 7e2fba5..475c423 100644
--- a/requirements.in
+++ b/requirements.in
@@ -1 +1,2 @@
+flake8
 Pillow

requirements.txt (172) → requirements.txt (316)

diff --git a/requirements.txt b/requirements.txt
index 5284de9..21cb493 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,5 +4,13 @@
 #
 #    pip-compile requirements.in
 #
+flake8==6.1.0
+    # via -r requirements.in
+mccabe==0.7.0
+    # via flake8
 pillow==10.1.0
     # via -r requirements.in
+pycodestyle==2.11.1
+    # via flake8
+pyflakes==3.1.0
+    # via flake8