From 3a9e2892823811892c095061d1367840920add84 Mon Sep 17 00:00:00 2001 From: Graham Hukill Date: Tue, 7 May 2024 09:19:00 -0400 Subject: [PATCH] Additional docstrings from review feedback --- hrqb/base/task.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hrqb/base/task.py b/hrqb/base/task.py index 0e06dde..5af09e3 100644 --- a/hrqb/base/task.py +++ b/hrqb/base/task.py @@ -31,6 +31,10 @@ def path(self) -> str: output/LookupTablesPipeline__extract__JobData.pickle output/LookupTablesPipeline__transform__UniqueJobTitles.pickle output/LookupTablesPipeline__load__UpsertJobTitles.pickle + + A double underscore '__' is used to join these components together to allow + splitting on the filename if needed, where a single component may (though not + likely) contain a single underscore. """ filename = ( "__".join( # noqa: FLY002 @@ -47,7 +51,14 @@ def filename_extension(self) -> str: @property def single_input(self) -> PandasPickleTarget | QuickbaseTableTarget: - """Return single parent Task Target, raise error if multiple parent Tasks.""" + """Return single parent Task Target, raise error if multiple parent Tasks. + + When used, this convenience method also helps reason about Tasks. Quite often, a + Task is only expecting a single parent Task that will feed it data. In these + scenarios, using self.single_input is not only convenient, but also codifies in + code this assumption. If this Task were to receive multiple inputs in the future + this method would then throw an error. + """ input_count = len(self.input()) if input_count != 1: message = f"Expected a single input to this Task but found: {input_count}"