style: fix all ruff lint errors (E501, E722, E741, F841)

- Break long lines (E501) across 25+ files
- Replace bare except with except Exception (E722)
- Rename ambiguous variable `l` to `item` (E741)
- Prefix unused variables with underscore (F841)
This commit is contained in:
Timothy
2026-03-03 20:42:30 -08:00
parent b4cf10214b
commit 8018325923
32 changed files with 133 additions and 54 deletions
+2 -2
View File
@@ -83,7 +83,7 @@ def grant_permissions():
CREATE LOGIN sa WITH PASSWORD = '{PASSWORD}'
END
""")
except:
except Exception:
pass
# Switch to AdenTestDB and grant permissions
@@ -98,7 +98,7 @@ def grant_permissions():
END
""")
print("[OK] Created database user")
except:
except Exception:
pass
# Grant permissions
+2 -3
View File
@@ -89,9 +89,8 @@ def main():
# Highlight the department with the highest average
if avg_salary == highest_avg:
# Use special formatting for the highest
print(
f"{'>>> ' + str(idx):<6} {department:<25} {avg_salary_str:<20} {emp_count:<12} ⭐ HIGHEST"
)
prefix = f"{'>>> ' + str(idx):<6}"
print(f"{prefix} {department:<25} {avg_salary_str:<20} {emp_count:<12} ⭐ HIGHEST")
else:
print(f"{idx:<6} {department:<25} {avg_salary_str:<20} {emp_count:<12}")
@@ -18,7 +18,9 @@ DOCKER_HUB_CREDENTIALS = {
required=True,
startup_required=False,
help_url="https://hub.docker.com/settings/security",
description="Docker Hub personal access token (also set DOCKER_HUB_USERNAME for listing own repos)",
description=(
"Docker Hub personal access token (also set DOCKER_HUB_USERNAME for listing own repos)"
),
direct_api_key_supported=True,
api_key_instructions="""To get a Docker Hub personal access token:
1. Go to https://hub.docker.com/settings/security
@@ -24,7 +24,9 @@ PIPEDRIVE_CREDENTIALS = {
required=True,
startup_required=False,
help_url="https://pipedrive.readme.io/docs/core-api-concepts-about-pipedrive-api",
description="Pipedrive API token for CRM management (also set PIPEDRIVE_DOMAIN for custom domains)",
description=(
"Pipedrive API token for CRM management (also set PIPEDRIVE_DOMAIN for custom domains)"
),
direct_api_key_supported=True,
api_key_instructions="""To get a Pipedrive API token:
1. Log in to your Pipedrive account
+4 -1
View File
@@ -21,7 +21,10 @@ PLAID_CREDENTIALS = {
required=True,
startup_required=False,
help_url="https://dashboard.plaid.com/developers/keys",
description="Plaid client ID for banking data access (also set PLAID_SECRET and optionally PLAID_ENV)",
description=(
"Plaid client ID for banking data access"
" (also set PLAID_SECRET and optionally PLAID_ENV)"
),
direct_api_key_supported=True,
api_key_instructions="""To get Plaid credentials:
1. Sign up at https://dashboard.plaid.com/
@@ -159,7 +159,8 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
Args:
base_id: The Airtable base ID (starts with 'app').
table_name: Table name or ID.
records: JSON array of objects with "fields" key, e.g. '[{"fields": {"Name": "Alice"}}]'.
records: JSON array of objects with "fields" key,
e.g. '[{"fields": {"Name": "Alice"}}]'.
typecast: If true, auto-convert values to appropriate field types.
"""
hdrs = _get_headers()
@@ -212,7 +213,8 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
Args:
base_id: The Airtable base ID (starts with 'app').
table_name: Table name or ID.
records: JSON array of objects with "id" and "fields" keys, e.g. '[{"id": "recXXX", "fields": {"Status": "Done"}}]'.
records: JSON array of objects with "id" and "fields" keys,
e.g. '[{"id": "recXXX", "fields": {"Status": "Done"}}]'.
typecast: If true, auto-convert values to appropriate field types.
"""
hdrs = _get_headers()
@@ -218,7 +218,10 @@ def register_tools(
return {"error": "task_gid is required"}
params = {
"opt_fields": "name,notes,completed,due_on,assignee.name,projects.name,tags.name,created_at,modified_at"
"opt_fields": (
"name,notes,completed,due_on,assignee.name,"
"projects.name,tags.name,created_at,modified_at"
)
}
data = _get(f"tasks/{task_gid}", token, params)
if "error" in data:
@@ -295,7 +295,8 @@ def register_tools(
api_key = credentials.get("attio")
if api_key is not None and not isinstance(api_key, str):
raise TypeError(
f"Expected string from credentials.get('attio'), got {type(api_key).__name__}"
"Expected string from credentials.get('attio'), "
f"got {type(api_key).__name__}"
)
if api_key is not None:
return api_key
@@ -121,7 +121,7 @@ class TestAttioClient:
mock_request.return_value = mock_response
params = {"matching_attribute": "email_addresses"}
result = self.client._request("PUT", "/objects/people/records", json_body={}, params=params)
self.client._request("PUT", "/objects/people/records", json_body={}, params=params)
call_kwargs = mock_request.call_args.kwargs
assert call_kwargs["params"] == params
@@ -283,7 +283,7 @@ class TestAttioClient:
mock_request.return_value = mock_response
entry_values = {"stage": "qualified"}
result = self.client.create_entry("list-1", "rec-123", entry_values=entry_values)
_result = self.client.create_entry("list-1", "rec-123", entry_values=entry_values)
call_kwargs = mock_request.call_args.kwargs
body = call_kwargs["json"]
@@ -89,7 +89,11 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
headers, sub_id = cfg
if resource_group:
url = f"{BASE_URL}/subscriptions/{sub_id}/resourceGroups/{resource_group}/providers/Microsoft.Sql/servers"
url = (
f"{BASE_URL}/subscriptions/{sub_id}"
f"/resourceGroups/{resource_group}"
"/providers/Microsoft.Sql/servers"
)
else:
url = f"{BASE_URL}/subscriptions/{sub_id}/providers/Microsoft.Sql/servers"
@@ -118,7 +122,11 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
if not resource_group or not server_name:
return {"error": "resource_group and server_name are required"}
url = f"{BASE_URL}/subscriptions/{sub_id}/resourceGroups/{resource_group}/providers/Microsoft.Sql/servers/{server_name}"
url = (
f"{BASE_URL}/subscriptions/{sub_id}"
f"/resourceGroups/{resource_group}"
f"/providers/Microsoft.Sql/servers/{server_name}"
)
data = _get(url, headers)
if "error" in data:
return data
@@ -140,7 +148,11 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
if not resource_group or not server_name:
return {"error": "resource_group and server_name are required"}
url = f"{BASE_URL}/subscriptions/{sub_id}/resourceGroups/{resource_group}/providers/Microsoft.Sql/servers/{server_name}/databases"
url = (
f"{BASE_URL}/subscriptions/{sub_id}"
f"/resourceGroups/{resource_group}"
f"/providers/Microsoft.Sql/servers/{server_name}/databases"
)
data = _get(url, headers)
if "error" in data:
return data
@@ -167,7 +179,12 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
if not resource_group or not server_name or not database_name:
return {"error": "resource_group, server_name, and database_name are required"}
url = f"{BASE_URL}/subscriptions/{sub_id}/resourceGroups/{resource_group}/providers/Microsoft.Sql/servers/{server_name}/databases/{database_name}"
url = (
f"{BASE_URL}/subscriptions/{sub_id}"
f"/resourceGroups/{resource_group}"
f"/providers/Microsoft.Sql/servers/{server_name}"
f"/databases/{database_name}"
)
data = _get(url, headers)
if "error" in data:
return data
@@ -189,7 +206,12 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
if not resource_group or not server_name:
return {"error": "resource_group and server_name are required"}
url = f"{BASE_URL}/subscriptions/{sub_id}/resourceGroups/{resource_group}/providers/Microsoft.Sql/servers/{server_name}/firewallRules"
url = (
f"{BASE_URL}/subscriptions/{sub_id}"
f"/resourceGroups/{resource_group}"
f"/providers/Microsoft.Sql/servers/{server_name}"
"/firewallRules"
)
data = _get(url, headers)
if "error" in data:
return data
@@ -75,7 +75,10 @@ def _post(host: str, endpoint: str, token: str, body: dict | None = None) -> dic
def _auth_error() -> dict[str, Any]:
return {
"error": "DATABRICKS_TOKEN or DATABRICKS_HOST not set",
"help": "Set DATABRICKS_HOST=https://your-workspace.cloud.databricks.com and DATABRICKS_TOKEN=dapi...",
"help": (
"Set DATABRICKS_HOST=https://your-workspace.cloud.databricks.com"
" and DATABRICKS_TOKEN=dapi..."
),
}
@@ -181,7 +181,8 @@ def register_tools(
site_url: Site URL (e.g. "https://example.com")
Returns:
Dict with sitemaps list (path, lastSubmitted, isPending, isSitemapsIndex, warnings, errors)
Dict with sitemaps list
(path, lastSubmitted, isPending, isSitemapsIndex, warnings, errors)
"""
token = _get_token(credentials)
if not token:
@@ -130,7 +130,8 @@ def register_tools(
Args:
spreadsheet_id: The spreadsheet ID from the URL (required)
range: A1 notation range e.g. "Sheet1!A1:D10" or "Sheet1" (required)
value_render: How values are rendered: FORMATTED_VALUE, UNFORMATTED_VALUE, FORMULA (default FORMATTED_VALUE)
value_render: How values are rendered: FORMATTED_VALUE,
UNFORMATTED_VALUE, or FORMULA (default FORMATTED_VALUE)
Returns:
Dict with cell values as 2D array, range info, and row/column counts
@@ -64,7 +64,9 @@ def _get(path: str, token: str, params: dict[str, Any] | None = None) -> dict[st
def _auth_error() -> dict[str, Any]:
return {
"error": "GREENHOUSE_API_TOKEN not set",
"help": "Get your API key from Greenhouse: Configure > Dev Center > API Credential Management",
"help": (
"Get your API key from Greenhouse: Configure > Dev Center > API Credential Management"
),
}
@@ -255,7 +255,7 @@ def register_tools(
if priority:
fields["priority"] = {"name": priority}
if labels:
fields["labels"] = [l.strip() for l in labels.split(",") if l.strip()]
fields["labels"] = [item.strip() for item in labels.split(",") if item.strip()]
url = f"{_base_url(domain)}/issue"
data = _request("post", url, email, token, json={"fields": fields})
@@ -703,7 +703,8 @@ def register_tools(
# Defensive check: ensure we get a string, not a complex object
if api_key is not None and not isinstance(api_key, str):
raise TypeError(
f"Expected string from credentials.get('linear'), got {type(api_key).__name__}"
"Expected string from credentials.get('linear'), "
f"got {type(api_key).__name__}"
)
if api_key is not None:
return api_key
@@ -102,7 +102,7 @@ class TestLinearClient:
}
mock_post.return_value = mock_response
result = self.client._execute_query(
_result = self.client._execute_query(
"query Issue($id: String!) { issue(id: $id) { id title } }",
{"id": "issue-123"},
)
@@ -289,7 +289,8 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
Args:
database: Database name.
collection: Collection name.
pipeline: JSON array of pipeline stages (e.g. '[{"$match": {"status": "active"}}, {"$group": {"_id": "$type", "count": {"$sum": 1}}}]').
pipeline: JSON array of pipeline stages
(e.g. '[{"$match": {"status": "active"}}]').
"""
cfg = _get_config()
if isinstance(cfg, dict):
@@ -141,7 +141,9 @@ def register_tools(
query_upper = query.strip().upper()
if not query_upper.startswith("SELECT") and not query_upper.startswith("WITH"):
return {
"error": "Only SELECT queries are allowed. Use mssql_execute_update for modifications."
"error": (
"Only SELECT queries are allowed. Use mssql_execute_update for modifications."
)
}
connection, error = _create_connection()
@@ -414,7 +416,9 @@ def register_tools(
i.type_desc AS INDEX_TYPE,
COL_NAME(ic.object_id, ic.column_id) AS COLUMN_NAME
FROM sys.indexes i
JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
JOIN sys.index_columns ic
ON i.object_id = ic.object_id
AND i.index_id = ic.index_id
WHERE i.object_id = OBJECT_ID(?)
ORDER BY i.name, ic.key_ordinal
""",
@@ -212,7 +212,9 @@ def register_tools(
Args:
parent_database_id: ID of the parent database (required)
title: Page title (required)
properties_json: Additional properties as JSON string e.g. '{"Status": {"select": {"name": "Done"}}}' (optional)
properties_json: Additional properties as JSON string
e.g. '{"Status": {"select": {"name": "Done"}}}'
(optional)
content: Plain text content for the page body (optional)
Returns:
@@ -87,7 +87,8 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
"""List PagerDuty incidents with optional filters.
Args:
status: Filter by status: 'triggered', 'acknowledged', 'resolved'. Comma-separated for multiple.
status: Filter by status: 'triggered', 'acknowledged',
'resolved'. Comma-separated for multiple.
since: Start of date range (ISO 8601, e.g. '2024-01-01T00:00:00Z').
until: End of date range (ISO 8601).
service_id: Filter by service ID.
@@ -138,7 +138,8 @@ def register_tools(
start: Pagination offset (default 0)
Returns:
Dict with deals list (id, title, value, currency, status, person_name, org_name, stage_id)
Dict with deals list (id, title, value, currency,
status, person_name, org_name, stage_id)
"""
token = _get_token(credentials)
if not token:
@@ -34,7 +34,7 @@ class TestPushoverClient:
@patch("aden_tools.tools.pushover_tool.pushover_tool.httpx.post")
def test_send_notification_emergency_priority(self, mock_post):
mock_post.return_value = self._mock_response()
result = self.client.send_notification("Emergency!", priority=2)
_result = self.client.send_notification("Emergency!", priority=2)
call_kwargs = mock_post.call_args[1]["data"]
assert call_kwargs["retry"] == 30
assert call_kwargs["expire"] == 3600
@@ -86,7 +86,7 @@ class TestPushoverClient:
@patch("aden_tools.tools.pushover_tool.pushover_tool.httpx.post")
def test_validate_user_with_device(self, mock_post):
mock_post.return_value = self._mock_response(json_data={"status": 1, "devices": ["iphone"]})
result = self.client.validate_user(device="iphone")
_result = self.client.validate_user(device="iphone")
call_kwargs = mock_post.call_args[1]["data"]
assert call_kwargs["device"] == "iphone"
@@ -69,7 +69,8 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
"""Query QuickBooks entities using the query API.
Args:
entity: Entity type to query (e.g. 'Customer', 'Invoice', 'Item', 'Vendor', 'Bill', 'Payment').
entity: Entity type to query (e.g. 'Customer', 'Invoice',
'Item', 'Vendor', 'Bill', 'Payment').
where: Optional WHERE clause (e.g. "Active = true AND DisplayName LIKE 'ABC%'").
order_by: Optional ORDER BY clause (e.g. "DisplayName ASC").
max_results: Maximum results to return (default 100, max 1000).
@@ -175,7 +176,9 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
Args:
customer_id: Customer ID to invoice.
line_items: JSON array of line items. Each item: {"description": "...", "amount": 100.00, "item_id": "1"}.
line_items: JSON array of line items. Each item:
{"description": "...", "amount": 100.00,
"item_id": "1"}.
"""
cfg = _get_config()
if isinstance(cfg, dict):
@@ -232,11 +232,11 @@ def register_tools(mcp: FastMCP, credentials: Any = None) -> None:
"count": len(logs),
"logs": [
{
"id": l.get("id"),
"level": l.get("level"),
"message": l.get("message"),
"created_at": l.get("created_at"),
"id": item.get("id"),
"level": item.get("level"),
"message": item.get("message"),
"created_at": item.get("created_at"),
}
for l in logs
for item in logs
],
}
@@ -141,8 +141,11 @@ def register_tools(
Send a WhatsApp message via Twilio.
Args:
to: Recipient phone in E.164 format e.g. "+14155552671" (required, whatsapp: prefix added automatically)
from_number: Sender Twilio WhatsApp number in E.164 format (required, whatsapp: prefix added automatically)
to: Recipient phone in E.164 format e.g. "+14155552671"
(required, whatsapp: prefix added automatically)
from_number: Sender Twilio WhatsApp number in E.164
format (required, whatsapp: prefix added
automatically)
body: Message text (required)
Returns:
@@ -46,7 +46,11 @@ def _request(
reason = errors[0].get("reason", "")
if reason == "quotaExceeded":
return {
"error": "YouTube API quota exceeded. Try again tomorrow or request a quota increase."
"error": (
"YouTube API quota exceeded."
" Try again tomorrow or"
" request a quota increase."
)
}
return {"error": f"Forbidden: {reason or resp.text}"}
if resp.status_code != 200:
@@ -112,7 +116,9 @@ def register_tools(
video_type: Filter by type - episode, movie, or empty for any
Returns:
Dict with query, results list (title, videoId, channelTitle, publishedAt, description, thumbnail), and total_results count
Dict with query, results list (title, videoId,
channelTitle, publishedAt, description,
thumbnail), and total_results count
"""
api_key = _get_api_key(credentials)
if not api_key:
@@ -299,7 +305,8 @@ def register_tools(
order: Sort order - date, viewCount, rating, relevance (default date)
Returns:
Dict with channel_id and videos list (videoId, title, publishedAt, description, thumbnail)
Dict with channel_id and videos list (videoId, title,
publishedAt, description, thumbnail)
"""
api_key = _get_api_key(credentials)
if not api_key:
@@ -45,7 +45,10 @@ def register_tools(
from youtube_transcript_api import YouTubeTranscriptApi
except ImportError:
return {
"error": "youtube-transcript-api package not installed. Run: pip install youtube-transcript-api"
"error": (
"youtube-transcript-api package not installed."
" Run: pip install youtube-transcript-api"
)
}
try:
@@ -88,7 +91,10 @@ def register_tools(
from youtube_transcript_api import YouTubeTranscriptApi
except ImportError:
return {
"error": "youtube-transcript-api package not installed. Run: pip install youtube-transcript-api"
"error": (
"youtube-transcript-api package not installed."
" Run: pip install youtube-transcript-api"
)
}
try:
@@ -241,7 +241,9 @@ def register_tools(
return {"error": "module is required"}
if not (criteria or email or phone or word):
return {
"error": "At least one search parameter is required (criteria, email, phone, or word)"
"error": (
"At least one search parameter is required (criteria, email, phone, or word)"
)
}
params: dict[str, Any] = {
+4 -2
View File
@@ -121,7 +121,9 @@ class TestAttioClient:
mock_request.return_value = mock_response
params = {"matching_attribute": "email_addresses"}
result = self.client._request("PUT", "/objects/people/records", json_body={}, params=params)
_result = self.client._request(
"PUT", "/objects/people/records", json_body={}, params=params
)
call_kwargs = mock_request.call_args.kwargs
assert call_kwargs["params"] == params
@@ -283,7 +285,7 @@ class TestAttioClient:
mock_request.return_value = mock_response
entry_values = {"stage": "qualified"}
result = self.client.create_entry("list-1", "rec-123", entry_values=entry_values)
_result = self.client.create_entry("list-1", "rec-123", entry_values=entry_values)
call_kwargs = mock_request.call_args.kwargs
body = call_kwargs["json"]
+7 -2
View File
@@ -38,7 +38,10 @@ class TestAzureSQLListServers:
data = {
"value": [
{
"id": "/subscriptions/sub-123/resourceGroups/rg/providers/Microsoft.Sql/servers/myserver",
"id": (
"/subscriptions/sub-123/resourceGroups/rg"
"/providers/Microsoft.Sql/servers/myserver"
),
"name": "myserver",
"location": "eastus",
"properties": {
@@ -72,7 +75,9 @@ class TestAzureSQLGetServer:
def test_successful_get(self, tool_fns):
data = {
"id": "/subscriptions/sub-123/resourceGroups/rg/providers/Microsoft.Sql/servers/myserver",
"id": (
"/subscriptions/sub-123/resourceGroups/rg/providers/Microsoft.Sql/servers/myserver"
),
"name": "myserver",
"location": "eastus",
"properties": {
+1 -1
View File
@@ -102,7 +102,7 @@ class TestLinearClient:
}
mock_post.return_value = mock_response
result = self.client._execute_query(
_result = self.client._execute_query(
"query Issue($id: String!) { issue(id: $id) { id title } }",
{"id": "issue-123"},
)