Add github actions CI (black, mypy, django tests)
This commit is contained in:
Ethan Roseman
2022-08-25 12:41:19 +09:00
committed by GitHub
parent 2624839689
commit 3e8b5809a0
10 changed files with 66 additions and 20 deletions

View File

@@ -2,5 +2,5 @@ from django.apps import AppConfig
class FrogApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'frog_api'
default_auto_field = "django.db.models.BigAutoField"
name = "frog_api"

View File

@@ -8,7 +8,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = []
dependencies: list[tuple[str, str]] = []
operations = [
migrations.CreateModel(

View File

@@ -1,6 +1,8 @@
from typing import Any
from rest_framework import status
from rest_framework.exceptions import APIException
from rest_framework.response import Response
from rest_framework.request import Request
from rest_framework.views import APIView
from frog_api.models import Category, Entry, Project, Version
@@ -19,7 +21,7 @@ class ProjectView(APIView):
API endpoint that allows projects to be viewed.
"""
def get(self, request, format=None):
def get(self, request: Request) -> Response:
"""
Return a list of all projects.
"""
@@ -28,11 +30,9 @@ class ProjectView(APIView):
return Response(serializer.data)
def get_latest_entry(project, version, category) -> dict:
def get_latest_entry(project: str, version: str, category: str) -> dict[Any, Any]:
if not Project.objects.filter(slug=project).exists():
raise MissingModelException(
f"Project {project} not found", code=status.HTTP_404_NOT_FOUND
)
raise MissingModelException(f"Project {project} not found")
if not Version.objects.filter(slug=version, project__slug=project).exists():
raise MissingModelException(
@@ -63,7 +63,7 @@ def get_latest_entry(project, version, category) -> dict:
return entry_data
def get_versions_digest_for_project(project) -> dict:
def get_versions_digest_for_project(project: str) -> dict[Any, Any]:
versions = {}
for version in Version.objects.filter(project__slug=project):
entry = get_latest_entry(project, version.slug, "total")
@@ -77,7 +77,7 @@ class RootDigestView(APIView):
API endpoint that returns the most recent entry for each version of each project.
"""
def get(self, request):
def get(self, request: Request) -> Response:
"""
Return the most recent entry for ovreall progress for each version of each project.
"""
@@ -96,7 +96,7 @@ class ProjectDigestView(APIView):
API endpoint that returns the most recent entry for each version of a project.
"""
def get(self, request, project):
def get(self, request: Request, project: str) -> Response:
"""
Return the most recent entry for overall progress for each version of a project.
"""
@@ -118,7 +118,7 @@ class VersionDigestView(APIView):
API endpoint that returns the most recent entry for overall progress for a version of a project.
"""
def get(self, request, project, version):
def get(self, request: Request, project: str, version: str) -> Response:
"""
Return the most recent entry for overall progress for a version of a project.
"""
@@ -133,7 +133,9 @@ class CategoryDigestView(APIView):
API endpoint that returns the most recent entry for a specific cagory and a version of a project.
"""
def get(self, request, project, version, category):
def get(
self, request: Request, project: str, version: str, category: str
) -> Response:
"""
Return the most recent entry for a specific cagory and a version of a project.
"""