mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-09-30 07:40:12 +03:00
fix(typing): resolve mypy errors in services.computes
This commit is contained in:
parent
9bad1d92f8
commit
e6053dd0a8
@ -16,7 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from uuid import UUID
|
||||
from typing import Optional, List
|
||||
from typing import Optional, List, Union
|
||||
from sqlalchemy import select, update, delete
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@ -31,7 +31,7 @@ class ComputesRepository(BaseRepository):
|
||||
|
||||
super().__init__(db_session)
|
||||
|
||||
async def get_compute(self, compute_id: UUID) -> Optional[models.Compute]:
|
||||
async def get_compute(self, compute_id: Union[str, UUID]) -> Optional[models.Compute]:
|
||||
|
||||
query = select(models.Compute).where(models.Compute.compute_id == compute_id)
|
||||
result = await self._db_session.execute(query)
|
||||
@ -65,7 +65,9 @@ class ComputesRepository(BaseRepository):
|
||||
await self._db_session.refresh(db_compute)
|
||||
return db_compute
|
||||
|
||||
async def update_compute(self, compute_id: UUID, compute_update: schemas.ComputeUpdate) -> Optional[models.Compute]:
|
||||
async def update_compute(
|
||||
self, compute_id: Union[str, UUID], compute_update: schemas.ComputeUpdate
|
||||
) -> Optional[models.Compute]:
|
||||
|
||||
update_values = compute_update.model_dump(exclude_unset=True)
|
||||
if compute_update.password is not None:
|
||||
@ -80,7 +82,7 @@ class ComputesRepository(BaseRepository):
|
||||
await self._db_session.refresh(compute_db) # force refresh of updated_at value
|
||||
return compute_db
|
||||
|
||||
async def delete_compute(self, compute_id: UUID) -> bool:
|
||||
async def delete_compute(self, compute_id: Union[str, UUID]) -> bool:
|
||||
|
||||
query = delete(models.Compute).where(models.Compute.compute_id == compute_id)
|
||||
result = await self._db_session.execute(query)
|
||||
|
||||
@ -391,7 +391,6 @@ module = [
|
||||
"gns3server.schemas.controller.projects", # 2
|
||||
"gns3server.schemas.controller.settings", # 3
|
||||
"gns3server.schemas.controller.templates.docker_templates", # 1
|
||||
"gns3server.services.computes", # 4
|
||||
"gns3server.services.templates", # 18
|
||||
"gns3server.utils.asyncio.aiozipstream", # 8
|
||||
"gns3server.utils.encryption", # 2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user