diff --git a/aider/commands.py b/aider/commands.py index dad0de4f5..27268deb9 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -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 diff --git a/aider/dump.py b/aider/dump.py index 060ad28b3..de6dcbb6d 100644 --- a/aider/dump.py +++ b/aider/dump.py @@ -1,27 +1,29 @@ import traceback import json + def cvt(s): if isinstance(s, str): return s try: - return json.dumps(s, indent = 4) + return json.dumps(s, indent=4) except TypeError: return str(s) + def dump(*vals): # http://docs.python.org/library/traceback.html - stack= traceback.extract_stack() - vars= stack[-2][3] + 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) + vals = [cvt(v) for v in vals] + 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)) diff --git a/aider/utils.py b/aider/utils.py index 0b10f838a..1b9873b4b 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -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) diff --git a/tests/test_main.py b/tests/test_main.py index 39baf0f56..e1d56d2fb 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -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"))