Skip to content

Commit

Permalink
Fix import sorting and toggle pyupgrade (#6)
Browse files Browse the repository at this point in the history
* Set ruff target version to py311
* Set package sources in ruff to properly sort imports
* Toggle pyupgrade on in ruff config
  • Loading branch information
guiparpinelli authored Dec 13, 2023
1 parent 5e852b1 commit 9a630d8
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ exclude = [".cache"]
[tool.ruff]
# https://beta.ruff.rs/docs/configuration/
line-length = 120
select = ['E', 'W', 'F', 'I', 'B', 'C4', 'ARG', 'SIM']
select = ['E', 'W', 'F', 'I', 'B', 'C4', 'ARG', 'SIM', 'UP']
ignore = ['W291', 'W292', 'W293']
src = ["src", "tests"]
target-version = "py311"

[tool.ruff.lint.isort]
combine-as-imports = true
Expand Down
1 change: 1 addition & 0 deletions src/nalgonda/agency_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time

from agency_swarm import Agency, Agent

from nalgonda.config import AgencyConfig
from nalgonda.custom_tools import TOOL_MAPPING

Expand Down
3 changes: 2 additions & 1 deletion src/nalgonda/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

from agency_config_lock_manager import AgencyConfigLockManager
from agency_swarm import Agent
from nalgonda.constants import CONFIG_FILE, DEFAULT_CONFIG_FILE
from pydantic import BaseModel, Field
from pydantic_settings import BaseSettings, SettingsConfigDict

from nalgonda.constants import CONFIG_FILE, DEFAULT_CONFIG_FILE

LATEST_GPT_MODEL = "gpt-4-1106-preview"


Expand Down
1 change: 1 addition & 0 deletions src/nalgonda/custom_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Mapping tool names to actual tool classes
from agency_swarm.tools import CodeInterpreter, Retrieval

from nalgonda.custom_tools.build_directory_tree import BuildDirectoryTree
from nalgonda.custom_tools.generate_proposal import GenerateProposal
from nalgonda.custom_tools.print_all_files_in_directory import PrintAllFilesInDirectory
Expand Down
3 changes: 2 additions & 1 deletion src/nalgonda/custom_tools/generate_proposal.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from agency_swarm import BaseTool
from nalgonda.custom_tools.utils import get_chat_completion
from pydantic import Field

from nalgonda.custom_tools.utils import get_chat_completion

USER_PROMPT_PREFIX = "Please draft a proposal for the following project brief: "
SYSTEM_MESSAGE = """\
You are a professional proposal drafting assistant. \
Expand Down
2 changes: 1 addition & 1 deletion src/nalgonda/custom_tools/print_all_files_in_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ def read_file(file_path: Path):
"""Read and return the contents of a file."""
try:
return file_path.read_text()
except IOError as e:
except OSError as e:
return f"Error reading file {file_path}: {e}"
3 changes: 2 additions & 1 deletion src/nalgonda/custom_tools/write_and_save_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

from agency_swarm import BaseTool
from fastapi import WebSocket
from nalgonda.constants import DATA_DIR
from pydantic import Field

from nalgonda.constants import DATA_DIR


class File(BaseTool):
"""
Expand Down
3 changes: 2 additions & 1 deletion src/nalgonda/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from agency_swarm import Agency
from agency_swarm.messages import MessageOutput
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from nalgonda.constants import DATA_DIR
from websockets import ConnectionClosedOK

from nalgonda.constants import DATA_DIR

# Ensure directories exist
DATA_DIR.mkdir(exist_ok=True)

Expand Down
2 changes: 0 additions & 2 deletions tests/custom_tools/test_build_directory_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ def test_build_directory_tree_default_settings():
bdt = BuildDirectoryTree()
assert bdt.start_directory == Path.cwd()
assert bdt.file_extensions == set()


1 change: 1 addition & 0 deletions tests/custom_tools/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from nalgonda.custom_tools.utils import check_directory_traversal


@pytest.mark.parametrize("path", ["..", "/", "/sbin"])
def test_check_directory_traversal_raises_for_attempts(path):
with pytest.raises(ValueError) as e:
Expand Down

0 comments on commit 9a630d8

Please sign in to comment.