Skip to content

Commit 77d0904

Browse files
style: apply ruff format to src/deploydiff/cost_estimator.py
1 parent cbc9017 commit 77d0904

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/deploydiff/cost_estimator.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@
153153
}
154154

155155

156-
def estimate_costs(plan: DeployPlan, pricing_file: str | Path | None = None) -> list[CostEstimate]:
156+
def estimate_costs(
157+
plan: DeployPlan, pricing_file: str | Path | None = None
158+
) -> list[CostEstimate]:
157159
"""Estimate monthly cost impact for each resource change in a plan.
158160
159161
Args:
@@ -197,7 +199,10 @@ def _estimate_resource_cost(
197199
# If deleting, after cost is 0; if creating, before cost is 0
198200
if before and change.action == ChangeAction.CREATE:
199201
return 0.0
200-
if not before and change.action in (ChangeAction.DELETE, ChangeAction.DELETE_BEFORE_CREATE):
202+
if not before and change.action in (
203+
ChangeAction.DELETE,
204+
ChangeAction.DELETE_BEFORE_CREATE,
205+
):
201206
return 0.0
202207

203208
resource_type = change.resource_type
@@ -206,7 +211,14 @@ def _estimate_resource_cost(
206211
# Try to find an instance type / size key in the resource config
207212
data = change.before if before else change.after
208213
if data and isinstance(data, dict):
209-
for field in ("instance_type", "InstanceType", "node_type", "NodeType", "volume_type", "engine"):
214+
for field in (
215+
"instance_type",
216+
"InstanceType",
217+
"node_type",
218+
"NodeType",
219+
"volume_type",
220+
"engine",
221+
):
210222
val = data.get(field, "")
211223
if val and str(val) in type_pricing:
212224
return type_pricing[str(val)]
@@ -224,7 +236,9 @@ def _build_cost_description(change: ResourceChange, before: float, after: float)
224236
return "no change"
225237

226238

227-
def _load_pricing(pricing_file: str | Path | None = None) -> dict[str, dict[str, float]]:
239+
def _load_pricing(
240+
pricing_file: str | Path | None = None,
241+
) -> dict[str, dict[str, float]]:
228242
"""Load pricing data from a custom file, falling back to defaults."""
229243
if pricing_file is None:
230244
return DEFAULT_PRICING.copy()

0 commit comments

Comments
 (0)