target file "bowler_bug.py":
def foo():
bar = 1
return bar(EOF)
code to run:
from bowler import Query
path = "bowler_bug.py"
Query(path).select_var("bar").rename("new_bar").execute(write=True, silent=True)
result:
hunks failed to apply, rejects saved to bowler_bug.py.rej
Traceback (most recent call last):
File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/bowler/tool.py", line 348, in apply_hunks
sh.patch(*args[1:], _in=accepted_hunks.encode("utf-8")) # type: ignore
File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 1427, in call
return RunningCommand(cmd, call_args, stdin, stdout, stderr)
File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 774, in init
self.wait()
File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 792, in wait
self.handle_command_exit_code(exit_code)
File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /usr/bin/patch -u bowler_bug.py
STDOUT:
patching file bowler_bug.py
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file bowler_bug.py.rej
I will take a look, the .rej file is probably missing the "no newline at end of file" line. If so this is likely https://bugs.python.org/issue2142 which is still open.
target file "bowler_bug.py": def foo(): bar = 1 return bar(EOF)
code to run: from bowler import Query path = "bowler_bug.py" Query(path).select_var("bar").rename("new_bar").execute(write=True, silent=True)
result: hunks failed to apply, rejects saved to bowler_bug.py.rej Traceback (most recent call last): File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/bowler/tool.py", line 348, in apply_hunks sh.patch(*args[1:], _in=accepted_hunks.encode("utf-8")) # type: ignore File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 1427, in call return RunningCommand(cmd, call_args, stdin, stdout, stderr) File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 774, in init self.wait() File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 792, in wait self.handle_command_exit_code(exit_code) File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 815, in handle_command_exit_code raise exc sh.ErrorReturnCode_1:
RAN: /usr/bin/patch -u bowler_bug.py
STDOUT: patching file bowler_bug.py Hunk #1 FAILED at 1. 1 out of 1 hunk FAILED -- saving rejects to file bowler_bug.py.rej
STDERR:
When a new line is added, the renaming works