From 9686e43ec26a4733bb4125232cf5c01cb736f58d Mon Sep 17 00:00:00 2001 From: riley Date: Tue, 28 Sep 2021 01:36:12 -0400 Subject: [PATCH] Documentation and formatting fixes --- todo/Todo.py | 4 ++-- todo/TodoObject.py | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/todo/Todo.py b/todo/Todo.py index 5ff1415..104ea5a 100644 --- a/todo/Todo.py +++ b/todo/Todo.py @@ -57,14 +57,14 @@ class Todo(TodoObject): else: # catch-all for unlisted notes return 0 - def _get_parent(self, level, obj: TodoObject, obj_type: Type[TodoObject] = None): + def _get_parent(self, level: int, obj: TodoObject, obj_type: Optional[Type[TodoObject]] = None): """Gets the parent for an object at level X. If an object with a lower level cannot be found within the obj, it will return the obj. Args: level (int): The level to find the parent for. obj (TodoObject): Object to grab parents from. - obj_type (Type[TodoObject]): The type of the object the parent should be. Default is None. + obj_type (Type[TodoObject], optional): The type of the object the parent should be. Default is None. Returns: TodoObject: The object found. diff --git a/todo/TodoObject.py b/todo/TodoObject.py index f99fddb..585107f 100644 --- a/todo/TodoObject.py +++ b/todo/TodoObject.py @@ -24,10 +24,10 @@ class TodoObject: Args: immediate (bool, optional): Whether it should return immediate children only. Defaults to False. - obj_type (Optional[Type[T]], optional): Specify the types of children to return. Defaults to None. + obj_type (Type[Note | Category | Task], optional): Specify the types of children to return. Defaults to None. Returns: - list[T]: [description] + list[Note | Category | Task]: Returns all children that match the criteria. """ output = [] for child in self.children: @@ -45,10 +45,10 @@ class TodoObject: """Get all parents of an object. Optionally specify a class of TodoObject to return. Args: - obj_type (Optional[Type[T]], optional): Specify the types of parents to return. Defaults to None. + obj_type (Type[Note | Category | Task], optional): Specify the types of parents to return. Defaults to None. Returns: - list[T]: List of parents found. + list[Note | Category | Task]: List of parents found. """ output = [] for parent in self.parents: @@ -67,7 +67,6 @@ class TodoObject: Returns: str: the markdown text generated """ - output = "" for i in self.get_children(): if len(output) > 0: @@ -127,13 +126,12 @@ class TodoObject: complete (Optional[bool], optional): If true, return completed tasks only, inverse if False. Defaults to None. Returns: - Task: [description] + Task: Returns the task found """ for task in self.get_tasks(immediate, complete): if re.match(regex, task.text): return task - def get_categories(self, immediate: bool = False) -> list[Category]: """Gets all categories from children of the TodoObject. @@ -150,7 +148,7 @@ class TodoObject: immediate (bool, optional): Whether or not it should return immediate children only. Defaults to False. Returns: - Category: [description] + Category: Returns the category found. """ for category in self.get_categories(immediate): if re.match(regex, category.text): @@ -161,7 +159,7 @@ class TodoObject: Args: immediate (bool, optional): Whether or not it should return immeduate children only. Defaults to False. -c + Returns: Note: Returns all notes found. """ @@ -175,7 +173,7 @@ c immediate (bool, optional): Whether or not it should return immediate children only. Defaults to False. Returns: - Note: [description] + Note: Returns the note found. """ for note in self.get_notes(immediate): if re.match(regex, note.text):