mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 04:40:38 +08:00
fix
This commit is contained in:
@ -333,7 +333,7 @@ def load_yaml(response_text: str, keys_fix_yaml: List[str] = []) -> dict:
|
|||||||
def try_fix_yaml(response_text: str, keys_fix_yaml: List[str] = []) -> dict:
|
def try_fix_yaml(response_text: str, keys_fix_yaml: List[str] = []) -> dict:
|
||||||
response_text_lines = response_text.split('\n')
|
response_text_lines = response_text.split('\n')
|
||||||
|
|
||||||
keys = ['relevant line:', 'suggestion content:', 'relevant_file:', 'existing code:', 'improved code:']
|
keys = ['relevant line:', 'suggestion content:', 'relevant file:', 'existing code:', 'improved code:']
|
||||||
keys = keys + keys_fix_yaml
|
keys = keys + keys_fix_yaml
|
||||||
# first fallback - try to convert 'relevant line: ...' to relevant line: |-\n ...'
|
# first fallback - try to convert 'relevant line: ...' to relevant line: |-\n ...'
|
||||||
response_text_lines_copy = response_text_lines.copy()
|
response_text_lines_copy = response_text_lines.copy()
|
||||||
|
@ -38,16 +38,15 @@ PR Feedback:
|
|||||||
assert load_yaml(yaml_str) == expected_output
|
assert load_yaml(yaml_str) == expected_output
|
||||||
|
|
||||||
def test_load_invalid_yaml2(self):
|
def test_load_invalid_yaml2(self):
|
||||||
yaml_str = \
|
yaml_str = '''\
|
||||||
'''\
|
- relevant file: src/app.py:
|
||||||
- relevant file: src/app.py:
|
suggestion content: The print statement is outside inside the if __name__ ==: \
|
||||||
suggestion content: The print statement is outside inside the if __name__ ==: '''
|
'''
|
||||||
with pytest.raises(ScannerError):
|
with pytest.raises(ScannerError):
|
||||||
yaml.safe_load(yaml_str)
|
yaml.safe_load(yaml_str)
|
||||||
|
|
||||||
expected_output = [{'relevant file': 'src/app.py:',
|
expected_output = [{'relevant file': 'src/app.py:', 'suggestion content': 'The print statement is outside inside the if __name__ ==: '}]
|
||||||
'suggestion content': 'The print statement is outside inside the if __name__ ==: '}]
|
assert load_yaml(yaml_str) == expected_output
|
||||||
assert load_yaml(yaml_str) == expected_output
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user