Skip to content

Commit

Permalink
refactor: typing for forms.py
Browse files Browse the repository at this point in the history
  • Loading branch information
thangixd committed May 24, 2024
1 parent fceb2b6 commit 32efd5a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tracex_project/db_results/forms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Implementation of forms for the database result app."""
from typing import List, Tuple, Any

from django import forms
from django.utils.safestring import mark_safe

from extraction.models import PatientJourney
from extraction.models import Cohort
from extraction.models import PatientJourney
from tracex.forms import BaseEventForm


Expand All @@ -19,7 +20,7 @@ def __init__(self, *args, **kwargs):
"selected_patient_journey"
].choices = self.get_patient_journey_choices()

def get_patient_journey_choices(self):
def get_patient_journey_choices(self) -> List[Tuple[str, str]]:
"""Retrieves the available patient journey choices with existing metrics from the database."""
patient_journeys = PatientJourney.manager.filter(
trace__events__metrics__isnull=False
Expand Down Expand Up @@ -89,7 +90,7 @@ def __init__(self, *args, **kwargs):
self.fields["sex"].choices = self.get_choices("sex")

@staticmethod
def get_choices(category):
def get_choices(category: str) -> List[Tuple[Any, Any]]:
"""Get all choices available in the database for a given category."""
choices = Cohort.manager.values_list(category, flat=True).distinct()
none_info_text = mark_safe("<i>Include elements with None values</i>")
Expand Down

0 comments on commit 32efd5a

Please sign in to comment.