diff --git a/gns3server/agent/gns3_copilot/agent/context_manager.py b/gns3server/agent/gns3_copilot/agent/context_manager.py index 5337c3d95..419e7785c 100644 --- a/gns3server/agent/gns3_copilot/agent/context_manager.py +++ b/gns3server/agent/gns3_copilot/agent/context_manager.py @@ -391,10 +391,10 @@ def create_pre_model_hook( max_tokens_for_trim = max_input_tokens - tool_tokens # Validate budget and provide actionable warnings - if system_tokens + tool_tokens > max_input_tokens: # noqa: E501 + if system_tokens + tool_tokens > max_input_tokens: logger.error( "System prompt (%d tokens) + tools (%d tokens) EXCEED input " - "budget (%d tokens). This will likely cause LLM call failures. " # noqa: E501 + "budget (%d tokens). This will likely cause LLM call failures. " "Recommendations: 1) Reduce system prompt length, 2) Reduce " "number of tools, 3) Use a model with larger context window, " "or 4) Switch to 'conservative' strategy.", diff --git a/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py b/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py index ed15f0589..6b96e6202 100644 --- a/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py +++ b/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py @@ -57,7 +57,7 @@ from gns3server.agent.gns3_copilot.utils.command_filter import ( # Import custom Netmiko device types for GNS3 emulation # This registers gns3_huawei_telnet_ce and other custom device types # NOTE: Must be imported BEFORE any Nornir operations to ensure device types are registered -from gns3server.agent.gns3_copilot.utils import custom_netmiko # noqa: F401 +from gns3server.agent.gns3_copilot.utils import custom_netmiko # Explicitly register custom device types to ensure they are available # This is a safety measure in case the auto-registration on import doesn't work diff --git a/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py b/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py index a8eb41bc4..206ca10ea 100644 --- a/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py +++ b/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py @@ -57,7 +57,7 @@ from gns3server.agent.gns3_copilot.utils.command_filter import ( # Import custom Netmiko device types for GNS3 emulation # This registers gns3_huawei_telnet_ce and other custom device types # NOTE: Must be imported BEFORE any Nornir operations to ensure device types are registered -from gns3server.agent.gns3_copilot.utils import custom_netmiko # noqa: F401 +from gns3server.agent.gns3_copilot.utils import custom_netmiko # Explicitly register custom device types to ensure they are available # This is a safety measure in case the auto-registration on import doesn't work diff --git a/gns3server/agent/gns3_copilot/tools_v2/vpcs_tools_netmiko.py b/gns3server/agent/gns3_copilot/tools_v2/vpcs_tools_netmiko.py index 1315730c7..d9186d2d4 100644 --- a/gns3server/agent/gns3_copilot/tools_v2/vpcs_tools_netmiko.py +++ b/gns3server/agent/gns3_copilot/tools_v2/vpcs_tools_netmiko.py @@ -54,7 +54,7 @@ from gns3server.agent.gns3_copilot.utils import get_device_ports_from_topology # Import custom Netmiko device types for GNS3 emulation # This registers gns3_vpcs_telnet and other custom device types # NOTE: Must be imported BEFORE any Nornir operations to ensure device types are registered -from gns3server.agent.gns3_copilot.utils import custom_netmiko # noqa: F401 +from gns3server.agent.gns3_copilot.utils import custom_netmiko # Explicitly register VPCS device type to ensure it is available try: diff --git a/gns3server/agent/gns3_copilot/utils/custom_netmiko/__init__.py b/gns3server/agent/gns3_copilot/utils/custom_netmiko/__init__.py index 1aea7adf8..9cad247ca 100644 --- a/gns3server/agent/gns3_copilot/utils/custom_netmiko/__init__.py +++ b/gns3server/agent/gns3_copilot/utils/custom_netmiko/__init__.py @@ -61,17 +61,17 @@ logger = logging.getLogger(__name__) # Import all custom drivers (auto-registers them with Netmiko) try: - from . import huawei_ce # noqa: F401 + from . import huawei_ce except Exception as e: logger.warning(f"Failed to import Huawei CE driver: {e}", exc_info=True) try: - from .ruijie_telnet import RuijieTelnetEnhanced # noqa: F401 + from .ruijie_telnet import RuijieTelnetEnhanced except Exception as e: logger.warning(f"Failed to import Ruijie driver: {e}", exc_info=True) try: - from . import vpcs_telnet # noqa: F401 + from . import vpcs_telnet except Exception as e: logger.warning(f"Failed to import VPCS driver: {e}", exc_info=True) diff --git a/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_huawei_ce.py b/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_huawei_ce.py index c6b6db344..62343c3ef 100644 --- a/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_huawei_ce.py +++ b/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_huawei_ce.py @@ -157,7 +157,7 @@ class TestHuaweiTelnetCEIntegration(unittest.TestCase): def test_mock_telnet_connection(self): """Test telnet_login logic with mocked connection.""" - from gns3server.agent.gns3_copilot.utils.custom_netmiko.huawei_ce import ( # noqa: E501 + from gns3server.agent.gns3_copilot.utils.custom_netmiko.huawei_ce import ( GNS3HuaweiTelnetCE, ) diff --git a/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_ruijie_telnet.py b/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_ruijie_telnet.py index dfef81823..adfbafea2 100644 --- a/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_ruijie_telnet.py +++ b/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_ruijie_telnet.py @@ -178,7 +178,7 @@ class TestRuijieTelnetEnhancedIntegration(unittest.TestCase): def test_send_config_set_calls_preprocess(self): """Test that send_config_set calls preprocessing.""" - from gns3server.agent.gns3_copilot.utils.custom_netmiko.ruijie_telnet import ( # noqa: E501 + from gns3server.agent.gns3_copilot.utils.custom_netmiko.ruijie_telnet import ( RuijieTelnetEnhanced, ) @@ -205,7 +205,7 @@ class TestRuijieTelnetEnhancedIntegration(unittest.TestCase): def test_multiple_interactive_patterns(self): """Test that multiple interactive commands are detected.""" - from gns3server.agent.gns3_copilot.utils.custom_netmiko.ruijie_telnet import ( # noqa: E501 + from gns3server.agent.gns3_copilot.utils.custom_netmiko.ruijie_telnet import ( RuijieTelnetEnhanced, ) diff --git a/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_vpcs_telnet.py b/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_vpcs_telnet.py index 4659465cd..f24565d85 100644 --- a/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_vpcs_telnet.py +++ b/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_vpcs_telnet.py @@ -116,7 +116,7 @@ class TestVPCSTelnetInit(unittest.TestCase): @classmethod def setUpClass(cls): """Set up test fixtures.""" - from gns3server.agent.gns3_copilot.utils.custom_netmiko.vpcs_telnet import ( # noqa: E501 + from gns3server.agent.gns3_copilot.utils.custom_netmiko.vpcs_telnet import ( VPCSTelnet, ) @@ -165,7 +165,7 @@ class TestVPCSTelnetMethods(unittest.TestCase): @classmethod def setUpClass(cls): """Set up test fixtures.""" - from gns3server.agent.gns3_copilot.utils.custom_netmiko.vpcs_telnet import ( # noqa: E501 + from gns3server.agent.gns3_copilot.utils.custom_netmiko.vpcs_telnet import ( VPCSTelnet, ) @@ -208,7 +208,7 @@ class TestVPCSTelnetSendCommand(unittest.TestCase): @classmethod def setUpClass(cls): """Set up test fixtures.""" - from gns3server.agent.gns3_copilot.utils.custom_netmiko.vpcs_telnet import ( # noqa: E501 + from gns3server.agent.gns3_copilot.utils.custom_netmiko.vpcs_telnet import ( VPCSTelnet, ) @@ -273,7 +273,7 @@ class TestVPCSTelnetTelnetLogin(unittest.TestCase): @classmethod def setUpClass(cls): """Set up test fixtures.""" - from gns3server.agent.gns3_copilot.utils.custom_netmiko.vpcs_telnet import ( # noqa: E501 + from gns3server.agent.gns3_copilot.utils.custom_netmiko.vpcs_telnet import ( VPCSTelnet, ) @@ -353,7 +353,7 @@ class TestVPCSTelnetAnsiStripping(unittest.TestCase): @classmethod def setUpClass(cls): """Set up test fixtures.""" - from gns3server.agent.gns3_copilot.utils.custom_netmiko.vpcs_telnet import ( # noqa: E501 + from gns3server.agent.gns3_copilot.utils.custom_netmiko.vpcs_telnet import ( VPCSTelnet, ) diff --git a/gns3server/agent/gns3_copilot/utils/gns3_drawing_utils.py b/gns3server/agent/gns3_copilot/utils/gns3_drawing_utils.py index a28278744..4fa48ee7d 100644 --- a/gns3server/agent/gns3_copilot/utils/gns3_drawing_utils.py +++ b/gns3server/agent/gns3_copilot/utils/gns3_drawing_utils.py @@ -238,7 +238,7 @@ def generate_ellipse_svg( svg_height: int, ) -> str: """Generate SVG for ellipse.""" - return f"""""" # noqa: E501 + return f"""""" def generate_rectangle_svg( @@ -247,7 +247,7 @@ def generate_rectangle_svg( color_scheme: dict[str, Any], ) -> str: """Generate SVG for rectangle.""" - return f"""""" # noqa: E501 + return f"""""" def generate_text_svg(text: str, color_scheme: dict[str, Any]) -> str: @@ -255,7 +255,7 @@ def generate_text_svg(text: str, color_scheme: dict[str, Any]) -> str: text_width = len(text) * 8 + 20 text_height = DEFAULT_FONT_SIZE + 16 - return f"""{text}""" # noqa: E501 + return f"""{text}""" def _hsv_to_hex(h: int, s: int, v: int) -> str: diff --git a/gns3server/api/routes/controller/netmiko.py b/gns3server/api/routes/controller/netmiko.py index 827ac751c..44c9c9f42 100644 --- a/gns3server/api/routes/controller/netmiko.py +++ b/gns3server/api/routes/controller/netmiko.py @@ -64,7 +64,7 @@ def _load_netmiko_device_types() -> schemas.NetmikoDeviceTypeList: # imported them yet); failures are logged by the package itself, do not # fail the whole endpoint. try: - from gns3server.agent.gns3_copilot.utils import custom_netmiko # noqa: F401 + from gns3server.agent.gns3_copilot.utils import custom_netmiko except Exception as e: log.warning(f"Could not register GNS3-copilot custom Netmiko drivers: {e}")