diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d31238e66..7c19e0f54 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,4 +2,8 @@ repos: - repo: https://github.com/psf/black rev: 23.3.0 hooks: - - id: black \ No newline at end of file + - id: black + - repo: https://github.com/pycqa/flake8 + rev: 4.0.1 + hooks: + - id: flake8 diff --git a/coder.py b/coder.py index b50c20b87..47ef38d7f 100755 --- a/coder.py +++ b/coder.py @@ -1,24 +1,17 @@ #!/usr/bin/env python -import os import sys -import copy -import random -import json import re import readline import traceback import argparse from rich.console import Console -from rich.text import Text from rich.live import Live from rich.markdown import Markdown from tqdm import tqdm from pathlib import Path -from collections import defaultdict -from pygments import highlight, lexers, formatters import os import openai @@ -33,8 +26,6 @@ try: except FileNotFoundError: pass -formatter = formatters.TerminalFormatter() - openai.api_key = os.getenv("OPENAI_API_KEY") @@ -244,10 +235,6 @@ class Coder: def show_send_output_plain(self, completion): resp = "" - in_diff = False - diff_lines = [] - - partial_line = "" for chunk in completion: if chunk.choices[0].finish_reason not in (None, "stop"): dump(chunk.choices[0].finish_reason) @@ -265,10 +252,6 @@ class Coder: def show_send_output_color(self, completion): resp = "" - in_diff = False - diff_lines = [] - - partial_line = "" with Live(vertical_overflow="scroll") as live: for chunk in completion: if chunk.choices[0].finish_reason not in (None, "stop"): @@ -319,8 +302,8 @@ class Coder: # first populating an empty file new_content = after_text else: - before_lines = [l.strip() for l in before_text.splitlines()] - stripped_content = [l.strip() for l in content] + before_lines = [line.strip() for line in before_text.splitlines()] + stripped_content = [line.strip() for line in content] where = find_index(stripped_content, before_lines) if where < 0: