qontract-reconcile 0.10.2.dev56__py3-none-any.whl → 0.10.2.dev57__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tools/qontract_cli.py CHANGED
@@ -20,7 +20,7 @@ from operator import itemgetter
20
20
  from pathlib import Path
21
21
  from statistics import median
22
22
  from textwrap import dedent
23
- from typing import TYPE_CHECKING, Any, cast
23
+ from typing import Any
24
24
 
25
25
  import boto3
26
26
  import click
@@ -186,11 +186,6 @@ from tools.sre_checkpoints import (
186
186
  get_latest_sre_checkpoints,
187
187
  )
188
188
 
189
- if TYPE_CHECKING:
190
- from mypy_boto3_s3.type_defs import CopySourceTypeDef
191
- else:
192
- CopySourceTypeDef = object
193
-
194
189
 
195
190
  def output(function: Callable) -> Callable:
196
191
  function = click.option(
@@ -1016,7 +1011,6 @@ def clusters_network(ctx: click.Context, name: str) -> None:
1016
1011
  ]
1017
1012
  with AWSApi(1, [account], settings=settings, init_users=False) as aws_api:
1018
1013
  vpc_id, _, _, _ = aws_api.get_cluster_vpc_details(account)
1019
- assert vpc_id
1020
1014
  cluster["vpc_id"] = vpc_id
1021
1015
  egress_ips = aws_api.get_cluster_nat_gateways_egress_ips(account, vpc_id)
1022
1016
  cluster["egress_ips"] = ", ".join(sorted(egress_ips))
@@ -1465,13 +1459,10 @@ def copy_tfstate(
1465
1459
  with AWSApi(1, accounts, settings, secret_reader) as aws:
1466
1460
  session = aws.get_session(account["name"])
1467
1461
  s3_client = aws.get_session_client(session, "s3", region)
1468
- copy_source = cast(
1469
- CopySourceTypeDef,
1470
- {
1471
- "Bucket": source_bucket,
1472
- "Key": source_object_path,
1473
- },
1474
- )
1462
+ copy_source = {
1463
+ "Bucket": source_bucket,
1464
+ "Key": source_object_path,
1465
+ }
1475
1466
 
1476
1467
  dest_pretty_path = f"s3://{dest_bucket}/{dest_key}"
1477
1468
  # check if dest already exists
@@ -1890,23 +1881,23 @@ def rds_recommendations(ctx: click.Context) -> None:
1890
1881
  with AWSApi(1, [account], settings=settings, init_users=False) as aws:
1891
1882
  try:
1892
1883
  data = aws.describe_rds_recommendations(account_name, region)
1893
- db_recommendations = data.get("DBRecommendations", [])
1884
+ recommendations = data.get("DBRecommendations", [])
1894
1885
  except Exception as e:
1895
1886
  logging.error(f"Error describing RDS recommendations: {e}")
1896
1887
  continue
1897
1888
 
1898
1889
  # Add field ResourceName infered from ResourceArn
1899
1890
  recommendations = [
1900
- {
1901
- **rec,
1902
- "ResourceName": rec["ResourceArn"].split(":")[-1],
1903
- # The Description field has \n that are causing issues with the markdown table
1904
- "Description": rec["Description"].replace("\n", " "),
1905
- }
1906
- for rec in db_recommendations
1891
+ {**rec, "ResourceName": rec["ResourceArn"].split(":")[-1]}
1892
+ for rec in recommendations
1907
1893
  if rec.get("Status") not in IGNORED_STATUSES
1908
1894
  and rec.get("Severity") not in IGNORED_SEVERITIES
1909
1895
  ]
1896
+ # The Description field has \n that are causing issues with the markdown table
1897
+ recommendations = [
1898
+ {**rec, "Description": rec["Description"].replace("\n", " ")}
1899
+ for rec in recommendations
1900
+ ]
1910
1901
  # If we have no recommendations to show, skip
1911
1902
  if not recommendations:
1912
1903
  continue
@@ -2272,7 +2263,7 @@ def app_interface_review_queue(ctx: click.Context) -> None:
2272
2263
  }:
2273
2264
  continue
2274
2265
 
2275
- labels = mr.attributes.get("labels") or []
2266
+ labels = mr.attributes.get("labels")
2276
2267
  if glhk.is_good_to_merge(labels):
2277
2268
  continue
2278
2269
  if "stale" in labels:
@@ -2367,7 +2358,7 @@ def app_interface_open_selfserviceable_mr_queue(ctx: click.Context) -> None:
2367
2358
  continue
2368
2359
 
2369
2360
  # skip stale or non self serviceable MRs
2370
- labels = mr.attributes.get("labels", [])
2361
+ labels = mr.attributes.get("labels")
2371
2362
  if "stale" in labels:
2372
2363
  continue
2373
2364
  if SELF_SERVICEABLE not in labels and SAAS_FILE_UPDATE not in labels:
@@ -2456,7 +2447,7 @@ def app_interface_merge_history(ctx: click.Context) -> None:
2456
2447
  "id": f"[{mr.iid}]({mr.web_url})",
2457
2448
  "title": mr.title,
2458
2449
  "merged_at": mr.merged_at,
2459
- "labels": ", ".join(mr.attributes.get("labels", [])),
2450
+ "labels": ", ".join(mr.attributes.get("labels")),
2460
2451
  }
2461
2452
  merge_queue_data.append(item)
2462
2453
 
@@ -4597,7 +4588,7 @@ def log_group_usage(ctx: click.Context, aws_account: str) -> None:
4597
4588
  settings = queries.get_app_interface_settings()
4598
4589
  secret_reader = SecretReader(settings=settings)
4599
4590
  columns = ["log_group", "stored_bytes", "retention_days"]
4600
- results: list[dict[str, str | int]] = []
4591
+ results: list[dict[str, str]] = []
4601
4592
 
4602
4593
  with AWSApi(1, [account], settings, secret_reader) as aws:
4603
4594
  session = aws.get_session(account["name"])