Skip to content

Commit c2265e8

Browse files
Fix pr #5058: Add API endpoints for resolver functionality
1 parent 87925dd commit c2265e8

25 files changed

+916
-965
lines changed

frontend/public/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"APP_MODE": "oss",
33
"GITHUB_CLIENT_ID": "",
44
"POSTHOG_CLIENT_KEY": "phc_3ESMmY9SgqEAGBB6sMGK5ayYHkeUuknH2vP6FmWH9RA"
5-
}
5+
}

openhands/agenthub/codeact_agent/codeact_agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ def get_action_message(
187187
)
188188
]
189189
elif isinstance(action, CmdRunAction) and action.source == 'user':
190-
content = [TextContent(text=f'User executed the command:\n{action.command}')]
190+
content = [
191+
TextContent(text=f'User executed the command:\n{action.command}')
192+
]
191193
return [
192194
Message(
193195
role='user',

openhands/events/action/message.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def images_urls(self):
2424
@images_urls.setter
2525
def images_urls(self, value):
2626
self.image_urls = value
27+
2728
def __str__(self) -> str:
2829
ret = f'**MessageAction** (source={self.source})\n'
2930
ret += f'CONTENT: {self.content}'

openhands/events/serialization/action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def action_from_dict(action: dict) -> Action:
6969
# images_urls has been renamed to image_urls
7070
if 'images_urls' in args:
7171
args['image_urls'] = args.pop('images_urls')
72-
72+
7373
try:
7474
decoded_action = action_class(**args)
7575
if 'timeout' in action:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
from .patch import parse_patch
43
from .apply import apply_diff
4+
from .patch import parse_patch
55

6-
__all__ = ["parse_patch", "apply_diff"]
6+
__all__ = ['parse_patch', 'apply_diff']

openhands/resolver/patching/apply.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,33 @@
1010

1111
def _apply_diff_with_subprocess(diff, lines, reverse=False):
1212
# call out to patch program
13-
patchexec = which("patch")
13+
patchexec = which('patch')
1414
if not patchexec:
15-
raise SubprocessException("cannot find patch program", code=-1)
15+
raise SubprocessException('cannot find patch program', code=-1)
1616

1717
tempdir = tempfile.gettempdir()
1818

19-
filepath = os.path.join(tempdir, "wtp-" + str(hash(diff.header)))
20-
oldfilepath = filepath + ".old"
21-
newfilepath = filepath + ".new"
22-
rejfilepath = filepath + ".rej"
23-
patchfilepath = filepath + ".patch"
24-
with open(oldfilepath, "w") as f:
25-
f.write("\n".join(lines) + "\n")
19+
filepath = os.path.join(tempdir, 'wtp-' + str(hash(diff.header)))
20+
oldfilepath = filepath + '.old'
21+
newfilepath = filepath + '.new'
22+
rejfilepath = filepath + '.rej'
23+
patchfilepath = filepath + '.patch'
24+
with open(oldfilepath, 'w') as f:
25+
f.write('\n'.join(lines) + '\n')
2626

27-
with open(patchfilepath, "w") as f:
27+
with open(patchfilepath, 'w') as f:
2828
f.write(diff.text)
2929

3030
args = [
3131
patchexec,
32-
"--reverse" if reverse else "--forward",
33-
"--quiet",
34-
"--no-backup-if-mismatch",
35-
"-o",
32+
'--reverse' if reverse else '--forward',
33+
'--quiet',
34+
'--no-backup-if-mismatch',
35+
'-o',
3636
newfilepath,
37-
"-i",
37+
'-i',
3838
patchfilepath,
39-
"-r",
39+
'-r',
4040
rejfilepath,
4141
oldfilepath,
4242
]
@@ -58,7 +58,7 @@ def _apply_diff_with_subprocess(diff, lines, reverse=False):
5858

5959
# do this last to ensure files get cleaned up
6060
if ret != 0:
61-
raise SubprocessException("patch program failed", code=ret)
61+
raise SubprocessException('patch program failed', code=ret)
6262

6363
return lines, rejlines
6464

openhands/resolver/patching/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def __init__(self, msg, hunk=None):
77
self.hunk = hunk
88
if hunk is not None:
99
super(HunkException, self).__init__(
10-
"{msg}, in hunk #{n}".format(msg=msg, n=hunk)
10+
'{msg}, in hunk #{n}'.format(msg=msg, n=hunk)
1111
)
1212
else:
1313
super(HunkException, self).__init__(msg)

0 commit comments

Comments
 (0)