Skip to content

Task

Bases: Task_

Source code in src/plankapy/interfaces.py
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
class Task(Task_):

    @property
    def card(self) -> Card:
        card_route = self.routes.get_card(id=self.cardId)
        return Card(**card_route()['item']).bind(self.routes)

    @overload
    def update(self): ...

    @overload
    def update(self, task: Task): ...

    @overload
    def update(self, name: str=None, isCompleted: bool=None) -> Task: ...

    def update(self, *args, **kwargs) -> Task:
        """Updates the task with new values

        Tip:
            If you want to update a task, it's better to use the `editor()` context manager

            Example:
            ```python
            >>> with task.editor():
            ...    task.name = 'New Task Name'
            ...    task.isCompleted = True

            >>> task
            Task(id=1, name='New Task Name', isCompleted=True, ...)
            ```

        Args:
            name (str): Name of the task (optional)
            isCompleted (bool): Whether the task is completed (optional)

        Args: Alternate
            task (Task): Task instance to update (required)

        Note:
            If no arguments are provided, the task will update itself with the current values stored in its attributes

        Returns:
            Task: Updated task instance
        """
        overload = parse_overload(
            args, kwargs, 
            model='task', 
            options=('name', 'isCompleted'),
            noarg=self)

        route = self.routes.patch_task(id=self.id)
        self.__init__(**route(**overload)['item'])
        return self

    def delete(self) -> Task:
        """Deletes the task

        Danger:
            This action is irreversible and cannot be undone

        Returns:
            Task: Deleted task instance
        """
        self.refresh()
        route = self.routes.delete_task(id=self.id)
        route()
        return self

    def refresh(self) -> None:
        """Refreshes the task data"""
        tasks = self.card.board.tasks
        for task in tasks:
            if task.id == self.id:
                self.__init__(**task)

delete()

Deletes the task

Danger

This action is irreversible and cannot be undone

Returns:

Name Type Description
Task Task

Deleted task instance

Source code in src/plankapy/interfaces.py
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
def delete(self) -> Task:
    """Deletes the task

    Danger:
        This action is irreversible and cannot be undone

    Returns:
        Task: Deleted task instance
    """
    self.refresh()
    route = self.routes.delete_task(id=self.id)
    route()
    return self

refresh()

Refreshes the task data

Source code in src/plankapy/interfaces.py
2654
2655
2656
2657
2658
2659
def refresh(self) -> None:
    """Refreshes the task data"""
    tasks = self.card.board.tasks
    for task in tasks:
        if task.id == self.id:
            self.__init__(**task)

update(*args, **kwargs)

update()
update(task: Task)
update(name: str = None, isCompleted: bool = None) -> Task

Updates the task with new values

Tip

If you want to update a task, it's better to use the editor() context manager

Example:

>>> with task.editor():
...    task.name = 'New Task Name'
...    task.isCompleted = True

>>> task
Task(id=1, name='New Task Name', isCompleted=True, ...)

Parameters:

Name Type Description Default
name str

Name of the task (optional)

required
isCompleted bool

Whether the task is completed (optional)

required

Alternate

Name Type Description Default
task Task

Task instance to update (required)

required
Note

If no arguments are provided, the task will update itself with the current values stored in its attributes

Returns:

Name Type Description
Task Task

Updated task instance

Source code in src/plankapy/interfaces.py
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
def update(self, *args, **kwargs) -> Task:
    """Updates the task with new values

    Tip:
        If you want to update a task, it's better to use the `editor()` context manager

        Example:
        ```python
        >>> with task.editor():
        ...    task.name = 'New Task Name'
        ...    task.isCompleted = True

        >>> task
        Task(id=1, name='New Task Name', isCompleted=True, ...)
        ```

    Args:
        name (str): Name of the task (optional)
        isCompleted (bool): Whether the task is completed (optional)

    Args: Alternate
        task (Task): Task instance to update (required)

    Note:
        If no arguments are provided, the task will update itself with the current values stored in its attributes

    Returns:
        Task: Updated task instance
    """
    overload = parse_overload(
        args, kwargs, 
        model='task', 
        options=('name', 'isCompleted'),
        noarg=self)

    route = self.routes.patch_task(id=self.id)
    self.__init__(**route(**overload)['item'])
    return self