fix(typing): resolve mypy errors in api.routes.compute.atm_switch_nodes

This commit is contained in:
Mark Paronyan 2026-09-28 05:40:13 +00:00
parent c154d1c41e
commit 8aa07a8c25
No known key found for this signature in database
GPG Key ID: 8DC7338A87FE22F8
2 changed files with 13 additions and 11 deletions

View File

@ -18,6 +18,7 @@
API routes for ATM switch nodes. API routes for ATM switch nodes.
""" """
from typing import Any
import os import os
from fastapi import APIRouter, Depends, Body, Path, status, HTTPException from fastapi import APIRouter, Depends, Body, Path, status, HTTPException
@ -29,7 +30,9 @@ from gns3server import schemas
from gns3server.compute.dynamips import Dynamips from gns3server.compute.dynamips import Dynamips
from gns3server.compute.dynamips.nodes.atm_switch import ATMSwitch from gns3server.compute.dynamips.nodes.atm_switch import ATMSwitch
responses = {404: {"model": schemas.ErrorMessage, "description": "Could not find project or ATM switch node"}} responses: dict[int | str, dict[str, Any]] = {
404: {"model": schemas.ErrorMessage, "description": "Could not find project or ATM switch node"}
}
router = APIRouter(responses=responses) router = APIRouter(responses=responses)
@ -57,13 +60,13 @@ async def create_atm_switch(project_id: UUID, node_data: schemas.ATMSwitchCreate
# Use the Dynamips ATM switch to simulate this node # Use the Dynamips ATM switch to simulate this node
dynamips_manager = Dynamips.instance() dynamips_manager = Dynamips.instance()
node_data = jsonable_encoder(node_data, exclude_unset=True) data = jsonable_encoder(node_data, exclude_unset=True)
node = await dynamips_manager.create_node( node = await dynamips_manager.create_node(
node_data.get("name"), data.get("name"),
str(project_id), str(project_id),
node_data.get("node_id"), data.get("node_id"),
node_type="atm_switch", node_type="atm_switch",
mappings=node_data.get("mappings"), mappings=data.get("mappings"),
) )
return node.asdict() return node.asdict()
@ -97,11 +100,11 @@ async def update_atm_switch(
Update an ATM switch node. Update an ATM switch node.
""" """
node_data = jsonable_encoder(node_data, exclude_unset=True) data = jsonable_encoder(node_data, exclude_unset=True)
if "name" in node_data and node.name != node_data["name"]: if "name" in data and node.name != data["name"]:
await node.set_name(node_data["name"]) await node.set_name(data["name"])
if "mappings" in node_data: if "mappings" in data:
node.mappings = node_data["mappings"] node.mappings = data["mappings"]
node.updated() node.updated()
return node.asdict() return node.asdict()

View File

@ -316,7 +316,6 @@ module = [
"gns3server.agent.web_wireshark.manage_wireshark", # 1 "gns3server.agent.web_wireshark.manage_wireshark", # 1
"gns3server.agent.web_wireshark.manager", # 9 "gns3server.agent.web_wireshark.manager", # 9
"gns3server.agent.web_wireshark.stats", # 4 "gns3server.agent.web_wireshark.stats", # 4
"gns3server.api.routes.compute.atm_switch_nodes", # 9
"gns3server.api.routes.compute.capabilities", # 1 "gns3server.api.routes.compute.capabilities", # 1
"gns3server.api.routes.compute.cloud_nodes", # 14 "gns3server.api.routes.compute.cloud_nodes", # 14
"gns3server.api.routes.compute.compute", # 1 "gns3server.api.routes.compute.compute", # 1