Add typehint

This commit is contained in:
RobinFrcd 2025-04-12 11:09:28 +02:00
parent b0c419f3c1
commit f1e970e25d
No known key found for this signature in database
GPG key ID: 488415846ECCDBCC

View file

@ -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 = []