-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* make mypy config stricter * Update mypy.ini * Update uv.lock * break down Makefile * bump backend qa tool versions
- Loading branch information
1 parent
403308f
commit 34741b3
Showing
7 changed files
with
222 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
SERVER_DIR=./server | ||
|
||
# Backend tool commands | ||
RUFF=ruff | ||
MYPY=mypy | ||
PYTEST=pytest chatgptserver --verbose | ||
PYCOVERAGE=coverage run -m pytest chatgptserver && coverage report --fail-under=95 && coverage html | ||
DJANGO_RUNSERVER=chatgptserver/manage.py runserver | ||
OPENAPI_SCHEMA=chatgptserver/manage.py spectacular --color --validate --file schema.yml | ||
LOCUST=locust -H http://127.0.0.1:8000/ | ||
|
||
# Backend Targets | ||
backend-lint: | ||
@echo "$(COLOR_BLUE_BG)Running backend linting with ruff...$(COLOR_RESET)" | ||
cd $(SERVER_DIR) && $(VENV_ACTIVATE) && $(RUFF) check --fix . | ||
|
||
backend-format: | ||
@echo "$(COLOR_BLUE_BG)Running backend formatting with ruff...$(COLOR_RESET)" | ||
cd $(SERVER_DIR) && $(VENV_ACTIVATE) && $(RUFF) format . | ||
|
||
backend-type-check: | ||
@echo "$(COLOR_BLUE_BG)Running backend static type checking with mypy...$(COLOR_RESET)" | ||
cd $(SERVER_DIR) && $(VENV_ACTIVATE) && $(MYPY) . | ||
|
||
backend-validate-api-schema: | ||
@echo "$(COLOR_BLUE_BG)Validating API schema...$(COLOR_RESET)" | ||
cd $(SERVER_DIR) && $(VENV_ACTIVATE) && $(OPENAPI_SCHEMA) | ||
|
||
backend-test: | ||
@echo "$(COLOR_BLUE_BG)Running backend unit tests...$(COLOR_RESET)" | ||
cd $(SERVER_DIR) && $(VENV_ACTIVATE) && $(PYTEST) && $(PYCOVERAGE) | ||
|
||
_run-backend: | ||
@echo "$(COLOR_BLUE_BG)Running backend server...$(COLOR_RESET)" | ||
cd $(SERVER_DIR) && $(VENV_ACTIVATE) && $(DJANGO_RUNSERVER) & echo $$! > backend.pid | ||
|
||
backend-load-test: | ||
@echo "$(COLOR_BLUE_BG)Running backend load tests...$(COLOR_RESET)" | ||
@$(MAKE) _run-backend | ||
cd $(SERVER_DIR) && $(VENV_ACTIVATE) && $(LOCUST) | ||
|
||
.PHONY: backend-lint backend-format backend-type-check \ | ||
backend-validate-api-schema backend-test _run-backend backend-load-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FRONTEND_DIR=./frontend | ||
|
||
# Frontend tool commands | ||
ESLINT=npm run lint:fix | ||
PRETTIER=npm run format | ||
TSC=npm run check-types | ||
AUDIT=npm audit --audit-level=moderate | ||
BUILD=npm run build | ||
JEST=npm run test | ||
NEXT_START=npm run start | ||
PLAYWRIGHT=npm run test:e2e | ||
|
||
# Frontend Targets | ||
frontend-lint: | ||
@echo "$(COLOR_BLUE_BG)Running frontend linting...$(COLOR_RESET)" | ||
cd $(FRONTEND_DIR) && $(ESLINT) . | ||
|
||
frontend-format: | ||
@echo "$(COLOR_BLUE_BG)Running frontend formatting...$(COLOR_RESET)" | ||
cd $(FRONTEND_DIR) && $(PRETTIER) . | ||
|
||
frontend-type-check: | ||
@echo "$(COLOR_BLUE_BG)Running frontend static type checking with TypeScript...$(COLOR_RESET)" | ||
cd $(FRONTEND_DIR) && $(TSC) | ||
|
||
frontend-test: | ||
@echo "$(COLOR_BLUE_BG)Running frontend unit tests...$(COLOR_RESET)" | ||
cd $(FRONTEND_DIR) && $(JEST) | ||
|
||
frontend-build: | ||
@echo "$(COLOR_BLUE_BG)Building frontend...$(COLOR_RESET)" | ||
cd $(FRONTEND_DIR) && $(BUILD) | ||
|
||
frontend-audit: | ||
@echo "$(COLOR_BLUE_BG)Auditing frontend dependencies...$(COLOR_RESET)" | ||
cd $(FRONTEND_DIR) && $(AUDIT) | ||
|
||
_run-frontend: | ||
@echo "$(COLOR_BLUE_BG)Running frontend server...$(COLOR_RESET)" | ||
cd $(FRONTEND_DIR) && $(NEXT_START) & echo $$! > frontend.pid | ||
|
||
_run-e2e-test: | ||
@echo "$(COLOR_BLUE_BG)Running end-to-end tests...$(COLOR_RESET)" | ||
cd $(FRONTEND_DIR) && $(PLAYWRIGHT) | ||
|
||
.PHONY: frontend-lint frontend-format frontend-type-check \ | ||
frontend-test frontend-build frontend-audit _run-frontend _run-e2e-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from typing import Any | ||
|
||
from rest_framework import serializers | ||
|
||
|
||
class ChatRequestSerializer(serializers.Serializer): | ||
class ChatRequestSerializer(serializers.Serializer[dict[str, Any]]): | ||
prompt = serializers.CharField() | ||
|
||
|
||
class AssistantResponseSerializer(serializers.Serializer): | ||
class AssistantResponseSerializer(serializers.Serializer[dict[str, Any]]): | ||
response = serializers.CharField() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.