diff --git a/setup.py b/setup.py index b80589c..1a6cf4f 100644 --- a/setup.py +++ b/setup.py @@ -16,8 +16,8 @@ def read(*names, **kwargs): - with io.open(join(dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")) as fh: - return fh.read() + with io.open(join(dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")) as file_handle: + return file_handle.read() setup( diff --git a/src/tirith/cli.py b/src/tirith/cli.py index 8e83da8..6642e31 100755 --- a/src/tirith/cli.py +++ b/src/tirith/cli.py @@ -8,7 +8,6 @@ import sys import textwrap -import tirith.providers.terraform_plan.handler as python_tf_plan_handler from tirith.logging import setup_logging from tirith.prettyprinter import pretty_print_result_dict from tirith.status import ExitStatus diff --git a/src/tirith/providers/infracost/handler.py b/src/tirith/providers/infracost/handler.py index dd6c84e..956cc5f 100644 --- a/src/tirith/providers/infracost/handler.py +++ b/src/tirith/providers/infracost/handler.py @@ -9,7 +9,7 @@ def __get_all_costs(operation_type, input_data): "total_monthly_cost": ["totalMonthlyCost", "monthlyCost"], "total_hourly_cost": ["totalHourlyCost", "hourlyCost"], } - totalSum = 0 + total_sum = 0 if "projects" in input_data: for project in input_data["projects"]: if "breakdown" in project and "resources" in project["breakdown"]: @@ -19,19 +19,19 @@ def __get_all_costs(operation_type, input_data): and resource[pointer[operation_type][0]] and resource[pointer[operation_type][0]] != "null" ): - totalSum += float(resource[pointer[operation_type][0]]) + total_sum += float(resource[pointer[operation_type][0]]) elif ( pointer[operation_type][1] in resource and resource[pointer[operation_type][1]] and resource[pointer[operation_type][1]] != "null" ): # Support new schema for Infracost - totalSum += float(resource[pointer[operation_type][1]]) + total_sum += float(resource[pointer[operation_type][1]]) else: pass # raise KeyError(f'{costType} not found in one of the resource') - logger.debug(f"Total sum of {operation_type} of all resources : {totalSum}") - return totalSum + logger.debug(f"Total sum of {operation_type} of all resources : {total_sum}") + return total_sum else: raise KeyError("breakdown/resources not found in one of the project") else: @@ -45,7 +45,7 @@ def __get_resources_costs(resource_type, operation_type, input_data): "total_monthly_cost": ["totalMonthlyCost", "monthlyCost"], "total_hourly_cost": ["totalHourlyCost", "hourlyCost"], } - totalSum = 0 + total_sum = 0 if "projects" in input_data: for project in input_data["projects"]: if "breakdown" in project and "resources" in project["breakdown"]: @@ -57,7 +57,7 @@ def __get_resources_costs(resource_type, operation_type, input_data): and resource[pointer[operation_type][0]] and resource[pointer[operation_type][0]] != "null" ): - totalSum += float(resource[pointer[operation_type][0]]) + total_sum += float(resource[pointer[operation_type][0]]) elif ( pointer[operation_type][1] in resource and "name" in resource @@ -65,12 +65,12 @@ def __get_resources_costs(resource_type, operation_type, input_data): and resource[pointer[operation_type][1]] and resource[pointer[operation_type][1]] != "null" ): - totalSum += float(resource[pointer[operation_type][1]]) + total_sum += float(resource[pointer[operation_type][1]]) else: pass # raise KeyError(f'{costType} not found in one of the resource') - logger.debug(f"Total sum of {operation_type} of specific resources : {totalSum}") - return totalSum + logger.debug(f"Total sum of {operation_type} of specific resources : {total_sum}") + return total_sum else: raise KeyError("breakdown/resources not found in one of the project") else: