diff --git a/application/api/answer/services/compression/service.py b/application/api/answer/services/compression/service.py index 83cc0e37..ccf6f126 100644 --- a/application/api/answer/services/compression/service.py +++ b/application/api/answer/services/compression/service.py @@ -11,7 +11,6 @@ from application.api.answer.services.compression.prompt_builder import ( from application.api.answer.services.compression.token_counter import TokenCounter from application.api.answer.services.compression.types import ( CompressionMetadata, - CompressionResult, ) from application.core.settings import settings diff --git a/tests/test_agent_token_tracking.py b/tests/test_agent_token_tracking.py index bd122cd7..e168567a 100644 --- a/tests/test_agent_token_tracking.py +++ b/tests/test_agent_token_tracking.py @@ -1,5 +1,5 @@ import pytest -from unittest.mock import Mock, MagicMock, patch +from unittest.mock import Mock, patch from application.agents.base import BaseAgent from application.llm.handlers.base import LLMHandler, ToolCall @@ -310,7 +310,7 @@ class TestLLMHandlerTokenTracking: tools_dict = {} # Execute streaming - results = list(handler.handle_streaming(mock_agent, "first", tools_dict, messages)) + list(handler.handle_streaming(mock_agent, "first", tools_dict, messages)) # Should have called gen_stream with tools=None (disabled) mock_agent.llm.gen_stream.assert_called() diff --git a/tests/test_compression_service.py b/tests/test_compression_service.py index 9dc6b278..c6700e3a 100644 --- a/tests/test_compression_service.py +++ b/tests/test_compression_service.py @@ -1,6 +1,6 @@ import pytest from datetime import datetime, timezone -from unittest.mock import Mock, MagicMock, patch +from unittest.mock import Mock, patch from application.api.answer.services.compression import CompressionService from application.api.answer.services.compression.threshold_checker import ( @@ -258,7 +258,7 @@ class TestCompressionService: mock_summary = "Test summary with tools" compression_service.llm.gen.return_value = mock_summary - result = compression_service.compress_conversation( + compression_service.compress_conversation( conversation=conversation, compress_up_to_index=0 ) diff --git a/tests/test_integration.py b/tests/test_integration.py index f2953aef..a3588c7e 100755 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -334,7 +334,7 @@ DocsGPT provides: try: error_data = response.json() self.print_error(f"Error: {error_data}") - except: + except Exception: self.print_error(f"Response: {response.text[:500]}") self.test_results.append((test_name, False, f"Status {response.status_code}")) return None @@ -371,7 +371,7 @@ DocsGPT provides: try: self.print_info(f"POST {endpoint}") - self.print_info(f"Crawling: https://docs.docsgpt.cloud/") + self.print_info("Crawling: https://docs.docsgpt.cloud/") response = requests.post( endpoint, @@ -401,7 +401,7 @@ DocsGPT provides: try: error_data = response.json() self.print_error(f"Error: {error_data}") - except: + except Exception: self.print_error(f"Response: {response.text[:500]}") self.test_results.append((test_name, False, f"Status {response.status_code}")) return None @@ -556,7 +556,7 @@ DocsGPT provides: try: error_data = response.json() self.print_error(f"Error: {error_data.get('message', response.text[:200])}") - except: + except Exception: self.print_error(f"Response: {response.text[:500]}") self.test_results.append((test_name, False, f"Status {response.status_code}")) return None @@ -803,7 +803,7 @@ DocsGPT provides: try: error_data = response.json() self.print_error(f"Error: {error_data.get('message', response.text[:200])}") - except: + except Exception: self.print_error(f"Response: {response.text[:500]}") self.test_results.append((test_name, False, f"Status {response.status_code}")) return None @@ -997,7 +997,7 @@ DocsGPT provides: conversation_id = result.get('conversation_id', conversation_id) self.print_success("Critical information sent") else: - self.print_error(f"Critical info request failed") + self.print_error("Critical info request failed") self.test_results.append((test_name, False, "Critical info failed")) return False time.sleep(2) @@ -1027,7 +1027,7 @@ DocsGPT provides: conversation_id = result.get('conversation_id', conversation_id) self.print_success(f"Burying question {i+1}/2 completed") else: - self.print_error(f"Request failed") + self.print_error("Request failed") self.test_results.append((test_name, False, "Burying questions failed")) return False time.sleep(2) @@ -1064,7 +1064,7 @@ DocsGPT provides: self.test_results.append((test_name, False, "Info not preserved")) return False else: - self.print_error(f"Recall request failed") + self.print_error("Recall request failed") self.test_results.append((test_name, False, "Recall failed")) return False except Exception as e: diff --git a/tests/test_model_validation.py b/tests/test_model_validation.py index 587f04a7..379ccbf6 100644 --- a/tests/test_model_validation.py +++ b/tests/test_model_validation.py @@ -64,7 +64,7 @@ def test_model_without_base_url(): def test_validate_model_id(): """Test model_id validation""" # Get the registry instance to check what models are available - registry = ModelRegistry.get_instance() + ModelRegistry.get_instance() # Test with a model that should exist (docsgpt-local is always added) assert validate_model_id("docsgpt-local") is True diff --git a/tests/test_token_management.py b/tests/test_token_management.py index 3156cfae..0b166953 100644 --- a/tests/test_token_management.py +++ b/tests/test_token_management.py @@ -6,6 +6,7 @@ They are skipped until the following modules are created: - application.compression (DocumentCompressor, HistoryCompressor, etc.) - application.core.token_budget (TokenBudgetManager) """ +# ruff: noqa: F821 import pytest pytest.skip(