fix(ci): fix black/ruff failures, add CoC and PR template
- Fix Python formatting (sync no longer strips blank lines from .py files) - Remove test_community_build.py (tests private sync module) - Fix ruff warnings in test files - Add CODE_OF_CONDUCT.md - Add .github/PULL_REQUEST_TEMPLATE.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ from typing import Any
|
||||
|
||||
from plugins.directus.client import DirectusClient
|
||||
|
||||
|
||||
def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
|
||||
"""Parse a parameter that may be a JSON string or already a native type."""
|
||||
if value is None:
|
||||
@@ -30,6 +31,7 @@ def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
|
||||
raise ValueError(f"Invalid JSON in '{param_name}': {e}")
|
||||
return value
|
||||
|
||||
|
||||
def get_tool_specifications() -> list[dict[str, Any]]:
|
||||
"""Return tool specifications for ToolGenerator (12 tools)"""
|
||||
return [
|
||||
@@ -267,10 +269,12 @@ def get_tool_specifications() -> list[dict[str, Any]]:
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# =====================
|
||||
# HANDLER FUNCTIONS
|
||||
# =====================
|
||||
|
||||
|
||||
async def list_roles(
|
||||
client: DirectusClient,
|
||||
filter: dict | None = None,
|
||||
@@ -291,6 +295,7 @@ async def list_roles(
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def get_role(client: DirectusClient, id: str) -> str:
|
||||
"""Get role by ID."""
|
||||
try:
|
||||
@@ -301,6 +306,7 @@ async def get_role(client: DirectusClient, id: str) -> str:
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def create_role(
|
||||
client: DirectusClient,
|
||||
name: str,
|
||||
@@ -326,6 +332,7 @@ async def create_role(
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def update_role(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
|
||||
"""Update role."""
|
||||
try:
|
||||
@@ -340,6 +347,7 @@ async def update_role(client: DirectusClient, id: str, data: dict[str, Any]) ->
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def delete_role(client: DirectusClient, id: str) -> str:
|
||||
"""Delete a role."""
|
||||
try:
|
||||
@@ -348,6 +356,7 @@ async def delete_role(client: DirectusClient, id: str) -> str:
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def list_permissions(
|
||||
client: DirectusClient, filter: dict | None = None, limit: int = 100
|
||||
) -> str:
|
||||
@@ -365,6 +374,7 @@ async def list_permissions(
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def get_permission(client: DirectusClient, id: str) -> str:
|
||||
"""Get permission by ID."""
|
||||
try:
|
||||
@@ -375,6 +385,7 @@ async def get_permission(client: DirectusClient, id: str) -> str:
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def create_permission(
|
||||
client: DirectusClient,
|
||||
collection: str,
|
||||
@@ -416,6 +427,7 @@ async def create_permission(
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def update_permission(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
|
||||
"""Update permission."""
|
||||
try:
|
||||
@@ -430,6 +442,7 @@ async def update_permission(client: DirectusClient, id: str, data: dict[str, Any
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def delete_permission(client: DirectusClient, id: str) -> str:
|
||||
"""Delete a permission."""
|
||||
try:
|
||||
@@ -438,6 +451,7 @@ async def delete_permission(client: DirectusClient, id: str) -> str:
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def get_my_permissions(client: DirectusClient) -> str:
|
||||
"""Get current user's permissions."""
|
||||
try:
|
||||
@@ -448,6 +462,7 @@ async def get_my_permissions(client: DirectusClient) -> str:
|
||||
except Exception as e:
|
||||
return json.dumps({"success": False, "error": str(e)}, indent=2)
|
||||
|
||||
|
||||
async def list_policies(
|
||||
client: DirectusClient, filter: dict | None = None, limit: int = 100
|
||||
) -> str:
|
||||
|
||||
Reference in New Issue
Block a user