From 81ee8e6ac01b1eaa93fa8de6dbbd11f2d73781af Mon Sep 17 00:00:00 2001 From: AlexShefY Date: Sat, 2 Nov 2024 12:13:36 +0100 Subject: [PATCH] fix --- verified_cogen/runners/rewriters/__init__.py | 4 ++-- verified_cogen/runners/rewriters/nagini_rewriter.py | 6 +++--- .../runners/rewriters/nagini_rewriter_fixing.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/verified_cogen/runners/rewriters/__init__.py b/verified_cogen/runners/rewriters/__init__.py index 470af38..9572800 100644 --- a/verified_cogen/runners/rewriters/__init__.py +++ b/verified_cogen/runners/rewriters/__init__.py @@ -1,5 +1,5 @@ -from typing import Tuple, Optional +from typing import Tuple class Rewriter: - def rewrite(self, prg: str) -> Tuple[str, Optional[str]]: ... + def rewrite(self, prg: str) -> Tuple[str, str]: ... diff --git a/verified_cogen/runners/rewriters/nagini_rewriter.py b/verified_cogen/runners/rewriters/nagini_rewriter.py index cd95fde..8a5123f 100644 --- a/verified_cogen/runners/rewriters/nagini_rewriter.py +++ b/verified_cogen/runners/rewriters/nagini_rewriter.py @@ -1,10 +1,10 @@ -from typing import Tuple, Optional, List +from typing import Tuple, List from verified_cogen.runners.rewriters import Rewriter class NaginiRewriter(Rewriter): - def rewrite(self, prg: str) -> Tuple[str, Optional[str]]: + def rewrite(self, prg: str) -> Tuple[str, str]: pos_implications: List[Tuple[int, int]] = [] for idx, line in enumerate(prg.splitlines()): @@ -13,7 +13,7 @@ def rewrite(self, prg: str) -> Tuple[str, Optional[str]]: pos_implications.append((idx + 1, j + 1)) if len(pos_implications) == 0: - return prg, None + return prg, "" prompt = "Manual inspection revealed occurrences of `==>` operator for implication on the following positions:\n" prompt += ", ".join(f"({a}, {b})" for a, b in pos_implications) + "\n" diff --git a/verified_cogen/runners/rewriters/nagini_rewriter_fixing.py b/verified_cogen/runners/rewriters/nagini_rewriter_fixing.py index ace013c..c665334 100644 --- a/verified_cogen/runners/rewriters/nagini_rewriter_fixing.py +++ b/verified_cogen/runners/rewriters/nagini_rewriter_fixing.py @@ -1,4 +1,4 @@ -from typing import Tuple, Optional, Dict +from typing import Tuple, Optional, Dict, List from verified_cogen.runners.rewriters.__init__ import Rewriter from verified_cogen.runners.rewriters.nagini_rewriter import NaginiRewriter @@ -12,7 +12,7 @@ def __init__(self, rewriter: Optional[NaginiRewriter] = None): self.wrapped_rewriter = rewriter def replace_impl(self, prg: str): - indices = [] + indices: List[Tuple[int, str]] = [] for i in range(len(prg) - 2): if prg[i : i + 3] == "==>": @@ -55,8 +55,8 @@ def replace_impl(self, prg: str): return new_prg - def rewrite(self, prg: str) -> Tuple[str, Optional[str]]: - prompt = "" + def rewrite(self, prg: str) -> Tuple[str, str]: + prompt: str = "" if self.wrapped_rewriter is not None: _, prompt = self.wrapped_rewriter.rewrite(prg)