Skip to content

Commit 3ca1eb6

Browse files
committed
server.py: use generators where it makes sense
It's only used in cases where there is significant copying and big objects, in other cases list comprehensions are fine
1 parent e4cd702 commit 3ca1eb6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import argparse
5+
import types
56
from dotenv import load_dotenv
67
from jira import JIRA
78
from fastmcp import FastMCP
@@ -52,8 +53,8 @@ def to_markdown(obj):
5253
return '```json\n' + json.dumps(obj, indent=2) + '\n```'
5354
elif hasattr(obj, 'raw'):
5455
return '```json\n' + json.dumps(obj.raw, indent=2) + '\n```'
55-
elif isinstance(obj, list):
56-
return '\n'.join([to_markdown(o) for o in obj])
56+
elif isinstance(obj, list) or isinstance(obj, types.GeneratorType):
57+
return '\n'.join((to_markdown(o) for o in obj))
5758
else:
5859
return str(obj)
5960

@@ -79,7 +80,7 @@ def simplify_issue(issue):
7980

8081
try:
8182
issues = jira_client.search_issues(jql, maxResults=max_results)
82-
return to_markdown([simplify_issue(issue) for issue in issues])
83+
return to_markdown((simplify_issue(issue) for issue in issues))
8384
except Exception as e:
8485
raise HTTPException(status_code=400, detail=f"JQL search failed: {e}")
8586

@@ -306,7 +307,7 @@ def simplify_comment(comment):
306307
}
307308
try:
308309
issue = jira_client.issue(issue_key)
309-
return to_markdown([simplify_comment(c) for c in issue.fields.comment.comments])
310+
return to_markdown((simplify_comment(c) for c in issue.fields.comment.comments))
310311
except Exception as e:
311312
raise HTTPException(status_code=400, detail=f"Failed to get comments for {issue_key}: {e}")
312313

0 commit comments

Comments
 (0)