mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
black formatting
This commit is contained in:
parent
3c26f90269
commit
9a413d351d
4 changed files with 26 additions and 16 deletions
|
@ -86,7 +86,10 @@ class Commands:
|
|||
return
|
||||
|
||||
if self.coder.repo.is_dirty():
|
||||
self.io.tool_error("The repository has uncommitted changes. Please commit or stash them before undoing.")
|
||||
self.io.tool_error(
|
||||
"The repository has uncommitted changes. Please commit or stash them before"
|
||||
" undoing."
|
||||
)
|
||||
return
|
||||
|
||||
local_head = self.coder.repo.git.rev_parse("HEAD")
|
||||
|
@ -100,7 +103,10 @@ class Commands:
|
|||
self.io.tool_error(f"Error: Unable to get the remote 'origin/{current_branch}'.")
|
||||
return
|
||||
if local_head == remote_head:
|
||||
self.io.tool_error("The last commit has already been pushed to the origin. Undoing is not possible.")
|
||||
self.io.tool_error(
|
||||
"The last commit has already been pushed to the origin. Undoing is not"
|
||||
" possible."
|
||||
)
|
||||
return
|
||||
|
||||
last_commit = self.coder.repo.head.commit
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import traceback
|
||||
import json
|
||||
|
||||
|
||||
def cvt(s):
|
||||
if isinstance(s, str):
|
||||
return s
|
||||
|
@ -9,19 +10,20 @@ def cvt(s):
|
|||
except TypeError:
|
||||
return str(s)
|
||||
|
||||
|
||||
def dump(*vals):
|
||||
# http://docs.python.org/library/traceback.html
|
||||
stack = traceback.extract_stack()
|
||||
vars = stack[-2][3]
|
||||
|
||||
# strip away the call to dump()
|
||||
vars= '('.join(vars.split('(')[1:])
|
||||
vars= ')'.join(vars.split(')')[:-1])
|
||||
vars = "(".join(vars.split("(")[1:])
|
||||
vars = ")".join(vars.split(")")[:-1])
|
||||
|
||||
vals = [cvt(v) for v in vals]
|
||||
has_newline = sum(1 for v in vals if '\n' in v)
|
||||
has_newline = sum(1 for v in vals if "\n" in v)
|
||||
if has_newline:
|
||||
print('%s:' % vars)
|
||||
print(', '.join(vals))
|
||||
print("%s:" % vars)
|
||||
print(", ".join(vals))
|
||||
else:
|
||||
print('%s:' % vars, ', '.join(vals))
|
||||
print("%s:" % vars, ", ".join(vals))
|
||||
|
|
|
@ -51,7 +51,9 @@ def try_dotdotdots(whole, part, replace):
|
|||
continue
|
||||
|
||||
if whole.count(part) != 1:
|
||||
raise ValueError("No perfect matching chunk in edit block with ... or part appears more than once")
|
||||
raise ValueError(
|
||||
"No perfect matching chunk in edit block with ... or part appears more than once"
|
||||
)
|
||||
|
||||
whole = whole.replace(part, replace, 1)
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@ class TestMain(TestCase):
|
|||
def test_main_with_empty_dir_no_files_on_command(self):
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
os.chdir(temp_dir)
|
||||
pipe_input = create_input(StringIO(''))
|
||||
pipe_input = create_input(StringIO(""))
|
||||
main([], input=pipe_input, output=DummyOutput())
|
||||
pipe_input.close()
|
||||
|
||||
def test_main_with_empty_dir_new_file(self):
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
os.chdir(temp_dir)
|
||||
pipe_input = create_input(StringIO(''))
|
||||
pipe_input = create_input(StringIO(""))
|
||||
main(["foo.txt"], input=pipe_input, output=DummyOutput())
|
||||
pipe_input.close()
|
||||
self.assertTrue(os.path.exists("foo.txt"))
|
||||
|
@ -29,7 +29,7 @@ class TestMain(TestCase):
|
|||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
os.chdir(temp_dir)
|
||||
subprocess.run(["git", "init"], cwd=temp_dir)
|
||||
pipe_input = create_input(StringIO(''))
|
||||
pipe_input = create_input(StringIO(""))
|
||||
main(["--yes", "foo.txt"], input=pipe_input, output=DummyOutput())
|
||||
pipe_input.close()
|
||||
self.assertTrue(os.path.exists("foo.txt"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue