Skip to content

Commit 5c206ca

Browse files
committed
fix ty type check errors for real this time
use getattr() for name-mangled private method access instead of direct attribute access, and use ty's native error code [unresolved-attribute] instead of mypy's [union-attr] for .func suppression comments
1 parent 0448793 commit 5c206ca

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

backend/tests/test_langchain_chat_manager.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,13 @@ def test_streaming_empty_chunk_skipped(mock_create_agent, oregon_state):
9595

9696
def test_agent_creation_with_thread_id(oregon_state, portland_city):
9797
cm = LangChainChatManager()
98-
agent = cm._LangChainChatManager__create_agent_for_session( # type: ignore[attr-defined]
99-
portland_city, oregon_state, "test-thread"
100-
)
98+
create = getattr(cm, "_LangChainChatManager__create_agent_for_session")
99+
agent = create(portland_city, oregon_state, "test-thread")
101100
assert agent is not None
102101

103102

104103
def test_agent_creation_without_thread_id(oregon_state, portland_city):
105104
cm = LangChainChatManager()
106-
agent = cm._LangChainChatManager__create_agent_for_session( # type: ignore[attr-defined]
107-
portland_city, oregon_state, None
108-
)
105+
create = getattr(cm, "_LangChainChatManager__create_agent_for_session")
106+
agent = create(portland_city, oregon_state, None)
109107
assert agent is not None

backend/tests/test_langchain_tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def test_retrieve_city_state_laws_returns_joined_docs(mock_rag_class):
131131
"""Test that RAG results are joined with newlines."""
132132
mock_rag_class.return_value.search.return_value = "Doc1 content\nDoc2 content"
133133

134-
result = retrieve_city_state_laws.func( # type: ignore[union-attr]
134+
result = retrieve_city_state_laws.func( # type: ignore[unresolved-attribute]
135135
query="eviction notice",
136136
state=UsaState("or"),
137137
city=OregonCity("portland"),
@@ -146,7 +146,7 @@ def test_retrieve_city_state_laws_empty_results(mock_rag_class):
146146
"""Test behavior when RAG returns no documents."""
147147
mock_rag_class.return_value.search.return_value = ""
148148

149-
result = retrieve_city_state_laws.func( # type: ignore[union-attr]
149+
result = retrieve_city_state_laws.func( # type: ignore[unresolved-attribute]
150150
query="obscure law",
151151
state=UsaState("or"),
152152
runtime=MagicMock(),
@@ -174,6 +174,6 @@ def test_generate_letter_empty_string(mock_get_stream_writer):
174174
mock_writer = MagicMock()
175175
mock_get_stream_writer.return_value = mock_writer
176176

177-
result = generate_letter.func(letter="") # type: ignore[union-attr]
177+
result = generate_letter.func(letter="") # type: ignore[unresolved-attribute]
178178
mock_writer.assert_called_once_with({"type": "letter", "content": ""})
179179
assert result == "Letter generated successfully."

0 commit comments

Comments
 (0)