From cff6f64be6b5c3a0fff0f3fdae0bc1449b1ab7a1 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Wed, 8 Nov 2023 11:00:11 -0500 Subject: [PATCH 1/6] Fix #202 - allow use of arbitrary separator, slight refactor for more idiomatic code --- docassemble/ALToolbox/al_income.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docassemble/ALToolbox/al_income.py b/docassemble/ALToolbox/al_income.py index 6aa3e2d6..6bef8d3e 100644 --- a/docassemble/ALToolbox/al_income.py +++ b/docassemble/ALToolbox/al_income.py @@ -701,13 +701,13 @@ def init(self, *pargs, **kwargs): if not hasattr(self, "source"): self.source = "vehicle" - def year_make_model(self) -> str: + def year_make_model(self, separator="/") -> str: """ Returns a string of the format year/make/model of the vehicle. Triggers gathering those attributes. """ - return f"{ self.year } / { self.make } / { self.model }" - + return separator.join([self.year, self.make, self.model]) + class ALVehicleList(ALAssetList): """List of ALVehicles. Extends ALAssetList.""" From c23fd68d1b344c8c61aa831c86a1eb71022a0e07 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Wed, 8 Nov 2023 11:02:04 -0500 Subject: [PATCH 2/6] Typing + black --- docassemble/ALToolbox/al_income.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docassemble/ALToolbox/al_income.py b/docassemble/ALToolbox/al_income.py index 6bef8d3e..1910fd5b 100644 --- a/docassemble/ALToolbox/al_income.py +++ b/docassemble/ALToolbox/al_income.py @@ -701,13 +701,13 @@ def init(self, *pargs, **kwargs): if not hasattr(self, "source"): self.source = "vehicle" - def year_make_model(self, separator="/") -> str: + def year_make_model(self, separator: str = "/") -> str: """ Returns a string of the format year/make/model of the vehicle. Triggers gathering those attributes. """ return separator.join([self.year, self.make, self.model]) - + class ALVehicleList(ALAssetList): """List of ALVehicles. Extends ALAssetList.""" From 66fa733bd2df8ae18f0a2b8830de63ae3de1c4ef Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Wed, 8 Nov 2023 11:03:49 -0500 Subject: [PATCH 3/6] add space back in --- docassemble/ALToolbox/al_income.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docassemble/ALToolbox/al_income.py b/docassemble/ALToolbox/al_income.py index 1910fd5b..001643af 100644 --- a/docassemble/ALToolbox/al_income.py +++ b/docassemble/ALToolbox/al_income.py @@ -701,7 +701,7 @@ def init(self, *pargs, **kwargs): if not hasattr(self, "source"): self.source = "vehicle" - def year_make_model(self, separator: str = "/") -> str: + def year_make_model(self, separator: str = " / ") -> str: """ Returns a string of the format year/make/model of the vehicle. Triggers gathering those attributes. From f8c716703dd4cb775f9146300ab0b23f179828e7 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Wed, 8 Nov 2023 11:12:18 -0500 Subject: [PATCH 4/6] Ensure string --- docassemble/ALToolbox/al_income.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docassemble/ALToolbox/al_income.py b/docassemble/ALToolbox/al_income.py index 001643af..14977a6e 100644 --- a/docassemble/ALToolbox/al_income.py +++ b/docassemble/ALToolbox/al_income.py @@ -706,7 +706,7 @@ def year_make_model(self, separator: str = " / ") -> str: Returns a string of the format year/make/model of the vehicle. Triggers gathering those attributes. """ - return separator.join([self.year, self.make, self.model]) + return separator.join(map(str, [self.year, self.make, self.model])) class ALVehicleList(ALAssetList): From df99e058d72d2a6de5e004811401c7d252d05af8 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Wed, 8 Nov 2023 11:15:47 -0500 Subject: [PATCH 5/6] improve docstring --- docassemble/ALToolbox/al_income.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docassemble/ALToolbox/al_income.py b/docassemble/ALToolbox/al_income.py index 14977a6e..3b37c7cd 100644 --- a/docassemble/ALToolbox/al_income.py +++ b/docassemble/ALToolbox/al_income.py @@ -705,6 +705,12 @@ def year_make_model(self, separator: str = " / ") -> str: """ Returns a string of the format year/make/model of the vehicle. Triggers gathering those attributes. + + Args: + separator {str} (Optional) The separator between the year, make and model. + + Returns: + A string of the format year/make/model of the vehicle. """ return separator.join(map(str, [self.year, self.make, self.model])) From 2cc7f0ffe1693e278cbfefd67c7f00843bf95ba2 Mon Sep 17 00:00:00 2001 From: Quinten Steenhuis Date: Wed, 8 Nov 2023 11:17:13 -0500 Subject: [PATCH 6/6] Also improve class docstring --- docassemble/ALToolbox/al_income.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/docassemble/ALToolbox/al_income.py b/docassemble/ALToolbox/al_income.py index 3b37c7cd..255e682c 100644 --- a/docassemble/ALToolbox/al_income.py +++ b/docassemble/ALToolbox/al_income.py @@ -678,22 +678,23 @@ def owners( class ALVehicle(ALAsset): - """ - An ALAsset with special attributes that help representing a vehicle. + """Represents a vehicle as a specialized type of ALAsset. - Vehicles have a .year_make_model() method which facilitates - listing vehicles on many financial statement forms. + This subclass of ALAsset adds specific attributes relevant to vehicles, + such as year, make, and model, and includes methods for representing + these attributes in a standardized format, as often required on financial + statement forms. Attributes: - .year {str} The model year of the vehicle, like 2022 - .make {str} The make of the vehicle, like "Honda" - .model {str} The model of the vehicle, like "Accord" - .market_value {float | Decimal} Market value of an asset. - .balance {float | Decimal} Balance of an asset. - .value {float | Decimal} (Optional) Income earned by the vehicle (typically 0) - .times_per_year {float} Time frequency over which the `value` is earned - .owner {str} Full name of the asset owner as a single string. - .source {str} (Optional) The "source" of the asset. Defaults to "vehicle". + year (str): The model year of the vehicle, e.g., '2022'. + make (str): The make of the vehicle, e.g., 'Honda'. + model (str): The model of the vehicle, e.g., 'Accord'. + market_value (float or Decimal): Market value of the vehicle. + balance (float or Decimal): Balance of the loan on the vehicle. + value (float or Decimal, optional): Income earned by the vehicle, typically 0. + times_per_year (int): The frequency over which the `value` is earned annually. + owner (str): Full name of the vehicle owner. + source (str, optional): The source of the asset, defaults to 'vehicle'. """ def init(self, *pargs, **kwargs):