refactor: ruff autofixes

This commit is contained in:
Mark Paronyan committed 2026-09-27 15:55:10 +03:00
1 parent 2ac637c662
commit a0450b6bce
455 files changed
+12322 -14762

No files matched your search

+7 -9
View File
@@ -158,11 +158,11 @@ BUILTIN_TEMPLATES = [
class TemplatesService:
def __init__(self, templates_repo: TemplatesRepository):
self._templates_repo = templates_repo
from gns3server.controller import Controller
self._controller = Controller.instance()
# resolve built-in template symbols
@@ -233,8 +233,10 @@ class TemplatesService:
if await self._templates_repo.get_template_by_name_and_version(template_create.name, template_create.version):
if template_create.version:
raise ControllerError(f"A template with name '{template_create.name}' and "
f"version {template_create.version} already exists")
raise ControllerError(
f"A template with name '{template_create.name}' and "
f"version {template_create.version} already exists"
)
else:
raise ControllerError(f"A template with name '{template_create.name}' already exists")
@@ -364,11 +366,7 @@ class TemplatesService:
if not os.path.exists(path):
return []
return [
{"filename": f}
for f in sorted(os.listdir(path))
if os.path.isfile(os.path.join(path, f))
]
return [{"filename": f} for f in sorted(os.listdir(path)) if os.path.isfile(os.path.join(path, f))]
def get_file(self, template_id: str, filename: str):
safe_filename = os.path.basename(filename)
@@ -395,4 +393,4 @@ class TemplatesService:
with open(path, "w", encoding="utf-8") as f:
f.write(content)
except OSError as e:
raise ControllerError(str(e))
raise ControllerError(str(e))