From 86d3444fb8f9c46419dee88dd5c1fd1ff2be2ffa Mon Sep 17 00:00:00 2001 From: BillSchumacher <34168009+BillSchumacher@users.noreply.github.com> Date: Tue, 18 Apr 2023 18:59:23 -0500 Subject: [PATCH] isort, add proper skips. --- autogpt/agent/agent.py | 3 ++- autogpt/agent/agent_manager.py | 4 +--- autogpt/app.py | 22 ++++++------------- autogpt/cli.py | 3 +-- autogpt/commands/file_operations.py | 4 +--- autogpt/commands/web_selenium.py | 2 +- autogpt/config/config.py | 4 ++-- autogpt/json_fixes/master_json_fix_method.py | 4 +--- autogpt/llm_utils.py | 2 +- autogpt/logs.py | 5 ++--- autogpt/memory/milvus.py | 3 ++- autogpt/models/base_open_ai_plugin.py | 3 +-- autogpt/plugins.py | 11 +++++----- autogpt/token_counter.py | 1 + pyproject.toml | 1 + tests/test_commands.py | 2 +- .../unit/models/test_base_open_api_plugin.py | 7 ++++-- tests/unit/test_plugins.py | 4 +++- 18 files changed, 38 insertions(+), 47 deletions(-) diff --git a/autogpt/agent/agent.py b/autogpt/agent/agent.py index c0bb8d5b..6f1e15be 100644 --- a/autogpt/agent/agent.py +++ b/autogpt/agent/agent.py @@ -3,7 +3,8 @@ from colorama import Fore, Style from autogpt.app import execute_command, get_command from autogpt.chat import chat_with_ai, create_chat_message from autogpt.config import Config -from autogpt.json_fixes.master_json_fix_method import fix_json_using_multiple_techniques +from autogpt.json_fixes.master_json_fix_method import \ + fix_json_using_multiple_techniques from autogpt.json_validation.validate_json import validate_json from autogpt.logs import logger, print_assistant_thoughts from autogpt.speech import say_text diff --git a/autogpt/agent/agent_manager.py b/autogpt/agent/agent_manager.py index a35da3c2..9a62ef61 100644 --- a/autogpt/agent/agent_manager.py +++ b/autogpt/agent/agent_manager.py @@ -1,9 +1,7 @@ """Agent manager for managing GPT agents""" from __future__ import annotations -from typing import List - -from typing import Union +from typing import List, Union from autogpt.config.config import Config, Singleton from autogpt.llm_utils import create_chat_completion diff --git a/autogpt/app.py b/autogpt/app.py index 38e9cb58..10eb98bb 100644 --- a/autogpt/app.py +++ b/autogpt/app.py @@ -6,22 +6,14 @@ from autogpt.agent.agent_manager import AgentManager from autogpt.commands.audio_text import read_audio_from_file from autogpt.commands.command import CommandRegistry, command from autogpt.commands.evaluate_code import evaluate_code -from autogpt.commands.execute_code import ( - execute_python_file, - execute_shell, - execute_shell_popen, -) -from autogpt.commands.file_operations import ( - append_to_file, - delete_file, - download_file, - read_file, - search_files, - write_to_file, - download_file, -) +from autogpt.commands.execute_code import (execute_python_file, execute_shell, + execute_shell_popen) +from autogpt.commands.file_operations import (append_to_file, delete_file, + download_file, read_file, + search_files, write_to_file) from autogpt.commands.git_operations import clone_repository -from autogpt.commands.google_search import google_official_search, google_search +from autogpt.commands.google_search import (google_official_search, + google_search) from autogpt.commands.image_gen import generate_image from autogpt.commands.improve_code import improve_code from autogpt.commands.twitter import send_tweet diff --git a/autogpt/cli.py b/autogpt/cli.py index aaf17694..4cf82a65 100644 --- a/autogpt/cli.py +++ b/autogpt/cli.py @@ -74,15 +74,14 @@ def main( from colorama import Fore from autogpt.agent.agent import Agent - from autogpt.commands.command import CommandRegistry from autogpt.config import Config, check_openai_api_key from autogpt.configurator import create_config from autogpt.logs import logger from autogpt.memory import get_memory + from autogpt.plugins import scan_plugins from autogpt.prompts.prompt import construct_main_ai_config from autogpt.utils import get_latest_bulletin - from autogpt.plugins import scan_plugins if ctx.invoked_subcommand is None: cfg = Config() # TODO: fill in llm values here diff --git a/autogpt/commands/file_operations.py b/autogpt/commands/file_operations.py index 5bb45179..d850ea67 100644 --- a/autogpt/commands/file_operations.py +++ b/autogpt/commands/file_operations.py @@ -10,13 +10,11 @@ import requests from colorama import Back, Fore from requests.adapters import HTTPAdapter, Retry +from autogpt.commands.command import command from autogpt.spinner import Spinner from autogpt.utils import readable_file_size - -from autogpt.commands.command import command from autogpt.workspace import WORKSPACE_PATH, path_in_workspace - LOG_FILE = "file_logger.txt" LOG_FILE_PATH = WORKSPACE_PATH / LOG_FILE diff --git a/autogpt/commands/web_selenium.py b/autogpt/commands/web_selenium.py index ab607f7b..e0e0d70a 100644 --- a/autogpt/commands/web_selenium.py +++ b/autogpt/commands/web_selenium.py @@ -17,8 +17,8 @@ from selenium.webdriver.support.wait import WebDriverWait from webdriver_manager.chrome import ChromeDriverManager from webdriver_manager.firefox import GeckoDriverManager -from autogpt.commands.command import command import autogpt.processing.text as summary +from autogpt.commands.command import command from autogpt.config import Config from autogpt.processing.html import extract_hyperlinks, format_hyperlinks diff --git a/autogpt/config/config.py b/autogpt/config/config.py index 5c6856f5..af1bcf0d 100644 --- a/autogpt/config/config.py +++ b/autogpt/config/config.py @@ -1,10 +1,10 @@ """Configuration class to store the state of bools for different scripts access.""" import os - from typing import List + import openai -from auto_gpt_plugin_template import AutoGPTPluginTemplate import yaml +from auto_gpt_plugin_template import AutoGPTPluginTemplate from colorama import Fore from dotenv import load_dotenv diff --git a/autogpt/json_fixes/master_json_fix_method.py b/autogpt/json_fixes/master_json_fix_method.py index a77bf670..991a95f2 100644 --- a/autogpt/json_fixes/master_json_fix_method.py +++ b/autogpt/json_fixes/master_json_fix_method.py @@ -9,9 +9,7 @@ CFG = Config() def fix_json_using_multiple_techniques(assistant_reply: str) -> Dict[Any, Any]: from autogpt.json_fixes.parsing import ( - attempt_to_fix_json_by_finding_outermost_brackets, - fix_and_parse_json, - ) + attempt_to_fix_json_by_finding_outermost_brackets, fix_and_parse_json) # Parse and print Assistant response assistant_reply_json = fix_and_parse_json(assistant_reply) diff --git a/autogpt/llm_utils.py b/autogpt/llm_utils.py index 48561da9..d26fb2d6 100644 --- a/autogpt/llm_utils.py +++ b/autogpt/llm_utils.py @@ -8,8 +8,8 @@ from colorama import Fore, Style from openai.error import APIError, RateLimitError from autogpt.config import Config -from autogpt.types.openai import Message from autogpt.logs import logger +from autogpt.types.openai import Message CFG = Config() diff --git a/autogpt/logs.py b/autogpt/logs.py index df3487f2..4ae33432 100644 --- a/autogpt/logs.py +++ b/autogpt/logs.py @@ -204,9 +204,8 @@ logger = Logger() def print_assistant_thoughts(ai_name, assistant_reply): """Prints the assistant's thoughts to the console""" - from autogpt.json_fixes.bracket_termination import ( - attempt_to_fix_json_by_finding_outermost_brackets, - ) + from autogpt.json_fixes.bracket_termination import \ + attempt_to_fix_json_by_finding_outermost_brackets from autogpt.json_fixes.parsing import fix_and_parse_json try: diff --git a/autogpt/memory/milvus.py b/autogpt/memory/milvus.py index 44aa72b9..e2b8fea8 100644 --- a/autogpt/memory/milvus.py +++ b/autogpt/memory/milvus.py @@ -1,5 +1,6 @@ """ Milvus memory storage provider.""" -from pymilvus import Collection, CollectionSchema, DataType, FieldSchema, connections +from pymilvus import (Collection, CollectionSchema, DataType, FieldSchema, + connections) from autogpt.memory.base import MemoryProviderSingleton, get_ada_embedding diff --git a/autogpt/models/base_open_ai_plugin.py b/autogpt/models/base_open_ai_plugin.py index fafd3932..64214599 100644 --- a/autogpt/models/base_open_ai_plugin.py +++ b/autogpt/models/base_open_ai_plugin.py @@ -1,6 +1,5 @@ """Handles loading of plugins.""" -from typing import Any, Dict, List, Optional, Tuple, TypedDict -from typing import TypeVar +from typing import Any, Dict, List, Optional, Tuple, TypedDict, TypeVar from auto_gpt_plugin_template import AutoGPTPluginTemplate diff --git a/autogpt/plugins.py b/autogpt/plugins.py index 0979b856..c6324a54 100644 --- a/autogpt/plugins.py +++ b/autogpt/plugins.py @@ -4,20 +4,19 @@ import importlib import json import os import zipfile -import openapi_python_client -import requests - from pathlib import Path -from typing import List, Tuple, Optional +from typing import List, Optional, Tuple from urllib.parse import urlparse from zipimport import zipimporter +import openapi_python_client +import requests +from auto_gpt_plugin_template import AutoGPTPluginTemplate from openapi_python_client.cli import Config as OpenAPIConfig + from autogpt.config import Config from autogpt.models.base_open_ai_plugin import BaseOpenAIPlugin -from auto_gpt_plugin_template import AutoGPTPluginTemplate - def inspect_zip_for_module(zip_path: str, debug: bool = False) -> Optional[str]: """ diff --git a/autogpt/token_counter.py b/autogpt/token_counter.py index b1e59d86..2d50547b 100644 --- a/autogpt/token_counter.py +++ b/autogpt/token_counter.py @@ -1,5 +1,6 @@ """Functions for counting the number of tokens in a message or string.""" from __future__ import annotations + from typing import List import tiktoken diff --git a/pyproject.toml b/pyproject.toml index fdb43d66..72bb3ff8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ extend-exclude = '.+/(dist|.venv|venv|build)/.+' [tool.isort] profile = "black" +skip = venv,env,node_modules,.env,.venv,dist multi_line_output = 3 include_trailing_comma = true force_grid_wrap = 0 diff --git a/tests/test_commands.py b/tests/test_commands.py index 4be41a90..8a7771f6 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1,5 +1,5 @@ -import shutil import os +import shutil import sys from pathlib import Path diff --git a/tests/unit/models/test_base_open_api_plugin.py b/tests/unit/models/test_base_open_api_plugin.py index 3dc58d51..8f49c295 100644 --- a/tests/unit/models/test_base_open_api_plugin.py +++ b/tests/unit/models/test_base_open_api_plugin.py @@ -1,6 +1,9 @@ -import pytest from typing import Any, Dict, List, Optional, Tuple -from autogpt.models.base_open_ai_plugin import BaseOpenAIPlugin, Message, PromptGenerator + +import pytest + +from autogpt.models.base_open_ai_plugin import (BaseOpenAIPlugin, Message, + PromptGenerator) class DummyPlugin(BaseOpenAIPlugin): diff --git a/tests/unit/test_plugins.py b/tests/unit/test_plugins.py index 58e895bf..83656da2 100644 --- a/tests/unit/test_plugins.py +++ b/tests/unit/test_plugins.py @@ -1,6 +1,8 @@ import pytest -from autogpt.plugins import inspect_zip_for_module, scan_plugins, blacklist_whitelist_check + from autogpt.config import Config +from autogpt.plugins import (blacklist_whitelist_check, inspect_zip_for_module, + scan_plugins) PLUGINS_TEST_DIR = "tests/unit/data/test_plugins" PLUGIN_TEST_ZIP_FILE = "Auto-GPT-Plugin-Test-master.zip"