diff --git a/api/__init__.py b/api/__init__.py index 514e262..cd544c0 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -5,7 +5,7 @@ import pkgutil from api.utils.versioning import get_version # Dynamically import all modules in the 'api' package, excluding subdirectories -versioned_blueprints = {} +versioned_blueprints: dict[str, list] = {} for finder, module_name, ispkg in pkgutil.iter_modules(["api"]): if not ispkg: # Import the module diff --git a/api/backends/entities.py b/api/backends/entities.py index a47129e..eee84ea 100644 --- a/api/backends/entities.py +++ b/api/backends/entities.py @@ -102,13 +102,14 @@ class Contributor(dict): html_url: str, contributions: Optional[int] = None, bio: Optional[str] = None, + keys: Optional[str] = None, ): - match contributions, bio: - case None, None: + match contributions, bio, keys: + case None, None, None: dict.__init__( - self, login=login, avatar_url=avatar_url, html_url=html_url, bio=bio + self, login=login, avatar_url=avatar_url, html_url=html_url, bio=bio, keys=keys ) - case int(_), None: + case int(_), None, None: dict.__init__( self, login=login, @@ -116,7 +117,7 @@ class Contributor(dict): html_url=html_url, contributions=contributions, ) - case None, str(_): + case None, str(_), None: dict.__init__( self, login=login, @@ -124,7 +125,7 @@ class Contributor(dict): html_url=html_url, bio=bio, ) - case int(_), str(_): + case int(_), str(_), str(_): dict.__init__( self, login=login, @@ -132,6 +133,16 @@ class Contributor(dict): html_url=html_url, contributions=contributions, bio=bio, + keys=keys, + ) + case None, str(_), str(_): + dict.__init__( + self, + login=login, + avatar_url=avatar_url, + html_url=html_url, + bio=bio, + keys=keys, ) case _: raise ValueError("Invalid arguments") diff --git a/api/backends/github.py b/api/backends/github.py index 08ee8df..f4b0750 100644 --- a/api/backends/github.py +++ b/api/backends/github.py @@ -1,7 +1,7 @@ import asyncio import os from operator import eq -from typing import Optional +from typing import Any, Optional import ujson from aiohttp import ClientResponse @@ -107,6 +107,11 @@ class Github(Backend): contributor, ) + if team_view: + filter_contributor[ + "keys" + ] = f"{base_url.replace('api.', '')}/{filter_contributor['login']}.gpg" + return Contributor(**filter_contributor) @staticmethod @@ -372,7 +377,7 @@ class Github(Backend): list[dict[str, str]]: A JSON object containing the contributors. """ - def transform(data: dict, repository: GithubRepository) -> list: + def transform(data: dict, repository: GithubRepository) -> dict[str, Any]: """Transforms a dictionary from the input list into a list of dictionaries with the desired structure. Args: diff --git a/api/ping.py b/api/ping.py index 125365c..09bce09 100644 --- a/api/ping.py +++ b/api/ping.py @@ -2,17 +2,17 @@ This module provides endpoints for pinging the API. Routes: - - HEAD /ping: Ping the API. + - GET /ping: Ping the API. """ import os from sanic import Blueprint, HTTPResponse, Request, response from sanic_ext import openapi -ping: Blueprint = Blueprint(os.path.basename(__file__).strip(".py")) +ping: Blueprint = Blueprint(os.path.basename(__file__).rstrip(".py")) -@ping.head("/ping") +@ping.get("/ping") @openapi.summary("Ping the API") async def root(request: Request) -> HTTPResponse: """ diff --git a/config.py b/config.py index d430b9e..aee8610 100644 --- a/config.py +++ b/config.py @@ -1,5 +1,8 @@ # API Configuration +from typing import Any + + backend: str = "github" redis: dict[str, str | int] = {"host": "localhost", "port": 6379} hostnames: list[str] = [ @@ -137,7 +140,7 @@ links: list[dict[str, str | bool]] = [ }, ] -default_info: dict[str, str | list[str | bool] | bool] = { +default_info: dict[str, Any] = { "name": "ReVanced", "about": "ReVanced was born out of Vanced's discontinuation and it is our goal to continue the legacy of what Vanced left behind. Thanks to ReVanced Patcher, it's possible to create long-lasting patches for nearly any Android app. ReVanced's patching system is designed to allow patches to work on new versions of the apps automatically with bare minimum maintenance.", "branding": { diff --git a/mypy.ini b/mypy.ini index 408c241..9009c16 100644 --- a/mypy.ini +++ b/mypy.ini @@ -22,3 +22,9 @@ ignore_missing_imports = True [mypy-sanic_testing.*] ignore_missing_imports = True + +[mypy-fire.*] +ignore_missing_imports = True + +[mypy-cytoolz.*] +ignore_missing_imports = True