Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Replace | with Union in tools type hints

carlosejimenez5a964fd06f2b
diff --git a/tools/edit_linting/bin/edit b/tools/edit_linting/bin/edit
index 3458f9df..1a7c00fd 100644
--- a/tools/edit_linting/bin/edit
+++ b/tools/edit_linting/bin/edit
@@ -2,7 +2,7 @@
import argparse
import sys
-
+from typing import Union
try:
from sweagent import TOOLS_DIR
except ImportError:
@@ -57,7 +57,7 @@ def parse_line_range(line_range: str) -> tuple[int, int]:
exit(1)
-def main(line_range: str, replacement_text: str | None = None):
+def main(line_range: str, replacement_text: Union[str, None] = None):
# Handle file opening
try:
wf = WindowedFile(exit_on_exception=False)
diff --git a/tools/edit_replace/bin/insert b/tools/edit_replace/bin/insert
index d46e55f9..4a1187c6 100644
--- a/tools/edit_replace/bin/insert
+++ b/tools/edit_replace/bin/insert
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import argparse
+from typing import Union
from default_utils import FileNotOpened, WindowedFile # type: ignore
from flake8_utils import flake8, format_flake8_output # type: ignore
@@ -35,7 +36,7 @@ def get_parser() -> argparse.ArgumentParser:
return parser
-def main(text: str, line: int | None = None):
+def main(text: str, line: Union[int, None] = None):
try:
wf = WindowedFile(exit_on_exception=False)
except FileNotOpened: