Skip to content

Commit 04de6d7

Browse files
authored
Merge pull request #305 from sahilds1/300-add-python-github-actions
[#300] Add Python linting checks for PRs using GitHub Actions
2 parents 8843aab + 4ab7553 commit 04de6d7

File tree

17 files changed

+36
-39
lines changed

17 files changed

+36
-39
lines changed

.github/workflows/python-app.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python application
5+
6+
on:
7+
push:
8+
branches: [ "listOfMed" ]
9+
pull_request:
10+
branches: [ "listOfMed" ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.x'
26+
- name: Install the code linting and formatting tool Ruff
27+
run: pipx install ruff
28+
- name: Lint code with Ruff
29+
run: ruff check --output-format=github --target-version=py39

server/api/admin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from .models.authUser import UserAccount
55
from .views.ai_settings.models import AI_Settings
66
from .views.ai_promptStorage.models import AI_PromptStorage
7-
from .views.ai_settings.models import AI_Settings
8-
from .views.ai_promptStorage.models import AI_PromptStorage
97
from .models.model_embeddings import Embeddings
108
from .views.feedback.models import Feedback
119
from .models.model_medRule import MedRule
@@ -24,7 +22,7 @@ class MedicationAdmin(admin.ModelAdmin):
2422

2523

2624
@admin.register(Medication)
27-
class MedicationAdmin(admin.ModelAdmin):
25+
class MedicationAdmin(admin.ModelAdmin): # noqa: F811
2826
list_display = ['name', 'benefits', 'risks']
2927

3028

server/api/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
from django.db import models
21

32
# Create your models here.

server/api/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .authUser import UserAccount
1+
from .authUser import UserAccount # noqa: F401

server/api/models/model_embeddings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from django.db import models
2-
from django.conf import settings
32
from pgvector.django import VectorField
43
import uuid
54
from ..views.uploadFile.models import UploadFile

server/api/models/model_medRule.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.db import models
22
from ..views.listMeds.models import Medication
3-
from django.db.models import CASCADE
43
from ..models.model_embeddings import Embeddings
54

65

server/api/tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from django.test import TestCase
21
import unittest
32
from .services.tools.tools import validate_tool_inputs, execute_tool
43

server/api/views/ai_promptStorage/serializers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from rest_framework import serializers
22
from .models import AI_PromptStorage
3-
from django.conf import settings
43

54

65
class AI_PromptStorageSerializer(serializers.ModelSerializer):

server/api/views/ai_promptStorage/views.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
from rest_framework import status
2-
from rest_framework.decorators import api_view, permission_classes
3-
from rest_framework.permissions import IsAuthenticated
2+
from rest_framework.decorators import api_view
43
from rest_framework.response import Response
54
from .models import AI_PromptStorage
65
from .serializers import AI_PromptStorageSerializer
7-
from django.views.decorators.csrf import csrf_exempt
86

97

108
@api_view(['POST'])
119
# @permission_classes([IsAuthenticated])
1210
def store_prompt(request):
1311
print(request.user)
14-
data = request.data.copy()
12+
data = request.data.copy() # noqa: F841
1513
print(request.user)
1614
serializer = AI_PromptStorageSerializer(
1715
data=request.data, context={'request': request})

server/api/views/ai_settings/urls.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from django.urls import path, include
2-
from rest_framework.routers import DefaultRouter
1+
from django.urls import path
32
from api.views.ai_settings import views
43

54
urlpatterns = [

0 commit comments

Comments
 (0)