added flake8

This commit is contained in:
Paul Gauthier 2023-05-07 22:13:57 -07:00
parent 3c98410d62
commit 1d0d3c700e
2 changed files with 7 additions and 20 deletions

View file

@ -3,3 +3,7 @@ repos:
rev: 23.3.0 rev: 23.3.0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8

View file

@ -1,24 +1,17 @@
#!/usr/bin/env python #!/usr/bin/env python
import os
import sys import sys
import copy
import random
import json
import re import re
import readline import readline
import traceback import traceback
import argparse import argparse
from rich.console import Console from rich.console import Console
from rich.text import Text
from rich.live import Live from rich.live import Live
from rich.markdown import Markdown from rich.markdown import Markdown
from tqdm import tqdm from tqdm import tqdm
from pathlib import Path from pathlib import Path
from collections import defaultdict
from pygments import highlight, lexers, formatters
import os import os
import openai import openai
@ -33,8 +26,6 @@ try:
except FileNotFoundError: except FileNotFoundError:
pass pass
formatter = formatters.TerminalFormatter()
openai.api_key = os.getenv("OPENAI_API_KEY") openai.api_key = os.getenv("OPENAI_API_KEY")
@ -244,10 +235,6 @@ class Coder:
def show_send_output_plain(self, completion): def show_send_output_plain(self, completion):
resp = "" resp = ""
in_diff = False
diff_lines = []
partial_line = ""
for chunk in completion: for chunk in completion:
if chunk.choices[0].finish_reason not in (None, "stop"): if chunk.choices[0].finish_reason not in (None, "stop"):
dump(chunk.choices[0].finish_reason) dump(chunk.choices[0].finish_reason)
@ -265,10 +252,6 @@ class Coder:
def show_send_output_color(self, completion): def show_send_output_color(self, completion):
resp = "" resp = ""
in_diff = False
diff_lines = []
partial_line = ""
with Live(vertical_overflow="scroll") as live: with Live(vertical_overflow="scroll") as live:
for chunk in completion: for chunk in completion:
if chunk.choices[0].finish_reason not in (None, "stop"): if chunk.choices[0].finish_reason not in (None, "stop"):
@ -319,8 +302,8 @@ class Coder:
# first populating an empty file # first populating an empty file
new_content = after_text new_content = after_text
else: else:
before_lines = [l.strip() for l in before_text.splitlines()] before_lines = [line.strip() for line in before_text.splitlines()]
stripped_content = [l.strip() for l in content] stripped_content = [line.strip() for line in content]
where = find_index(stripped_content, before_lines) where = find_index(stripped_content, before_lines)
if where < 0: if where < 0: