Skip to content

Commit 306ded2

Browse files
Fix to new version of docsig; add missing docstrings and reformat some return statements
1 parent 80b1807 commit 306ded2

File tree

5 files changed

+139
-24
lines changed

5 files changed

+139
-24
lines changed

docassemble/AssemblyLine/al_courts.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ class ALCourt(Court):
2929
A list of cities? A list of counties? Instead, we use a function on the CourtList object that filters courts by
3030
address and can use any of those three features of the court to do the filtering."""
3131

32-
def init(self, *pargs, **kwargs):
32+
def init(self, *pargs, **kwargs) -> None:
33+
"""Create a new court object.
34+
35+
Args:
36+
*pargs: Standard DAObject positional arguments
37+
**kwargs: Standard DAObject keyword arguments
38+
"""
3339
super().init(*pargs, **kwargs)
3440
if "address" not in kwargs:
3541
self.initializeAttribute("address", ALAddress)
@@ -208,7 +214,13 @@ class ALCourtLoader(DAObject):
208214
converters (Dict[str, Callable]): A dictionary of functions to apply to columns in the dataframe.
209215
"""
210216

211-
def init(self, *pargs, **kwargs):
217+
def init(self, *pargs, **kwargs) -> None:
218+
"""Create a new courtloader object.
219+
220+
Args:
221+
*pargs: Standard DAObject positional arguments
222+
**kwargs: Standard DAObject keyword arguments
223+
"""
212224
super().init(*pargs, **kwargs)
213225
self.package = docassemble.base.functions.this_thread.current_question.package
214226
if not hasattr(self, "filename"):
@@ -240,8 +252,9 @@ def unique_column_values(self, column_name: str) -> Set[str]:
240252
column_name (str): The name of the column in the dataframe.
241253
242254
Returns:
243-
Set[str]: A set containing unique values from the specified column.
244-
Returns an empty set if an error occurs.
255+
Set[str]:
256+
- A set containing unique values from the specified column.
257+
- Returns an empty set if the column does not exist or an error occurs.
245258
"""
246259
df = self._load_courts()
247260
try:

docassemble/AssemblyLine/al_document.py

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,13 @@ class ALAddendumField(DAObject):
248248
The attributes `headers` and `field_style` are planned for future releases and are not currently implemented.
249249
"""
250250

251-
def init(self, *pargs, **kwargs):
251+
def init(self, *pargs, **kwargs) -> None:
252+
"""Standard DAObject init method.
253+
254+
Args:
255+
*pargs: Positional arguments
256+
**kwargs: Keyword arguments
257+
"""
252258
super().init(*pargs, **kwargs)
253259

254260
def overflow_value(
@@ -752,7 +758,13 @@ class ALAddendumFieldDict(DAOrderedDict):
752758
only the overflow text will be displayed.
753759
"""
754760

755-
def init(self, *pargs, **kwargs):
761+
def init(self, *pargs, **kwargs) -> None:
762+
"""Standard DAObject init method.
763+
764+
Args:
765+
*pargs: Positional arguments
766+
**kwargs: Keyword arguments
767+
"""
756768
super(ALAddendumFieldDict, self).init(*pargs, **kwargs)
757769
self.object_type = ALAddendumField
758770
self.auto_gather = False
@@ -990,7 +1002,13 @@ class ALDocument(DADict):
9901002
```
9911003
"""
9921004

993-
def init(self, *pargs, **kwargs):
1005+
def init(self, *pargs, **kwargs) -> None:
1006+
"""Standard DAObject init method.
1007+
1008+
Args:
1009+
*pargs: Positional arguments
1010+
**kwargs: Keyword arguments
1011+
"""
9941012
super(ALDocument, self).init(*pargs, **kwargs)
9951013
self.initializeAttribute("overflow_fields", ALAddendumFieldDict)
9961014
if not hasattr(self, "default_overflow_message"):
@@ -1345,7 +1363,13 @@ class ALStaticDocument(DAStaticFile):
13451363
Consider handling files in `/data/templates` if deemed useful, potentially by copying into a DAFile using `pdf_concatenate()`.
13461364
"""
13471365

1348-
def init(self, *pargs, **kwargs):
1366+
def init(self, *pargs, **kwargs) -> None:
1367+
"""Standard DAObject init method.
1368+
1369+
Args:
1370+
*pargs: Positional arguments
1371+
**kwargs: Keyword arguments
1372+
"""
13491373
super().init(*pargs, **kwargs)
13501374
self.has_addendum = False
13511375
self.auto_gather = False
@@ -1515,7 +1539,13 @@ class ALDocumentBundle(DAList):
15151539
```
15161540
"""
15171541

1518-
def init(self, *pargs, **kwargs):
1542+
def init(self, *pargs, **kwargs) -> None:
1543+
"""Standard DAObject init method.
1544+
1545+
Args:
1546+
*pargs: Positional arguments
1547+
**kwargs: Keyword arguments
1548+
"""
15191549
super().init(*pargs, **kwargs)
15201550
if "auto_gather" not in kwargs:
15211551
self.auto_gather = False
@@ -2511,7 +2541,13 @@ class ALExhibit(DAObject):
25112541
starting_page (int): first page number to use in table of contents
25122542
"""
25132543

2514-
def init(self, *pargs, **kwargs):
2544+
def init(self, *pargs, **kwargs) -> None:
2545+
"""Standard DAObject init method.
2546+
2547+
Args:
2548+
*pargs: Positional arguments
2549+
**kwargs: Keyword arguments
2550+
"""
25152551
super().init(*pargs, **kwargs)
25162552
self.initializeAttribute("_cache", DALazyAttribute)
25172553
self.object_type = DAFileList
@@ -2731,7 +2767,13 @@ class ALExhibitList(DAList):
27312767
auto_ocr (bool): If True, automatically starts OCR processing for uploaded exhibits. Defaults to True.
27322768
"""
27332769

2734-
def init(self, *pargs, **kwargs):
2770+
def init(self, *pargs, **kwargs) -> None:
2771+
"""Standard DAObject init method.
2772+
2773+
Args:
2774+
*pargs: Positional arguments
2775+
**kwargs: Keyword arguments
2776+
"""
27352777
super().init(*pargs, **kwargs)
27362778
if not hasattr(self, "auto_label"):
27372779
self.auto_label = True
@@ -2909,7 +2951,13 @@ class ALExhibitDocument(ALDocument):
29092951
```
29102952
"""
29112953

2912-
def init(self, *pargs, **kwargs):
2954+
def init(self, *pargs, **kwargs) -> None:
2955+
"""Standard DAObject init method.
2956+
2957+
Args:
2958+
*pargs: Positional arguments
2959+
**kwargs: Keyword arguments
2960+
"""
29132961
super().init(*pargs, **kwargs)
29142962
self.initializeAttribute("exhibits", ALExhibitList)
29152963
if hasattr(self, "auto_labeler"):
@@ -3060,7 +3108,13 @@ class ALTableDocument(ALDocument):
30603108
table (???): Represents the actual table data. Type and attributes need more context to document.
30613109
"""
30623110

3063-
def init(self, *pargs, **kwargs):
3111+
def init(self, *pargs, **kwargs) -> None:
3112+
"""Standard DAObject init method.
3113+
3114+
Args:
3115+
*pargs: Positional arguments
3116+
**kwargs: Keyword arguments
3117+
"""
30643118
super().init(*pargs, **kwargs)
30653119
self.has_addendum = False
30663120
if not hasattr(self, "suffix_to_append"):
@@ -3171,7 +3225,13 @@ class ALUntransformedDocument(ALDocument):
31713225
suffix_to_append (str): Suffix that can be appended to file names, defaulting to "preview".
31723226
"""
31733227

3174-
def init(self, *pargs, **kwargs):
3228+
def init(self, *pargs, **kwargs) -> None:
3229+
"""Standard DAObject init method.
3230+
3231+
Args:
3232+
*pargs: Positional arguments
3233+
**kwargs: Keyword arguments
3234+
"""
31753235
super().init(*pargs, **kwargs)
31763236
self.has_addendum = False
31773237
if not hasattr(self, "suffix_to_append"):

docassemble/AssemblyLine/al_general.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ def formatted_unit(
293293
True, the function will not add 'Unit' regardless of other conditions. Defaults to False.
294294
295295
Returns:
296-
str: The formatted unit. If the unit attribute does not exist and require is set to False, this will be an
296+
str:
297+
The formatted unit. If the unit attribute does not exist and require is set to False, this will be an
297298
empty string. If the unit attribute exists and is not None or an empty string, the function will return
298299
the unit number, possibly prefixed with 'Unit'. If the unit attribute exists and is None or an empty
299300
string, the function will return an empty string.
@@ -627,7 +628,8 @@ def normalized_address(self) -> Union[Address, "ALAddress"]:
627628
Warning: currently the normalized address will not be redacted if the address is impounded.
628629
629630
Returns:
630-
Union[Address, "ALAddress"]: Normalized address if geocoding is successful, otherwise
631+
Union[Address, "ALAddress"]:
632+
Normalized address if geocoding is successful, otherwise
631633
the original address.
632634
"""
633635
try:
@@ -680,7 +682,13 @@ class ALAddressList(DAList):
680682
of the list in a formatted manner.
681683
"""
682684

683-
def init(self, *pargs, **kwargs):
685+
def init(self, *pargs, **kwargs) -> None:
686+
"""Standard DAObject init method.
687+
688+
Args:
689+
*pargs: Positional arguments
690+
**kwargs: Keyword arguments
691+
"""
684692
super(ALAddressList, self).init(*pargs, **kwargs)
685693
self.object_type = ALAddress
686694

@@ -702,7 +710,13 @@ class ALNameList(DAList):
702710
Extends the DAList class and is tailored for IndividualName objects.
703711
"""
704712

705-
def init(self, *pargs, **kwargs):
713+
def init(self, *pargs, **kwargs) -> None:
714+
"""Standard DAObject init method.
715+
716+
Args:
717+
*pargs: Positional arguments
718+
**kwargs: Keyword arguments
719+
"""
706720
super().init(*pargs, **kwargs)
707721
self.object_type = IndividualName
708722

@@ -720,7 +734,13 @@ class ALPeopleList(DAList):
720734
721735
For example, defendants, plaintiffs, or children."""
722736

723-
def init(self, *pargs, **kwargs):
737+
def init(self, *pargs, **kwargs) -> None:
738+
"""Standard DAObject init method.
739+
740+
Args:
741+
*pargs: Positional arguments
742+
**kwargs: Keyword arguments
743+
"""
724744
super(ALPeopleList, self).init(*pargs, **kwargs)
725745
self.object_type = ALIndividual
726746

@@ -874,7 +894,13 @@ class ALIndividual(Individual):
874894
aliases: ALNameList
875895
preferred_name: IndividualName
876896

877-
def init(self, *pargs, **kwargs):
897+
def init(self, *pargs, **kwargs) -> None:
898+
"""Standard DAObject init method.
899+
900+
Args:
901+
*pargs: Positional arguments
902+
**kwargs: Keyword arguments
903+
"""
878904
super(ALIndividual, self).init(*pargs, **kwargs)
879905
# Initialize the attributes that are themselves objects. Requirement to work with Docassemble
880906
# See: https://docassemble.org/docs/objects.html#ownclassattributes

docassemble/AssemblyLine/language.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@
1414
]
1515

1616

17-
def _package_name(package_name: Optional[str] = None):
18-
"""Get package name without the name of the given module. By default this is `docassemble.AssemblyLine.language`"""
17+
def _package_name(package_name: Optional[str] = None) -> str:
18+
"""Get package name without the name of the given module. By default this is `docassemble.AssemblyLine.language`
19+
20+
Args:
21+
package_name: the name of the package to get the package name from (defaults to `docassemble.AssemblyLine.language`)
22+
23+
Returns:
24+
str: the package name without the name of the given module
25+
"""
1926
if not package_name:
2027
package_name = __name__
2128
try:
@@ -24,7 +31,13 @@ def _package_name(package_name: Optional[str] = None):
2431
return package_name
2532

2633

27-
def get_local_languages_yaml():
34+
def get_local_languages_yaml() -> str:
35+
"""
36+
Get the path to the local languages.yml file. If it does not exist, it will return the path to the languages.yml
37+
38+
Returns:
39+
str: the path to the local languages.yml file if it exists, otherwise the path to the languages.yml file
40+
"""
2841
try:
2942
local_yaml = path_and_mimetype("data/sources/languages.yml")[0]
3043
except:

docassemble/AssemblyLine/project_maintenance.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,10 @@ def link_issue_title_to_project(
338338
print(f"Project '{project_name}' not found.")
339339

340340

341-
def main():
341+
def main() -> None:
342+
"""
343+
Main function to run the specified project maintenance command.
344+
"""
342345
parser = argparse.ArgumentParser(
343346
description="Run specified function with arguments."
344347
)

0 commit comments

Comments
 (0)