From 7da37819fbdf951aca7705294d5bf68719e6463e Mon Sep 17 00:00:00 2001 From: illya-laifu <110652325+illya-laifu@users.noreply.github.com> Date: Fri, 3 Jan 2025 19:57:51 +0200 Subject: [PATCH] feat: use stubtest to ensure that all public entites are documented (#32) --- taskchampion.pyi | 49 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/taskchampion.pyi b/taskchampion.pyi index edf8bfa..ba74f8f 100644 --- a/taskchampion.pyi +++ b/taskchampion.pyi @@ -1,7 +1,21 @@ from datetime import datetime from enum import Enum -from typing import Optional, Iterator +from typing import Optional, Iterator, final +__all__ = [ + "Replica", + "Operation", + "Operations", + "Status", + "TaskData", + "Task", + "WorkingSet", + "Annotation", + "Tag", + "DependencyMap", +] + +@final class Replica: @staticmethod def new_on_disk(path: str, create_if_missing: bool): ... @@ -10,10 +24,13 @@ class Replica: def create_task(self, uuid: str, ops: "Operations") -> "Task": ... def all_task_uuids(self) -> list[str]: ... def all_tasks(self) -> dict[str, "Task"]: ... + def all_task_data(self) -> dict[str, "TaskData"]: ... def working_set(self) -> "WorkingSet": ... def dependency_map(self, force: bool) -> "DependencyMap": ... def get_task(self, uuid: str) -> Optional["Task"]: ... - def import_task_with_uuid(self, uuid: str) -> "Task": ... + def get_undo_operations(self) -> Optional["Operations"]: ... + def get_task_data(self, uuid: str) -> Optional["TaskData"]: ... + def expire_tasks(self): ... def sync_to_local(self, server_dir: str, avoid_snapshots: bool): ... def sync_to_remote( self, url: str, client_id: str, encryption_secret: str, avoid_snapshots: bool @@ -29,8 +46,9 @@ class Replica: def num_local_operations(self) -> int: ... def num_undo_points(self) -> int: ... def commit_operations(self, ops: "Operations") -> None: ... - def commit_reversed_operations(self, ops: "Operations") -> None: ... + def commit_reversed_operations(self, operations: "Operations") -> None: ... +@final class Operation: @staticmethod def Create(uuid: str) -> "Operation": ... @@ -41,8 +59,8 @@ class Operation: uuid: str, property: str, timestamp: str, - old_value: Optional[str], - value: Optional[str], + old_value: Optional[str] = None, + value: Optional[str] = None, ) -> "Operation": ... @staticmethod def UndoPoint() -> "Operation": ... @@ -58,13 +76,13 @@ class Operation: old_value: Optional[str] value: Optional[str] +@final class Operations: def append(self, op: "Operation"): ... def __len__(self) -> int: ... - def __iter__(self) -> Iterator["Operation"]: ... - def __next__(self) -> "Operation": ... def __getitem__(self, i: int) -> "Operation": ... +@final class Status(Enum): Pending = 1 Completed = 2 @@ -72,6 +90,7 @@ class Status(Enum): Recurring = 4 Unknown = 5 +@final class TaskData: @staticmethod def create(uuid: str, ops: "Operations") -> "TaskData": ... @@ -80,11 +99,12 @@ class TaskData: def has(self, value: str) -> bool: ... def update(self, property: str, value: str, ops: "Operations"): ... def delete(self, ops: "Operations"): ... + def get_uuid(self) -> str: ... +@final class Task: def get_uuid(self) -> str: ... def get_status(self) -> "Status": ... - def get_taskmap(self) -> dict[str, str]: ... def get_entry(self) -> Optional[datetime]: ... def get_priority(self) -> str: ... def get_wait(self) -> Optional[datetime]: ... @@ -115,15 +135,17 @@ class Task: def add_tag(self, tag: "Tag", ops: "Operations"): ... def remove_tag(self, tag: "Tag", ops: "Operations"): ... def add_annotation(self, annotation: "Annotation", ops: "Operations"): ... - def remove_annotation(self, annotation: "Annotation", ops: "Operations"): ... + def remove_annotation(self, timestamp: str, ops: "Operations"): ... def set_due(self, due: Optional[datetime], ops: "Operations"): ... def set_uda(self, namespace: str, key: str, value: str, ops: "Operations"): ... def remove_uda(self, namespace: str, key: str, ops: "Operations"): ... def set_legacy_uda(self, key: str, value: str, ops: "Operations"): ... def remove_legacy_uda(self, key: str, ops: "Operations"): ... - def add_dependency(self, uuid: str, ops: "Operations"): ... - def remove_dependency(self, uuid: str, ops: "Operations"): ... + def add_dependency(self, dep: str, ops: "Operations"): ... + def remove_dependency(self, dep: str, ops: "Operations"): ... + def into_task_data(self) -> "TaskData": ... +@final class WorkingSet: def __len__(self) -> int: ... def largest_index(self) -> int: ... @@ -132,16 +154,19 @@ class WorkingSet: def by_uuid(self, uuid: str) -> Optional[int]: ... def __iter__(self) -> Iterator[tuple[int, str]]: ... +@final class Annotation: entry: datetime description: str - def __init__(self, entry: datetime, description: str) -> "Annotation": ... + def __init__(self, entry: datetime, description: str) -> None: ... +@final class DependencyMap: def dependencies(self, dep_of: str) -> list[str]: ... def dependents(self, dep_on: str) -> list[str]: ... +@final class Tag: def __init__(self, tag: str): ... def is_synthetic(self) -> bool: ...