Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make client task notes consistent #72

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rtmilk"
version = "0.2.4"
version = "0.3.0"
description = "RTM API wrapper"
authors = ["Rehan Khwaja <[email protected]>"]
license = "MIT"
Expand Down Expand Up @@ -48,7 +48,7 @@ coverage xml

[tool.ruff]
line-length = 1000
ignore = ["A002", "A003", "ANN", "FBT003", "D", "DTZ", "EM", "ERA001", "FBT001", "FIX", "N802", "I", "N803", "N806", "N815", "PLR0913", "PT013", "PTH", "S101", "S311", "T20", "TCH", "TD", "TRY003", "W191"]
ignore = ["A002", "A003", "ANN", "FBT003", "D", "DTZ", "EM", "ERA001", "FBT001", "FIX", "G004", "N802", "I", "N803", "N806", "N815", "PLR0913", "PT013", "PTH", "S101", "S311", "T20", "TCH", "TD", "TRY003", "W191"]
select = ["ALL"]
target-version = "py39"

Expand Down
17 changes: 4 additions & 13 deletions src/rtmilk/_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

from datetime import date, datetime
from logging import getLogger
from typing import Generic, Optional, TypeVar, Union
from typing import Generic, TypeVar

from .api_sync import API
from .api_async import APIAsync
from .models import Note

_log = getLogger(__name__)
_T = TypeVar('_T')
Expand All @@ -27,17 +28,7 @@ def _LoadValue(self, value: _T):
def value(self) -> _T:
return self._value

class NotesProperty:
def __init__(self, task):
self._task = task
self._value = None

def _LoadValue(self, value: list[str]):
self._value = value

@property
def value(self) -> _T:
return self._value
class NotesProperty(_Property[list[Note]]):

def Add(self, title: str, text: str):
self._task._client.api.TasksNotesAdd(
Expand Down Expand Up @@ -105,7 +96,7 @@ async def SetAsync(self, value: bool):
taskseries_id=self._task._taskSeriesId,
task_id=self._task._taskId)

class DateProperty(_Property[Optional[Union[date, datetime]]]):
class DateProperty(_Property[date | datetime | None]):
def __init__(self, task, dateType):
super().__init__(task)
self._dateType = dateType
Expand Down
2 changes: 1 addition & 1 deletion src/rtmilk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _CreateFromTaskSeries(client, listId, taskSeries):
result.startDate._LoadValue(task0.start.date() if task0.start is not None else None) # None means no change
result.dueDate._LoadValue(task0.due.date() if task0.due is not None else None) # None means no change
result.complete._LoadValue(task0.completed is not None)
result.notes._LoadValue(taskSeries.notes)
result.notes._LoadValue([] if isinstance(taskSeries.notes, list) else taskSeries.notes.note)
result.createTime = taskSeries.created
result.modifiedTime = taskSeries.modified

Expand Down
6 changes: 3 additions & 3 deletions src/rtmilk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Task(BaseModel):
priority: PriorityEnum
start: EmptyStrToNone[datetime] | None

class NotesResponsePayload(BaseModel):
class Note(BaseModel):
id: str
created: datetime
modified: datetime
Expand All @@ -124,10 +124,10 @@ class Transaction(BaseModel):

class NotesResponse(OkStat):
transaction: Transaction
note: NotesResponsePayload
note: Note

class NotePayload(BaseModel):
note: list[NotesResponsePayload]
note: list[Note]

class Tags(BaseModel):
tag: list[str]
Expand Down
Loading