Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
fix linting errors
Browse files Browse the repository at this point in the history
Signed-off-by: Janine Olear <pninak@web.de>
  • Loading branch information
miyunari committed Jul 25, 2023
1 parent 3db1187 commit 0cf01a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/cloudimagedirectory/connection/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def is_provided_by(self, name: str) -> bool:
"""Check the origin of the file."""
return f"{name}/" in self.filename

def is_API(self, api) -> bool:
def is_API(self, api: str) -> bool:
"""Check if the file is the actual API entry and not a sub url."""
path = self.filename.split("/")
if path[0] != api:
Expand All @@ -45,7 +45,7 @@ def is_API(self, api) -> bool:
return False

# NOTE: check length of hash value.
if len(path[len(path)-1]) != 40:
if len(path[len(path) - 1]) != 40:
return False

return True
Expand Down
18 changes: 8 additions & 10 deletions src/cloudimagedirectory/transform/transform.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Transforms the raw data into useful data."""
import copy
import os
import hashlib

import os
from datetime import datetime
from typing import Any, Callable, no_type_check

Expand Down Expand Up @@ -86,7 +85,7 @@ class TransformerIdxListImageLatest(Transformer):
# TODO: Mypy says that 'data' below is not iterable. This needs to be fixed later.
@no_type_check
def run(self, data: Transformer) -> list: # noqa: C901
# NOTE: Verify that the data is not raw.
# NOTE: Verify that the data is not raw.
entries = [x for x in data if not x.is_raw() and not x.is_provided_by("idx")]

# NOTE: Sort the list of data by date
Expand Down Expand Up @@ -298,7 +297,7 @@ def run(self, data: type[Transformer]) -> list:
class TransformerAWSV2RHEL(Transformer):
"""Transform raw rhel AWS data into the schema."""

def run(self, data):
def run(self, data: list) -> list:
"""Transform the raw data."""
# NOTE: Verify that the data is raw.
entries = [x for x in data if x.is_provided_by("aws") and x.is_raw()]
Expand All @@ -322,7 +321,7 @@ def run(self, data):
# NOTE: Due to consistency issues between the cloud providers and the fact
# that they do not all have unique numbers to identify their images, we decided
# to use this solution instead.
image_id = hashlib.sha1(image_name.encode()).hexdigest()
image_id = hashlib.sha1(image_name.encode()).hexdigest() # noqa: S324

# NOTE: example of expected paths
# v2/os/rhel/provider/aws/version/8.6.0/region/eu-west-3/image/71d0a7aaa1f0dc06840e46f6ce316a7acfb022d4
Expand All @@ -337,7 +336,7 @@ def run(self, data):
class TransformerAzureV2RHEL(Transformer):
"""Transform raw rhel Azure data into the schema."""

def run(self, data):
def run(self, data: list) -> list:
"""Transform the raw data."""
# NOTE: Verify that the data is raw and provided by azure.
entries = [x for x in data if x.is_provided_by("azure") and x.is_raw()]
Expand All @@ -362,7 +361,7 @@ def run(self, data):
# NOTE: Due to consistency issues between the cloud providers and the fact
# that they do not all have unique numbers to identify their images, we decided
# to use this solution instead.
image_id = hashlib.sha1(image_name.encode()).hexdigest()
image_id = hashlib.sha1(image_name.encode()).hexdigest() # noqa: S324

# NOTE: example of expected paths
# v2/os/rhel/provider/azure/version/8.6.0/region/southcentralus/image/71d0a7aaa1f0dc06840e46f6ce316a7acfb022d4
Expand All @@ -377,7 +376,7 @@ def run(self, data):
class TransformerGoogleV2RHEL(Transformer):
"""Transform raw rhel Google data into the schema."""

def run(self, data):
def run(self, data: list) -> list:
"""Transform the raw data."""
# NOTE: Verify that the data is raw and provided by google.
entries = [x for x in data if x.is_provided_by("google") and x.is_raw()]
Expand All @@ -390,7 +389,6 @@ def run(self, data):
for content in raw.content:
content["creation_timestamp"] = content["creationTimestamp"]
if "rhel" in content["name"]:

image_data = format_google.image_rhel(content)
image_name = image_data["name"].replace(" ", "_").lower()
region = "global"
Expand All @@ -400,7 +398,7 @@ def run(self, data):
# NOTE: Due to consistency issues between the cloud providers and the fact
# that they do not all have unique numbers to identify their images, we decided
# to use this solution instead.
image_id = hashlib.sha1(image_name.encode()).hexdigest()
image_id = hashlib.sha1(image_name.encode()).hexdigest() # noqa: S324

# NOTE: example of expected paths
# v2/os/rhel/provider/google/version/8.6.0/region/global/image/71d0a7aaa1f0dc06840e46f6ce316a7acfb022d4
Expand Down

0 comments on commit 0cf01a3

Please sign in to comment.