Skip to content

Commit e20fdea

Browse files
Merge pull request #968 from SuffolkLITLab/copilot/fix-967
Fix return type documentation for ALCourtLoader methods
2 parents 9313291 + 3a0880a commit e20fdea

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

docassemble/AssemblyLine/al_courts.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import os
6-
from typing import Any, Callable, Dict, List, Mapping, Optional, Union, Set
6+
from typing import Any, Callable, Dict, List, Mapping, Optional, Union, Set, Tuple
77
import pandas as pd
88
import docassemble.base.functions
99
from docassemble.base.util import (
@@ -238,12 +238,12 @@ def init(self, *pargs, **kwargs) -> None:
238238
# Only solution I can think of would require court database owners to assign each court a unique ID
239239
# and something that triggers recalculating the court address/etc info.
240240

241-
def all_courts(self) -> List[Dict[int, str]]:
241+
def all_courts(self) -> List[Tuple[int, str]]:
242242
"""
243243
Return a list of all courts in the spreadsheet.
244244
245245
Returns:
246-
List[Dict[int, str]]: List of all ALCourt instances without filtering.
246+
List[Tuple[int, str]]: List of tuples where each tuple contains (dataframe_index, display_value). The dataframe_index (int) can be used with as_court() to retrieve the full court object. The display_value (str) is the court's name or other display column value.
247247
"""
248248
return self.filter_courts(None)
249249

@@ -329,13 +329,14 @@ def matching_courts_in_county(
329329
display_column: str = "name",
330330
search_string: Optional[str] = None,
331331
search_columns: Optional[Union[List[str], str]] = None,
332-
) -> List[Dict[int, str]]:
332+
) -> List[Tuple[int, str]]:
333333
"""
334334
Retrieve a list of all courts in the specified county.
335335
336336
This function fetches courts suitable for displaying as a drop-down or radio button list
337-
in Docassemble. The results are dictionaries where the key is the index in the dataframe,
338-
useful for retrieving the court's full details later using the as_court() method.
337+
in Docassemble. The results are tuples where the first element is the dataframe index
338+
(useful for retrieving the court's full details later using the as_court() method) and
339+
the second element is the display value from the specified display_column.
339340
340341
Args:
341342
county_name (str): Name of the county.
@@ -346,7 +347,7 @@ def matching_courts_in_county(
346347
the search_string in a case-insensitive manner. Defaults to None.
347348
348349
Returns:
349-
List[Dict[int, str]]: List of dictionaries representing matching courts.
350+
List[Tuple[int, str]]: List of tuples where each tuple contains (dataframe_index, display_value). The dataframe_index (int) can be used with as_court() to retrieve the full court object. The display_value (str) is the court's name or other display column value.
350351
"""
351352
return self.filter_courts(
352353
court_types=county_name,
@@ -363,11 +364,11 @@ def filter_courts(
363364
display_column: str = "name",
364365
search_string: Optional[str] = None,
365366
search_columns: Optional[Union[List[str], str]] = None,
366-
) -> List[Dict[int, str]]:
367+
) -> List[Tuple[int, str]]:
367368
"""
368-
Return a filtered subset of courts represented as a list of dictionaries.
369+
Return a filtered subset of courts represented as a list of tuples.
369370
370-
Each dictionary has the format {index: name}, where "index" refers to the dataframe index and "name"
371+
Each tuple has the format (index, display_value), where "index" refers to the dataframe index and "display_value"
371372
is determined by the `display_column`.
372373
373374
Args:
@@ -380,7 +381,7 @@ def filter_courts(
380381
the search_string in a case-insensitive manner. Defaults to None.
381382
382383
Returns:
383-
List[Dict[int, str]]: List of dictionaries representing filtered courts.
384+
List[Tuple[int, str]]: List of tuples where each tuple contains (dataframe_index, display_value). The dataframe_index (int) can be used with as_court() to retrieve the full court object. The display_value (str) is the court's name or other display column value.
384385
"""
385386
df = self._load_courts()
386387
if court_types:

0 commit comments

Comments
 (0)