chore: fix all ruff lint errors + format — 0 errors, 306 tests pass
This commit is contained in:
@@ -9,8 +9,8 @@ from typing import Any
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.audit import log_audit
|
||||
from app.plugins.registry import PluginRegistry, get_registry
|
||||
from app.plugins.migration_runner import MigrationValidationError
|
||||
from app.plugins.registry import PluginRegistry, get_registry
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -48,7 +48,9 @@ class PluginService:
|
||||
record = await self._registry.install(db, name)
|
||||
if tenant_id and user_id:
|
||||
await log_audit(
|
||||
db, tenant_id, user_id,
|
||||
db,
|
||||
tenant_id,
|
||||
user_id,
|
||||
action="plugin.install",
|
||||
entity_type="plugin",
|
||||
entity_id=getattr(record, "id", None),
|
||||
@@ -64,9 +66,9 @@ class PluginService:
|
||||
"message": "Plugin installed successfully",
|
||||
}
|
||||
except ValueError as exc:
|
||||
raise ValueError(str(exc))
|
||||
raise ValueError(str(exc)) from None
|
||||
except MigrationValidationError as exc:
|
||||
raise MigrationValidationError(str(exc))
|
||||
raise MigrationValidationError(str(exc)) from None
|
||||
|
||||
async def activate_plugin(
|
||||
self,
|
||||
@@ -84,7 +86,9 @@ class PluginService:
|
||||
was_already_active = record.active and record.status == "active"
|
||||
if tenant_id and user_id:
|
||||
await log_audit(
|
||||
db, tenant_id, user_id,
|
||||
db,
|
||||
tenant_id,
|
||||
user_id,
|
||||
action="plugin.activate",
|
||||
entity_type="plugin",
|
||||
entity_id=getattr(record, "id", None),
|
||||
@@ -97,10 +101,12 @@ class PluginService:
|
||||
"status": record.status,
|
||||
"installed": record.installed,
|
||||
"active": record.active,
|
||||
"message": "Plugin is already active" if was_already_active else "Plugin activated successfully",
|
||||
"message": "Plugin is already active"
|
||||
if was_already_active
|
||||
else "Plugin activated successfully",
|
||||
}
|
||||
except ValueError as exc:
|
||||
raise ValueError(str(exc))
|
||||
raise ValueError(str(exc)) from None
|
||||
|
||||
async def deactivate_plugin(
|
||||
self,
|
||||
@@ -118,7 +124,9 @@ class PluginService:
|
||||
was_already_inactive = not record.active and record.status == "inactive"
|
||||
if tenant_id and user_id:
|
||||
await log_audit(
|
||||
db, tenant_id, user_id,
|
||||
db,
|
||||
tenant_id,
|
||||
user_id,
|
||||
action="plugin.deactivate",
|
||||
entity_type="plugin",
|
||||
entity_id=getattr(record, "id", None),
|
||||
@@ -131,10 +139,12 @@ class PluginService:
|
||||
"status": record.status,
|
||||
"installed": record.installed,
|
||||
"active": record.active,
|
||||
"message": "Plugin is already inactive" if was_already_inactive else "Plugin deactivated successfully",
|
||||
"message": "Plugin is already inactive"
|
||||
if was_already_inactive
|
||||
else "Plugin deactivated successfully",
|
||||
}
|
||||
except ValueError as exc:
|
||||
raise ValueError(str(exc))
|
||||
raise ValueError(str(exc)) from None
|
||||
|
||||
async def uninstall_plugin(
|
||||
self,
|
||||
@@ -153,10 +163,16 @@ class PluginService:
|
||||
dropped_tables = getattr(record, "dropped_tables", [])
|
||||
if tenant_id and user_id:
|
||||
await log_audit(
|
||||
db, tenant_id, user_id,
|
||||
db,
|
||||
tenant_id,
|
||||
user_id,
|
||||
action="plugin.uninstall",
|
||||
entity_type="plugin",
|
||||
changes={"name": name, "remove_data": remove_data, "dropped_tables": dropped_tables},
|
||||
changes={
|
||||
"name": name,
|
||||
"remove_data": remove_data,
|
||||
"dropped_tables": dropped_tables,
|
||||
},
|
||||
)
|
||||
return {
|
||||
"name": name,
|
||||
@@ -169,11 +185,12 @@ class PluginService:
|
||||
"message": f"Plugin uninstalled{' and data tables dropped' if remove_data else ''}",
|
||||
}
|
||||
except ValueError as exc:
|
||||
raise ValueError(str(exc))
|
||||
raise ValueError(str(exc)) from None
|
||||
|
||||
def get_manifest_schema(self) -> dict[str, Any]:
|
||||
"""Return the manifest schema documentation."""
|
||||
from app.plugins.manifest import MANIFEST_SCHEMA_DOC
|
||||
|
||||
return MANIFEST_SCHEMA_DOC.model_dump()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user