From 4ed682397a6d550839368f5de569c9e10fc8ac8c Mon Sep 17 00:00:00 2001 From: Dixing Xu Date: Thu, 21 Nov 2024 17:37:47 +0800 Subject: [PATCH] :rotating_light: add linter workflow and fix lint issues --- .github/workflows/lint.yml | 21 +++++++++++++++++++++ aide/__init__.py | 5 +---- aide/agent.py | 2 +- aide/backend/utils.py | 6 +++--- aide/interpreter.py | 2 +- aide/run.py | 2 -- 6 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..5dd1b99 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,21 @@ +name: Lint + +on: + - push + - pull_request + +jobs: + lint-python: + name: ruff + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + steps: + - name: Checkout Code + uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.11 + - name: Install Ruff + run: pip install ruff==0.7.1 + - name: Run Ruff + run: ruff check --output-format=github aide/ \ No newline at end of file diff --git a/aide/__init__.py b/aide/__init__.py index eddc964..e669170 100644 --- a/aide/__init__.py +++ b/aide/__init__.py @@ -1,14 +1,11 @@ from dataclasses import dataclass -from .backend import compile_prompt_to_md - from .agent import Agent from .interpreter import Interpreter -from .journal import Journal, Node +from .journal import Journal from omegaconf import OmegaConf from rich.status import Status from .utils.config import load_task_desc, prep_agent_workspace, save_run, _load_cfg, prep_cfg -from pathlib import Path @dataclass class Solution: diff --git a/aide/agent.py b/aide/agent.py index 45d39e6..2fe9c12 100644 --- a/aide/agent.py +++ b/aide/agent.py @@ -3,7 +3,7 @@ from typing import Any, Callable, cast import humanize -from .backend import FunctionSpec, compile_prompt_to_md, query +from .backend import FunctionSpec, query from .interpreter import ExecutionResult from .journal import Journal, Node from .utils import data_preview diff --git a/aide/backend/utils.py b/aide/backend/utils.py index d223b1b..914ec90 100644 --- a/aide/backend/utils.py +++ b/aide/backend/utils.py @@ -2,15 +2,15 @@ import jsonschema from dataclasses_json import DataClassJsonMixin +import backoff +import logging +from typing import Callable PromptType = str | dict | list FunctionCallType = dict OutputType = str | FunctionCallType -import backoff -import logging -from typing import Callable logger = logging.getLogger("aide") diff --git a/aide/interpreter.py b/aide/interpreter.py index 87e4d96..f6a947f 100644 --- a/aide/interpreter.py +++ b/aide/interpreter.py @@ -49,7 +49,7 @@ def exception_summary(e, working_dir, exec_file_name, format_tb_ipython): tb_lines = traceback.format_exception(e) # skip parts of stack trace in weflow code tb_str = "".join( - [l for l in tb_lines if "aide/" not in l and "importlib" not in l] + [line for line in tb_lines if "aide/" not in line and "importlib" not in line] ) # tb_str = "".join([l for l in tb_lines]) diff --git a/aide/run.py b/aide/run.py index c813428..035383e 100644 --- a/aide/run.py +++ b/aide/run.py @@ -4,7 +4,6 @@ from . import backend -from .utils import tree_export from .agent import Agent from .interpreter import Interpreter from .journal import Journal, Node @@ -23,7 +22,6 @@ TimeRemainingColumn, ) from rich.text import Text -from rich.markdown import Markdown from rich.status import Status from rich.tree import Tree from .utils.config import load_task_desc, prep_agent_workspace, save_run, load_cfg