mirror of
https://github.com/searxng/searxng.git
synced 2025-04-16 08:24:06 +00:00
Add typehint
This commit is contained in:
parent
b0c419f3c1
commit
f1e970e25d
1 changed files with 5 additions and 4 deletions
|
@ -3,6 +3,7 @@
|
|||
"""
|
||||
|
||||
from json import dumps, loads
|
||||
from typing import Any, Optional
|
||||
|
||||
about = {
|
||||
"website": 'https://www.senscritique.com/',
|
||||
|
@ -58,7 +59,7 @@ graphql_query = """query SearchProductExplorer($query: String, $offset: Int, $li
|
|||
}"""
|
||||
|
||||
|
||||
def request(query, params):
|
||||
def request(query: str, params: dict[str, Any]) -> dict[str, Any]:
|
||||
offset = (params['pageno'] - 1) * page_size
|
||||
|
||||
data = {
|
||||
|
@ -75,7 +76,7 @@ def request(query, params):
|
|||
return params
|
||||
|
||||
|
||||
def response(resp):
|
||||
def response(resp: Any) -> list[dict[str, Any]]:
|
||||
results = []
|
||||
response_data = loads(resp.text)
|
||||
|
||||
|
@ -89,7 +90,7 @@ def response(resp):
|
|||
return results
|
||||
|
||||
|
||||
def parse_item(item):
|
||||
def parse_item(item: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Parse a single item from the SensCritique API response"""
|
||||
title = item.get('title', '')
|
||||
year = item.get('yearOfProduction')
|
||||
|
@ -110,7 +111,7 @@ def parse_item(item):
|
|||
}
|
||||
|
||||
|
||||
def build_content_parts(item, title, original_title):
|
||||
def build_content_parts(item: dict[str, Any], title: str, original_title: Optional[str]) -> list[str]:
|
||||
"""Build the content parts for an item"""
|
||||
content_parts = []
|
||||
|
||||
|
|
Loading…
Reference in a new issue