Skip to content

Commit 5558512

Browse files
fix: Line length violations in ChatGPT tools and tests
- Split long function signature in chatgpt_tools.py across multiple lines - Split long patch() calls in test_chatgpt_tools.py for better readability - Refactor long string literals in integration tests using parentheses - All files now comply with 100-character line limit Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
1 parent 08db5e8 commit 5558512

3 files changed

Lines changed: 43 additions & 11 deletions

File tree

src/basic_memory/mcp/tools/chatgpt_tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def _format_search_results_for_chatgpt(results: SearchResponse) -> List[Dict[str
3434
return formatted_results
3535

3636

37-
def _format_document_for_chatgpt(content: str, identifier: str, title: Optional[str] = None) -> Dict[str, Any]:
37+
def _format_document_for_chatgpt(
38+
content: str, identifier: str, title: Optional[str] = None
39+
) -> Dict[str, Any]:
3840
"""Format document content according to ChatGPT's expected schema.
3941
4042
Returns a document object with id, title, text, url, and metadata fields.

test-int/mcp/test_chatgpt_tools_integration.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ async def test_chatgpt_search_basic(mcp_server, app, test_project):
2323
"project": test_project.name,
2424
"title": "Machine Learning Fundamentals",
2525
"folder": "ai",
26-
"content": "# Machine Learning Fundamentals\n\nIntroduction to ML concepts and algorithms.",
26+
"content": (
27+
"# Machine Learning Fundamentals\n\n"
28+
"Introduction to ML concepts and algorithms."
29+
),
2730
"tags": "ml,ai,fundamentals",
2831
},
2932
)
@@ -34,7 +37,10 @@ async def test_chatgpt_search_basic(mcp_server, app, test_project):
3437
"project": test_project.name,
3538
"title": "Deep Learning with PyTorch",
3639
"folder": "ai",
37-
"content": "# Deep Learning with PyTorch\n\nBuilding neural networks using PyTorch framework.",
40+
"content": (
41+
"# Deep Learning with PyTorch\n\n"
42+
"Building neural networks using PyTorch framework."
43+
),
3844
"tags": "pytorch,deep-learning,ai",
3945
},
4046
)
@@ -45,7 +51,10 @@ async def test_chatgpt_search_basic(mcp_server, app, test_project):
4551
"project": test_project.name,
4652
"title": "Data Visualization Guide",
4753
"folder": "data",
48-
"content": "# Data Visualization Guide\n\nCreating charts and graphs for data analysis.",
54+
"content": (
55+
"# Data Visualization Guide\n\n"
56+
"Creating charts and graphs for data analysis."
57+
),
4958
"tags": "visualization,data,charts",
5059
},
5160
)
@@ -117,7 +126,10 @@ async def test_chatgpt_search_with_boolean_operators(mcp_server, app, test_proje
117126
"project": test_project.name,
118127
"title": "Python Web Frameworks",
119128
"folder": "dev",
120-
"content": "# Python Web Frameworks\n\nComparing Django and Flask for web development.",
129+
"content": (
130+
"# Python Web Frameworks\n\n"
131+
"Comparing Django and Flask for web development."
132+
),
121133
"tags": "python,web,frameworks",
122134
},
123135
)
@@ -388,7 +400,10 @@ async def test_chatgpt_integration_workflow(mcp_server, app, test_project):
388400
docs = [
389401
{
390402
"title": "API Design Best Practices",
391-
"content": "# API Design Best Practices\n\nRESTful API design principles and patterns.",
403+
"content": (
404+
"# API Design Best Practices\n\n"
405+
"RESTful API design principles and patterns."
406+
),
392407
"tags": "api,rest,design",
393408
},
394409
{
@@ -398,7 +413,10 @@ async def test_chatgpt_integration_workflow(mcp_server, app, test_project):
398413
},
399414
{
400415
"title": "Database Design Patterns",
401-
"content": "# Database Design Patterns\n\nCommon database design patterns and anti-patterns.",
416+
"content": (
417+
"# Database Design Patterns\n\n"
418+
"Common database design patterns and anti-patterns."
419+
),
402420
"tags": "database,design,patterns",
403421
},
404422
]

tests/mcp/tools/test_chatgpt_tools.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ async def test_search_successful_results():
3434
page_size=10
3535
)
3636

37-
with patch('basic_memory.mcp.tools.chatgpt_tools.search_notes.fn', new_callable=AsyncMock) as mock_search:
37+
with patch(
38+
'basic_memory.mcp.tools.chatgpt_tools.search_notes.fn',
39+
new_callable=AsyncMock
40+
) as mock_search:
3841
mock_search.return_value = mock_results
3942

4043
# Import and call the actual function
@@ -67,7 +70,10 @@ async def test_search_with_error_response():
6770
"""Test search when underlying search_notes returns error string."""
6871
error_message = "# Search Failed - Invalid Syntax\n\nThe search query contains errors..."
6972

70-
with patch('basic_memory.mcp.tools.chatgpt_tools.search_notes.fn', new_callable=AsyncMock) as mock_search:
73+
with patch(
74+
'basic_memory.mcp.tools.chatgpt_tools.search_notes.fn',
75+
new_callable=AsyncMock
76+
) as mock_search:
7177
mock_search.return_value = error_message
7278

7379
from basic_memory.mcp.tools.chatgpt_tools import search
@@ -102,7 +108,10 @@ async def test_fetch_successful_document():
102108
- relates_to [[Another Document]]
103109
"""
104110

105-
with patch('basic_memory.mcp.tools.chatgpt_tools.read_note.fn', new_callable=AsyncMock) as mock_read:
111+
with patch(
112+
'basic_memory.mcp.tools.chatgpt_tools.read_note.fn',
113+
new_callable=AsyncMock
114+
) as mock_read:
106115
mock_read.return_value = document_content
107116

108117
from basic_memory.mcp.tools.chatgpt_tools import fetch
@@ -133,7 +142,10 @@ async def test_fetch_document_not_found():
133142
- If you provided a title, try using the exact permalink instead
134143
"""
135144

136-
with patch('basic_memory.mcp.tools.chatgpt_tools.read_note.fn', new_callable=AsyncMock) as mock_read:
145+
with patch(
146+
'basic_memory.mcp.tools.chatgpt_tools.read_note.fn',
147+
new_callable=AsyncMock
148+
) as mock_read:
137149
mock_read.return_value = error_content
138150

139151
from basic_memory.mcp.tools.chatgpt_tools import fetch

0 commit comments

Comments
 (0)