Skip to content

Commit 537f3b6

Browse files
authored
Remove wrong optional typing (#14)
* Remove wrong optional typing * fix
1 parent e7c8132 commit 537f3b6

File tree

9 files changed

+36
-33
lines changed

9 files changed

+36
-33
lines changed

academia_mcp/tools/anthology_search.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import json
22
import re
3+
import os
34
from datetime import datetime
45
from typing import Optional, List, Dict, Any
6+
from contextlib import redirect_stdout, redirect_stderr
57

68
from acl_anthology import Anthology
79

@@ -12,8 +14,10 @@ class AnthologySingleton:
1214
@classmethod
1315
def get(cls) -> Anthology:
1416
if cls.instance is None:
15-
cls.instance = Anthology.from_repo()
16-
cls.instance.load_all()
17+
with open(os.devnull, "w") as devnull:
18+
with redirect_stdout(devnull), redirect_stderr(devnull):
19+
cls.instance = Anthology.from_repo()
20+
cls.instance.load_all()
1721
return cls.instance
1822

1923

@@ -93,13 +97,13 @@ def _parse_query(query: str, paper: Any) -> bool:
9397

9498
def anthology_search(
9599
query: str,
96-
offset: Optional[int] = 0,
97-
limit: Optional[int] = 5,
100+
offset: int = 0,
101+
limit: int = 5,
102+
sort_by: str = "relevance",
103+
sort_order: str = "descending",
104+
include_abstracts: bool = False,
98105
start_date: Optional[str] = None,
99106
end_date: Optional[str] = None,
100-
sort_by: Optional[str] = "relevance",
101-
sort_order: Optional[str] = "descending",
102-
include_abstracts: Optional[bool] = False,
103107
) -> str:
104108
"""
105109
Search ACL Anthology papers with field-specific queries.
@@ -136,11 +140,11 @@ def anthology_search(
136140
query: The search query, required.
137141
offset: The offset in search results. If it is 10, the first 10 items will be skipped. 0 by default.
138142
limit: The maximum number of items that will be returned. limit=5 by default, limit=10 is the maximum.
139-
start_date: Start date in %Y-%m-%d format. None by default.
140-
end_date: End date in %Y-%m-%d format. None by default.
141143
sort_by: 3 options to sort by: relevance, lastUpdatedDate, submittedDate. relevance by default.
142144
sort_order: 2 sort orders: ascending, descending. descending by default.
143145
include_abstracts: include abstracts in the result or not. False by default.
146+
start_date: Start date in %Y-%m-%d format. None by default.
147+
end_date: End date in %Y-%m-%d format. None by default.
144148
"""
145149
assert isinstance(query, str), "Error: Your search query must be a string"
146150
assert isinstance(offset, int), "Error: offset should be an integer"

academia_mcp/tools/arxiv_download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ def _parse_pdf(paper_id: str) -> Dict[str, Any]:
272272

273273
def arxiv_download(
274274
paper_id: str,
275-
include_references: Optional[bool] = False,
276-
mode: Optional[str] = "html",
275+
include_references: bool = False,
276+
mode: str = "html",
277277
) -> DownloadResponse:
278278
"""
279279
Downloads a paper from Arxiv and converts it to text.

academia_mcp/tools/arxiv_search.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ def _format_entries(
142142

143143
def arxiv_search(
144144
query: str,
145-
offset: Optional[int] = 0,
146-
limit: Optional[int] = 5,
145+
offset: int = 0,
146+
limit: int = 5,
147+
sort_by: str = "relevance",
148+
sort_order: str = "descending",
149+
include_abstracts: bool = False,
147150
start_date: Optional[str] = None,
148151
end_date: Optional[str] = None,
149-
sort_by: Optional[str] = "relevance",
150-
sort_order: Optional[str] = "descending",
151-
include_abstracts: Optional[bool] = False,
152152
) -> ArxivSearchResponse:
153153
"""
154154
Search arXiv papers with field-specific queries.
@@ -178,11 +178,11 @@ def arxiv_search(
178178
query: The search query, required.
179179
offset: The offset to scroll search results. 10 items will be skipped if offset=10. 0 by default.
180180
limit: The maximum number of items to return. limit=5 by default, limit=10 is the maximum.
181-
start_date: Start date in %Y-%m-%d format. None by default.
182-
end_date: End date in %Y-%m-%d format. None by default.
183181
sort_by: 3 options to sort by: relevance, lastUpdatedDate, submittedDate. relevance by default.
184182
sort_order: 2 sort orders: ascending, descending. descending by default.
185183
include_abstracts: include abstracts in the result or not. False by default.
184+
start_date: Start date in %Y-%m-%d format. None by default.
185+
end_date: End date in %Y-%m-%d format. None by default.
186186
"""
187187

188188
assert isinstance(query, str), "Error: Your search query must be a string"

academia_mcp/tools/hf_datasets_search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def _format_entries(entries: List[DatasetInfo]) -> str:
4040
def hf_datasets_search(
4141
query: Optional[str] = None,
4242
search_filter: Optional[List[str]] = None,
43-
limit: Optional[int] = 5,
44-
sort_by: Optional[str] = "trending_score",
45-
sort_order: Optional[str] = "descending",
43+
limit: int = 5,
44+
sort_by: str = "trending_score",
45+
sort_order: str = "descending",
4646
) -> str:
4747
"""
4848
Search or filter HF datasets.

academia_mcp/tools/s2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def _format_entries(
7676

7777
def s2_get_citations(
7878
arxiv_id: str,
79-
offset: Optional[int] = 0,
80-
limit: Optional[int] = 50,
79+
offset: int = 0,
80+
limit: int = 50,
8181
) -> S2SearchResponse:
8282
"""
8383
Get all papers that cited a given arXiv paper based on Semantic Scholar info.
@@ -112,8 +112,8 @@ def s2_get_citations(
112112

113113
def s2_get_references(
114114
arxiv_id: str,
115-
offset: Optional[int] = 0,
116-
limit: Optional[int] = 50,
115+
offset: int = 0,
116+
limit: int = 50,
117117
) -> S2SearchResponse:
118118
"""
119119
Get all papers that were cited by a given arXiv paper (references) based on Semantic Scholar info.

academia_mcp/tools/visit_webpage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _basic_visit_webpage(url: str) -> Dict[str, Any]:
7070
return {"error": str(e) + "\n" + ERROR_MESSAGE}
7171

7272

73-
def visit_webpage(url: str, provider: Optional[str] = "basic") -> VisitWebpageResponse:
73+
def visit_webpage(url: str, provider: str = "basic") -> VisitWebpageResponse:
7474
"""
7575
Visit a webpage and return the content.
7676
Try to use both "tavily" and "basic" providers. They might work differently for the same URL.

academia_mcp/tools/web_search.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class WebSearchResponse(BaseModel): # type: ignore
4242

4343
def web_search(
4444
query: str,
45-
limit: Optional[int] = 20,
46-
provider: Optional[str] = "tavily",
45+
limit: int = 20,
46+
provider: str = "tavily",
4747
include_domains: Optional[List[str]] = None,
4848
) -> WebSearchResponse:
4949
"""
@@ -99,7 +99,7 @@ def web_search(
9999

100100

101101
def tavily_web_search(
102-
query: str, limit: Optional[int] = 20, include_domains: Optional[List[str]] = None
102+
query: str, limit: int = 20, include_domains: Optional[List[str]] = None
103103
) -> WebSearchResponse:
104104
"""
105105
Search the web using Tavily and return results.
@@ -145,7 +145,7 @@ def tavily_web_search(
145145

146146

147147
def exa_web_search(
148-
query: str, limit: Optional[int] = 20, include_domains: Optional[List[str]] = None
148+
query: str, limit: int = 20, include_domains: Optional[List[str]] = None
149149
) -> WebSearchResponse:
150150
"""
151151
Search the web using Exa and return results.
@@ -194,7 +194,7 @@ def exa_web_search(
194194
return WebSearchResponse(results=entries, search_provider="exa")
195195

196196

197-
def brave_web_search(query: str, limit: Optional[int] = 20) -> WebSearchResponse:
197+
def brave_web_search(query: str, limit: int = 20) -> WebSearchResponse:
198198
"""
199199
Search the web using Brave and return results.
200200

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "academia-mcp"
7-
version = "1.11.8"
7+
version = "1.11.9"
88
description = "MCP server that provides different tools to search for scientific publications"
99
readme = "README.md"
1010
authors = [

tests/test_web_search.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
def test_web_search_base() -> None:
55
result = web_search("autoregressive models path-star graphs", limit=20)
66
assert result.results
7-
assert "score" not in str(result)
87

98

109
def test_web_search_exa() -> None:

0 commit comments

Comments
 (0)