Fix IDE warnings (#12010)

### What problem does this PR solve?

As title

### Type of change

- [x] Refactoring

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2025-12-18 11:27:02 +08:00
committed by GitHub
parent a63dcfed6f
commit cc9546b761
25 changed files with 283 additions and 279 deletions

View File

@ -45,9 +45,9 @@ class TestChatAssistantCreate:
client.create_chat(name=name.upper())
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.create_chat(name=name)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
chat_assistant = client.create_chat(name=name)
assert chat_assistant.name == name
@ -68,9 +68,9 @@ class TestChatAssistantCreate:
dataset_ids = dataset_ids(dataset.id)
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.create_chat(name="ragflow test", dataset_ids=dataset_ids)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
chat_assistant = client.create_chat(name="ragflow test", dataset_ids=dataset_ids)
assert chat_assistant.name == "ragflow test"
@ -121,9 +121,9 @@ class TestChatAssistantCreate:
llm_o = Chat.LLM(client, llm)
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.create_chat(name="llm_test", dataset_ids=[dataset.id], llm=llm_o)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
chat_assistant = client.create_chat(name="llm_test", dataset_ids=[dataset.id], llm=llm_o)
if llm:
@ -189,9 +189,9 @@ class TestChatAssistantCreate:
prompt_o = Chat.Prompt(client, prompt)
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.create_chat(name="prompt_test", dataset_ids=[dataset.id], prompt=prompt_o)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
chat_assistant = client.create_chat(name="prompt_test", dataset_ids=[dataset.id], prompt=prompt_o)
if prompt:
@ -219,6 +219,6 @@ class TestChatAssistantCreate2:
@pytest.mark.p2
def test_unparsed_document(self, client, add_document):
dataset, _ = add_document
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.create_chat(name="prompt_test", dataset_ids=[dataset.id])
assert "doesn't own parsed file" in str(excinfo.value)
assert "doesn't own parsed file" in str(exception_info.value)

View File

@ -37,9 +37,9 @@ class TestChatAssistantsDelete:
payload = payload([chat_assistant.id for chat_assistant in chat_assistants])
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.delete_chats(**payload)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
if payload is None:
client.delete_chats(payload)
@ -71,9 +71,9 @@ class TestChatAssistantsDelete:
chat_ids = [chat.id for chat in chat_assistants]
client.delete_chats(ids=chat_ids)
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.delete_chats(ids=chat_ids)
assert "not found" in str(excinfo.value)
assert "not found" in str(exception_info.value)
@pytest.mark.p3
def test_duplicate_deletion(self, client, add_chat_assistants_func):

View File

@ -49,9 +49,9 @@ class TestChatAssistantsList:
)
def test_page(self, client, params, expected_page_size, expected_message):
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.list_chats(**params)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
assistants = client.list_chats(**params)
assert len(assistants) == expected_page_size
@ -80,9 +80,9 @@ class TestChatAssistantsList:
)
def test_page_size(self, client, params, expected_page_size, expected_message):
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.list_chats(**params)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
assistants = client.list_chats(**params)
assert len(assistants) == expected_page_size
@ -99,9 +99,9 @@ class TestChatAssistantsList:
)
def test_orderby(self, client, params, expected_message):
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.list_chats(**params)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
client.list_chats(**params)
@ -126,9 +126,9 @@ class TestChatAssistantsList:
)
def test_desc(self, client, params, expected_message):
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.list_chats(**params)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
client.list_chats(**params)
@ -144,9 +144,9 @@ class TestChatAssistantsList:
)
def test_name(self, client, params, expected_num, expected_message):
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.list_chats(**params)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
assistants = client.list_chats(**params)
if params["name"] in [None, ""]:
@ -172,9 +172,9 @@ class TestChatAssistantsList:
params = {"id": chat_assistant_id}
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.list_chats(**params)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
assistants = client.list_chats(**params)
if params["id"] in [None, ""]:
@ -200,9 +200,9 @@ class TestChatAssistantsList:
params = {"id": chat_assistant_id, "name": name}
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
client.list_chats(**params)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
assistants = client.list_chats(**params)
assert len(assistants) == expected_num

View File

@ -39,9 +39,9 @@ class TestChatAssistantUpdate:
chat_assistant = chat_assistants[0]
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
chat_assistant.update(payload)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
chat_assistant.update(payload)
updated_chat = client.list_chats(id=chat_assistant.id)[0]
@ -101,9 +101,9 @@ class TestChatAssistantUpdate:
payload = {"name": "llm_test", "llm": llm, "dataset_ids": [dataset.id]}
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
chat_assistant.update(payload)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
chat_assistant.update(payload)
updated_chat = client.list_chats(id=chat_assistant.id)[0]
@ -178,9 +178,9 @@ class TestChatAssistantUpdate:
payload = {"name": "prompt_test", "prompt": prompt, "dataset_ids": [dataset.id]}
if expected_message:
with pytest.raises(Exception) as excinfo:
with pytest.raises(Exception) as exception_info:
chat_assistant.update(payload)
assert expected_message in str(excinfo.value)
assert expected_message in str(exception_info.value)
else:
chat_assistant.update(payload)
updated_chat = client.list_chats(id=chat_assistant.id)[0]