chore: enable F821, F401, W293 (#9503)

* auto fixes

* auto fix pt2 and transitive deps and undefined var checking locals()

* manual fixes (ignored or letta-code fixed)

* fix circular import
This commit is contained in:
Kian Jones
2026-02-17 10:07:40 -08:00
committed by Caren Thomas
parent fa70e09963
commit 25d54dd896
211 changed files with 534 additions and 2243 deletions

View File

@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Any, List, Literal, Optional
from typing import TYPE_CHECKING, List, Literal, Optional
from letta.constants import CORE_MEMORY_LINE_NUMBER_WARNING
@@ -67,7 +67,7 @@ def memory(
raise NotImplementedError("This should never be invoked directly. Contact Letta if you see this error message.")
def send_message(self: "Agent", message: str) -> Optional[str]:
def send_message(self: "Agent", message: str) -> Optional[str]: # noqa: F821
"""
Sends a message to the human user.
@@ -84,7 +84,7 @@ def send_message(self: "Agent", message: str) -> Optional[str]:
def conversation_search(
self: "Agent",
self: "Agent", # noqa: F821
query: Optional[str] = None,
roles: Optional[List[Literal["assistant", "user", "tool"]]] = None,
limit: Optional[int] = None,
@@ -160,7 +160,7 @@ def conversation_search(
return results_str
async def archival_memory_insert(self: "Agent", content: str, tags: Optional[list[str]] = None) -> Optional[str]:
async def archival_memory_insert(self: "Agent", content: str, tags: Optional[list[str]] = None) -> Optional[str]: # noqa: F821
"""
Add information to long-term archival memory for later retrieval.
@@ -191,7 +191,7 @@ async def archival_memory_insert(self: "Agent", content: str, tags: Optional[lis
async def archival_memory_search(
self: "Agent",
self: "Agent", # noqa: F821
query: str,
tags: Optional[list[str]] = None,
tag_match_mode: Literal["any", "all"] = "any",

View File

@@ -1,5 +1,5 @@
import asyncio
from typing import TYPE_CHECKING, List
from typing import List
from letta.functions.helpers import (
_send_message_to_agents_matching_tags_async,
@@ -10,9 +10,10 @@ from letta.functions.helpers import (
from letta.schemas.enums import MessageRole
from letta.schemas.message import MessageCreate
from letta.server.rest_api.dependencies import get_letta_server
from letta.settings import settings
def send_message_to_agent_and_wait_for_reply(self: "Agent", message: str, other_agent_id: str) -> str:
def send_message_to_agent_and_wait_for_reply(self: "Agent", message: str, other_agent_id: str) -> str: # noqa: F821
"""
Sends a message to a specific Letta agent within the same organization and waits for a response. The sender's identity is automatically included, so no explicit introduction is needed in the message. This function is designed for two-way communication where a reply is expected.
@@ -36,7 +37,7 @@ def send_message_to_agent_and_wait_for_reply(self: "Agent", message: str, other_
)
def send_message_to_agents_matching_tags(self: "Agent", message: str, match_all: List[str], match_some: List[str]) -> List[str]:
def send_message_to_agents_matching_tags(self: "Agent", message: str, match_all: List[str], match_some: List[str]) -> List[str]: # noqa: F821
"""
Sends a message to all agents within the same organization that match the specified tag criteria. Agents must possess *all* of the tags in `match_all` and *at least one* of the tags in `match_some` to receive the message.
@@ -65,7 +66,7 @@ def send_message_to_agents_matching_tags(self: "Agent", message: str, match_all:
return asyncio.run(_send_message_to_agents_matching_tags_async(self, server, messages, matching_agents))
def send_message_to_all_agents_in_group(self: "Agent", message: str) -> List[str]:
def send_message_to_all_agents_in_group(self: "Agent", message: str) -> List[str]: # noqa: F821
"""
Sends a message to all agents within the same multi-agent group.
@@ -81,7 +82,7 @@ def send_message_to_all_agents_in_group(self: "Agent", message: str) -> List[str
return asyncio.run(_send_message_to_all_agents_in_group_async(self, message))
def send_message_to_agent_async(self: "Agent", message: str, other_agent_id: str) -> str:
def send_message_to_agent_async(self: "Agent", message: str, other_agent_id: str) -> str: # noqa: F821
"""
Sends a message to a specific Letta agent within the same organization. The sender's identity is automatically included, so no explicit introduction is required in the message. This function does not expect a response from the target agent, making it suitable for notifications or one-way communication.
Args:

View File

@@ -4,7 +4,7 @@ from typing import List, Optional
from pydantic import BaseModel, Field
def rethink_user_memory(agent_state: "AgentState", new_memory: str) -> None:
def rethink_user_memory(agent_state: "AgentState", new_memory: str) -> None: # noqa: F821
"""
Rewrite memory block for the main agent, new_memory should contain all current information from the block that is not outdated or inconsistent, integrating any new information, resulting in a new memory block that is organized, readable, and comprehensive.
@@ -18,7 +18,7 @@ def rethink_user_memory(agent_state: "AgentState", new_memory: str) -> None:
return None
def finish_rethinking_memory(agent_state: "AgentState") -> None: # type: ignore
def finish_rethinking_memory(agent_state: "AgentState") -> None: # type: ignore # noqa: F821
"""
This function is called when the agent is done rethinking the memory.
@@ -43,7 +43,7 @@ class MemoryChunk(BaseModel):
)
def store_memories(agent_state: "AgentState", chunks: List[MemoryChunk]) -> None:
def store_memories(agent_state: "AgentState", chunks: List[MemoryChunk]) -> None: # noqa: F821
"""
Persist dialogue that is about to fall out of the agents context window.
@@ -59,7 +59,7 @@ def store_memories(agent_state: "AgentState", chunks: List[MemoryChunk]) -> None
def search_memory(
agent_state: "AgentState",
agent_state: "AgentState", # noqa: F821
convo_keyword_queries: Optional[List[str]],
start_minutes_ago: Optional[int],
end_minutes_ago: Optional[int],