Skip to content

Commit

Permalink
python: Fix formatting and typing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jubnzv committed Feb 26, 2022
1 parent 43ac759 commit 28fb96b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main(files: List[str], draw_cfg: str = "",
parser.add_argument("files", nargs='*', help="Path to IEC source files")
parser.add_argument("--draw-cfg", type=str,
help="Save control flow graph image at the selected path")
parser.add_argument("-b","--binary", default=os.path.join("output", "bin", "iec_checker"),
parser.add_argument("-b", "--binary", default=os.path.join("output", "bin", "iec_checker"),
help="File path to the OCaml binary")
args = parser.parse_args()
sys.exit(main(args.files, args.draw_cfg, args.binary))
2 changes: 1 addition & 1 deletion src/python/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def run_checker(file_path: str, binary: str = binary_default,


def run_checker_full_out(file_path: str, binary: str = binary_default,
*args) -> Tuple[int, str]:
*args) -> Tuple[int, str]:
"""Run iec-checker core for a given file and capture the whole output.
No extra options will be set by default."""
p = subprocess.Popen([binary, *args, file_path],
Expand Down
6 changes: 4 additions & 2 deletions src/python/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import logging
from dataclasses import dataclass
from typing import List
from typing import List, Optional
import ijson

from .om import Scheme
Expand All @@ -30,7 +30,7 @@ class DumpManager:

def __init__(self, dump_path: str):
self.dump_path: str = dump_path
self.scheme: Scheme = None
self.scheme: Optional[Scheme] = None

def __enter__(self):
self.scheme = self.mk_scheme()
Expand All @@ -51,6 +51,8 @@ def mk_scheme(self) -> Scheme:
with open(self.dump_path, 'rb') as f:
for item in ijson.items(f, ""):
scheme = Scheme.from_dict(item)
if not scheme:
raise Exception(f"Cannot parse JSON scheme from {self.dump_path}")
return scheme

def remove_dump(self):
Expand Down
1 change: 0 additions & 1 deletion src/python/om.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Object model
The Object model represents IR data from the iec-checker core.
"""

from dataclasses import dataclass
from typing import List, Dict, Set

Expand Down

0 comments on commit 28fb96b

Please sign in to comment.