Skip to content

Commit cf96b8c

Browse files
committed
add ruff
1 parent bb928bf commit cf96b8c

6 files changed

Lines changed: 16 additions & 9 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,6 @@ warn_redundant_casts = true
8585
warn_unreachable = true
8686
warn_unused_ignores = false
8787
plugins = ["returns.contrib.mypy.returns_plugin"]
88+
89+
[tool.ruff]
90+
exclude = ["tests/", "plots/"]

scripts/preprocess_benchmark.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
import json
44
import os
5-
import markdown_to_json
5+
66
import fire
7-
from tfbench.common import md2task, BenchmarkTask
87
from funcy import lmap
98

9+
from tfbench.common import md2task, BenchmarkTask
10+
1011

1112
def main(input_raw_benchmark_path: str = "benchmark", output_path: str = "tfb.json"):
1213

scripts/result_token_stat.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import json
2+
13
import tiktoken
24
import fire
35
from dacite import from_dict
4-
import json
5-
from funcy_chain import Chain
66
import pandas
77

8-
from tfbench.common import BenchmarkTask, get_prompt
8+
from tfbench.common import BenchmarkTask
99

1010

1111
def main(input_file="tfb.json"):
@@ -20,5 +20,6 @@ def main(input_file="tfb.json"):
2020
print(f"min: {df.token_count.min()}")
2121
print(f"avg: {df.token_count.mean()}")
2222

23+
2324
if __name__ == "__main__":
2425
fire.Fire(main)

src/tfbench/add_dependency.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def _is_input(code: str, call: str) -> bool:
5252
"""check if a function call is an input to the task"""
5353
inputs: list[list[str]] = (
5454
Chain(code.splitlines())
55-
.filter(lambda l: "=" in l)
56-
.map(lambda l: l.split("=")[0])
55+
.filter(lambda line: "=" in line)
56+
.map(lambda line: line.split("=")[0])
5757
.map(str.strip)
5858
.map(str.split)
5959
.value

src/tfbench/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def main(
102102
):
103103
"""script to extract benchmark tasks from Haskell repositories"""
104104
with open(input_repo_list_path) as fp:
105-
repo_id_list = [l.strip() for l in fp.readlines()]
105+
repo_id_list = [line.strip() for line in fp.readlines()]
106106

107107
logging.info(f"Loaded {len(repo_id_list)} repos to be processed")
108108
num_func = 0

src/tfbench/experiment.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
from typing import Callable
6+
import logging
67

78
from openai import OpenAI
89
from anthropic import Anthropic, InternalServerError
@@ -133,7 +134,8 @@ def generate_type_signature(prompt: str) -> str | None:
133134
thinking, answer = message.content
134135
text = answer.text # type: ignore
135136
return text if isinstance(text, str) else None
136-
except:
137+
except Exception as e:
138+
logging.error(f"Error processing message content: {e}")
137139
return None
138140

139141
return generate_type_signature

0 commit comments

Comments
 (0)