mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-21 04:57:58 -05:00
fix(classic): fix linting and formatting errors across codebase
- Fix 32+ flake8 E501 (line too long) errors by shortening descriptions - Remove unused import in todo.py - Fix test_todo.py argument order (config= keyword) - Add type annotations to fix pyright errors where straightforward - Add noqa comments for flake8 false positives in __init__.py - Remove unused nonlocal declarations in main.py - Run black and isort to fix formatting - Update CLAUDE.md with improved linting commands Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -142,24 +142,21 @@ class BaseAgent(Generic[AnyProposal], metaclass=AgentMeta):
|
||||
return self.config.send_token_limit or self.llm.max_tokens * 3 // 4
|
||||
|
||||
@abstractmethod
|
||||
async def propose_action(self) -> AnyProposal:
|
||||
...
|
||||
async def propose_action(self) -> AnyProposal: ...
|
||||
|
||||
@abstractmethod
|
||||
async def execute(
|
||||
self,
|
||||
proposal: AnyProposal,
|
||||
user_feedback: str = "",
|
||||
) -> ActionResult:
|
||||
...
|
||||
) -> ActionResult: ...
|
||||
|
||||
@abstractmethod
|
||||
async def do_not_execute(
|
||||
self,
|
||||
denied_proposal: AnyProposal,
|
||||
user_feedback: str,
|
||||
) -> ActionResult:
|
||||
...
|
||||
) -> ActionResult: ...
|
||||
|
||||
def reset_trace(self):
|
||||
self._trace = []
|
||||
@@ -167,8 +164,7 @@ class BaseAgent(Generic[AnyProposal], metaclass=AgentMeta):
|
||||
@overload
|
||||
async def run_pipeline(
|
||||
self, protocol_method: Callable[P, Iterator[T]], *args, retry_limit: int = 3
|
||||
) -> list[T]:
|
||||
...
|
||||
) -> list[T]: ...
|
||||
|
||||
@overload
|
||||
async def run_pipeline(
|
||||
@@ -176,8 +172,7 @@ class BaseAgent(Generic[AnyProposal], metaclass=AgentMeta):
|
||||
protocol_method: Callable[P, None | Awaitable[None]],
|
||||
*args,
|
||||
retry_limit: int = 3,
|
||||
) -> list[None]:
|
||||
...
|
||||
) -> list[None]: ...
|
||||
|
||||
async def run_pipeline(
|
||||
self,
|
||||
|
||||
@@ -195,9 +195,11 @@ class ImageGeneratorComponent(
|
||||
# TODO: integrate in `forge.llm.providers`(?)
|
||||
response = OpenAI(
|
||||
api_key=self.openai_credentials.api_key.get_secret_value(),
|
||||
organization=self.openai_credentials.organization.get_secret_value()
|
||||
if self.openai_credentials.organization
|
||||
else None,
|
||||
organization=(
|
||||
self.openai_credentials.organization.get_secret_value()
|
||||
if self.openai_credentials.organization
|
||||
else None
|
||||
),
|
||||
).images.generate(
|
||||
prompt=prompt,
|
||||
n=1,
|
||||
|
||||
@@ -88,9 +88,7 @@ class SafeEvaluator(ast.NodeVisitor):
|
||||
if node.id in self.CONSTANTS:
|
||||
return self.CONSTANTS[node.id]
|
||||
avail = list(self.CONSTANTS.keys())
|
||||
raise CommandExecutionError(
|
||||
f"Unknown variable: {node.id}. Available: {avail}"
|
||||
)
|
||||
raise CommandExecutionError(f"Unknown variable: {node.id}. Available: {avail}")
|
||||
|
||||
def visit_BinOp(self, node: ast.BinOp) -> float:
|
||||
if type(node.op) not in self.OPERATORS:
|
||||
|
||||
@@ -65,9 +65,11 @@ class JSONSchema(BaseModel):
|
||||
type=schema["type"],
|
||||
enum=schema.get("enum"),
|
||||
items=JSONSchema.from_dict(schema["items"]) if "items" in schema else None,
|
||||
properties=JSONSchema.parse_properties(schema)
|
||||
if schema["type"] == "object"
|
||||
else None,
|
||||
properties=(
|
||||
JSONSchema.parse_properties(schema)
|
||||
if schema["type"] == "object"
|
||||
else None
|
||||
),
|
||||
minimum=schema.get("minimum"),
|
||||
maximum=schema.get("maximum"),
|
||||
minItems=schema.get("minItems"),
|
||||
@@ -153,13 +155,11 @@ class JSONSchema(BaseModel):
|
||||
|
||||
|
||||
@overload
|
||||
def _resolve_type_refs_in_schema(schema: dict, definitions: dict) -> dict:
|
||||
...
|
||||
def _resolve_type_refs_in_schema(schema: dict, definitions: dict) -> dict: ...
|
||||
|
||||
|
||||
@overload
|
||||
def _resolve_type_refs_in_schema(schema: list, definitions: dict) -> list:
|
||||
...
|
||||
def _resolve_type_refs_in_schema(schema: list, definitions: dict) -> list: ...
|
||||
|
||||
|
||||
def _resolve_type_refs_in_schema(schema: dict | list, definitions: dict) -> dict | list:
|
||||
|
||||
@@ -218,14 +218,14 @@ class Agent(BaseAgent[OneShotAgentActionProposal], Configurable[AgentSettings]):
|
||||
if exception:
|
||||
prompt.messages.append(ChatMessage.system(f"Error: {exception}"))
|
||||
|
||||
response: ChatModelResponse[
|
||||
OneShotAgentActionProposal
|
||||
] = await self.llm_provider.create_chat_completion(
|
||||
prompt.messages,
|
||||
model_name=self.llm.name,
|
||||
completion_parser=self.prompt_strategy.parse_response_content,
|
||||
functions=prompt.functions,
|
||||
prefill_response=prompt.prefill_response,
|
||||
response: ChatModelResponse[OneShotAgentActionProposal] = (
|
||||
await self.llm_provider.create_chat_completion(
|
||||
prompt.messages,
|
||||
model_name=self.llm.name,
|
||||
completion_parser=self.prompt_strategy.parse_response_content,
|
||||
functions=prompt.functions,
|
||||
prefill_response=prompt.prefill_response,
|
||||
)
|
||||
)
|
||||
result = response.parsed_result
|
||||
|
||||
|
||||
@@ -837,9 +837,7 @@ def print_assistant_thoughts(
|
||||
thoughts_text = remove_ansi_escape(
|
||||
thoughts.text
|
||||
if isinstance(thoughts, AssistantThoughts)
|
||||
else thoughts.summary()
|
||||
if isinstance(thoughts, ModelWithSummary)
|
||||
else thoughts
|
||||
else thoughts.summary() if isinstance(thoughts, ModelWithSummary) else thoughts
|
||||
)
|
||||
print_attribute(
|
||||
f"{ai_name.upper()} THOUGHTS", thoughts_text, title_color=Fore.YELLOW
|
||||
|
||||
Reference in New Issue
Block a user