Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kumarak committed Nov 16, 2023
1 parent 8c00efa commit 1b11bc9
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/blight/actions/embed_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
from blight.util import flock_append


def SHA256(value):
"""Get sha256 hash from the value"""
return hashlib.sha256(value.encode("utf-8")).hexdigest()


def cc_as_string(tool_record: Dict):

Check failure on line 23 in src/blight/actions/embed_commands.py

View workflow job for this annotation

GitHub Actions / Trunk Check

mypy(no-untyped-def)

[new] Function is missing a return type annotation
return json.dumps(tool_record).replace('"', '\\"').replace("\\\\", "\\")

Expand Down Expand Up @@ -79,10 +74,10 @@ def align_string(string: str) -> str:


class EmbedCommands(CompilerAction):
def __init__(self, config):
def __init__(self, config: dict[str, str]) -> None:
super().__init__(config)

def _get_header_file(self, cmd_hash: str):
def _get_header_file(self, cmd_hash: str) -> str:
output = Path(self._config["output"])
header_file = "{}/{}_{}_{}.h".format(
output, cmd_hash, os.getpid(), random.randint(0, 9999999)
Expand All @@ -91,15 +86,15 @@ def _get_header_file(self, cmd_hash: str):
os.remove(header_file)
return header_file

def before_run(self, tool: Tool) -> None:
def before_run(self, tool: CompilerTool) -> None:

Check failure on line 89 in src/blight/actions/embed_commands.py

View workflow job for this annotation

GitHub Actions / Trunk Check

ruff(F821)

[new] Undefined name `CompilerTool`

Check failure on line 89 in src/blight/actions/embed_commands.py

View workflow job for this annotation

GitHub Actions / Trunk Check

mypy(name-defined)

[new] Name "CompilerTool" is not defined
if tool.lang not in (Lang.C, Lang.Cxx):
return

if is_input_assembly(tool):
return

cc_string = cc_as_string(cc_as_dict(tool)).strip()
cmd_hash = SHA256(cc_string)
cmd_hash = hashlib.sha256(cc_string.encode()).hexdigest()
header_file = self._get_header_file(cmd_hash)
with flock_append(header_file) as io:

Check failure on line 99 in src/blight/actions/embed_commands.py

View workflow job for this annotation

GitHub Actions / Trunk Check

mypy(arg-type)

[new] Argument 1 to "flock_append" has incompatible type "str"; expected "PathLike[Any]"
variable = """
Expand Down

0 comments on commit 1b11bc9

Please sign in to comment.