Toss in black for autoformatting as well
- ID
163b6a6- date
2023-11-12 00:55:43+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
1f22853- message
Toss in black for autoformatting as well- changed files
Changed files
.github/workflows/test.yml (918) → .github/workflows/test.yml (943)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index b46f788..0d42d05 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -26,6 +26,8 @@ jobs:
pip install -r requirements.txt
- name: Run linting
run: |
+ black --check .
+
# 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)
#
aws/bulk_sns_publish.py (4541) → aws/bulk_sns_publish.py (4539)
diff --git a/aws/bulk_sns_publish.py b/aws/bulk_sns_publish.py
index 97c780f..d9ef4ba 100755
--- a/aws/bulk_sns_publish.py
+++ b/aws/bulk_sns_publish.py
@@ -141,7 +141,7 @@ def publish_messages(*, input_file, topic_arn):
total_entries = sum(len(entries) for entries in get_batch_entries(input_file))
with tqdm.tqdm(total=total_entries) as pbar:
- for (batch, _) in concurrently(
+ for batch, _ in concurrently(
handler=functools.partial(publish_batch, sns_client, topic_arn),
inputs=get_batch_entries(input_file),
max_concurrency=8,
aws/dynamols.py (4888) → aws/dynamols.py (4887)
diff --git a/aws/dynamols.py b/aws/dynamols.py
index 2f70cbf..6f2cf1a 100755
--- a/aws/dynamols.py
+++ b/aws/dynamols.py
@@ -80,7 +80,6 @@ def parallel_scan_table(sess, *, TableName, **kwargs):
scans_to_run = iter(tasks_to_do)
with concurrent.futures.ThreadPoolExecutor() as executor:
-
# Schedule the initial batch of futures. Here we assume that
# max_scans_in_parallel < total_segments, so there's no risk that
# the queue will throw an Empty exception.
aws/s3_unfreeze.py (2162) → aws/s3_unfreeze.py (2162)
diff --git a/aws/s3_unfreeze.py b/aws/s3_unfreeze.py
index 6be4a32..6be9e1a 100755
--- a/aws/s3_unfreeze.py
+++ b/aws/s3_unfreeze.py
@@ -30,11 +30,11 @@ def restore_object(s3_client, s3_uri):
head_resp = s3_client.head_object(Bucket=bucket, Key=key)
- if head_resp.get('Restore') == 'ongoing-request="true"':
+ if head_resp.get("Restore") == 'ongoing-request="true"':
return "RestoreInProgress"
- if 'ongoing-request="false"' in head_resp.get('Restore', ''):
- return 'RestoredSuccessfully'
+ if 'ongoing-request="false"' in head_resp.get("Restore", ""):
+ return "RestoredSuccessfully"
try:
resp = s3_client.restore_object(
aws/s3rm.py (2562) → aws/s3rm.py (2585)
diff --git a/aws/s3rm.py b/aws/s3rm.py
index 0108f4b..e8f20a7 100755
--- a/aws/s3rm.py
+++ b/aws/s3rm.py
@@ -43,7 +43,9 @@ def delete_objects(sess, iterator):
total_deleted_size = 0
def print_result():
- print(f'{humanize.intcomma(total_deleted_count)} object{"s" if total_deleted_count != 1 else ""} deleted, total {humanize.naturalsize(total_deleted_size)}')
+ print(
+ f'{humanize.intcomma(total_deleted_count)} object{"s" if total_deleted_count != 1 else ""} deleted, total {humanize.naturalsize(total_deleted_size)}'
+ )
def delete_batch(batch):
sess.client("s3").delete_objects(
@@ -61,10 +63,10 @@ def delete_objects(sess, iterator):
handler=delete_batch,
inputs=more_itertools.chunked(iterator, 1000),
# Note: if you go too fast, you get a SlowDown error from S3.
- max_concurrency=3
+ max_concurrency=3,
):
total_deleted_count += len(batch)
- total_deleted_size += sum(s3_obj['Size'] for s3_obj in batch)
+ total_deleted_size += sum(s3_obj["Size"] for s3_obj in batch)
except: # noqa: E722
print_result()
raise
aws/s3tree.py (6357) → aws/s3tree.py (6373)
diff --git a/aws/s3tree.py b/aws/s3tree.py
index 099f16b..6c82c01 100755
--- a/aws/s3tree.py
+++ b/aws/s3tree.py
@@ -137,9 +137,7 @@ def pprint_s3tree(*, bucket, tree):
extra_objects = f"...{len(tree.objects) - 3} other objects"
lines.append(f"{prefix_char} {termcolor.colored(extra_objects, 'blue')}")
- for i, folder_name in enumerate(
- natsort.natsort(tree.folders), start=1
- ):
+ for i, folder_name in enumerate(natsort.natsort(tree.folders), start=1):
folder_tree = tree.folders[folder_name]
if tree.path == "":
@@ -186,7 +184,11 @@ if __name__ == "__main__":
print("(no objects)")
sys.exit(1)
- keys = [s3_obj["Key"] for s3_obj in s3_objects if s3_obj["Size"] > 0 or not s3_obj["Key"].endswith("/")]
+ keys = [
+ s3_obj["Key"]
+ for s3_obj in s3_objects
+ if s3_obj["Size"] > 0 or not s3_obj["Key"].endswith("/")
+ ]
tree = build_s3_tree(keys)
aws/sqs_stats.py (3899) → aws/sqs_stats.py (3916)
diff --git a/aws/sqs_stats.py b/aws/sqs_stats.py
index 671ca26..1b7ea39 100755
--- a/aws/sqs_stats.py
+++ b/aws/sqs_stats.py
@@ -61,7 +61,7 @@ def get_queue_stats(sess, *, queue_urls):
handler=lambda q_url: sqs_client.get_queue_attributes(
QueueUrl=q_url, AttributeNames=attribute_names
),
- inputs=queue_urls
+ inputs=queue_urls,
):
queue_responses[q_url] = q_resp
@@ -79,7 +79,8 @@ def print_number(account_id, region_name, queue_name, *, value, color):
print(
termcolor.colored(
- " " * spaces_required + create_link_text(
+ " " * spaces_required
+ + create_link_text(
url=f"https://{region_name}.console.aws.amazon.com/sqs/v2/home?region={region_name}#/queues/https%3A%2F%2Fsqs.{region_name}.amazonaws.com%2F{account_id}%2F{queue_name}",
label=humanize.intcomma(value),
),
requirements.in (14) → requirements.in (30)
diff --git a/requirements.in b/requirements.in
index 475c423..77fc521 100644
--- a/requirements.in
+++ b/requirements.in
@@ -1,2 +1,4 @@
+black
flake8
Pillow
+pip-tools
requirements.txt (316) → requirements.txt (826)
diff --git a/requirements.txt b/requirements.txt
index 21cb493..1ee24ee 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,13 +4,41 @@
#
# pip-compile requirements.in
#
+black==23.11.0
+ # via -r requirements.in
+build==1.0.3
+ # via pip-tools
+click==8.1.7
+ # via
+ # black
+ # pip-tools
flake8==6.1.0
# via -r requirements.in
mccabe==0.7.0
# via flake8
+mypy-extensions==1.0.0
+ # via black
+packaging==23.2
+ # via
+ # black
+ # build
+pathspec==0.11.2
+ # via black
pillow==10.1.0
# via -r requirements.in
+pip-tools==7.3.0
+ # via -r requirements.in
+platformdirs==4.0.0
+ # via black
pycodestyle==2.11.1
# via flake8
pyflakes==3.1.0
# via flake8
+pyproject-hooks==1.0.0
+ # via build
+wheel==0.41.3
+ # via pip-tools
+
+# The following packages are considered to be unsafe in a requirements file:
+# pip
+# setuptools