From 9b57cfd331a898c9fb01eacdc008f59dc4211d93 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 25 Nov 2020 10:44:49 -0800 Subject: [PATCH] Fixes default lists on activitypub dataclasses --- bookwyrm/activitypub/book.py | 2 +- bookwyrm/activitypub/note.py | 4 ++-- bookwyrm/activitypub/person.py | 2 +- bookwyrm/tests/data/ap_quotation.json | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bookwyrm/activitypub/book.py b/bookwyrm/activitypub/book.py index 60d36bd02..bdc30edd2 100644 --- a/bookwyrm/activitypub/book.py +++ b/bookwyrm/activitypub/book.py @@ -25,7 +25,7 @@ class Book(ActivityObject): librarything_key: str goodreads_key: str - attachment: List[Image] = field(default=lambda: []) + attachment: List[Image] = field(default_factory=lambda: []) type: str = 'Book' diff --git a/bookwyrm/activitypub/note.py b/bookwyrm/activitypub/note.py index ebc0cf3ce..9eab952d3 100644 --- a/bookwyrm/activitypub/note.py +++ b/bookwyrm/activitypub/note.py @@ -24,8 +24,8 @@ class Note(ActivityObject): cc: List[str] content: str replies: Dict - tag: List[Link] = field(default=lambda: []) - attachment: List[Image] = field(default=lambda: []) + tag: List[Link] = field(default_factory=lambda: []) + attachment: List[Image] = field(default_factory=lambda: []) sensitive: bool = False type: str = 'Note' diff --git a/bookwyrm/activitypub/person.py b/bookwyrm/activitypub/person.py index 118774a27..324d68e32 100644 --- a/bookwyrm/activitypub/person.py +++ b/bookwyrm/activitypub/person.py @@ -15,7 +15,7 @@ class Person(ActivityObject): summary: str publicKey: PublicKey endpoints: Dict - icon: Image = field(default=lambda: {}) + icon: Image = field(default_factory=lambda: {}) bookwyrmUser: bool = False manuallyApprovesFollowers: str = False discoverable: str = True diff --git a/bookwyrm/tests/data/ap_quotation.json b/bookwyrm/tests/data/ap_quotation.json index 5085547a6..089bc85fd 100644 --- a/bookwyrm/tests/data/ap_quotation.json +++ b/bookwyrm/tests/data/ap_quotation.json @@ -19,8 +19,8 @@ "mediaType": "image//images/covers/2b4e4712-5a4d-4ac1-9df4-634cc9c7aff3jpg", "url": "https://example.com/images/covers/2b4e4712-5a4d-4ac1-9df4-634cc9c7aff3jpg", "name": "Cover of \"This Is How You Lose the Time War\"" - } - ], + } + ], "replies": { "id": "https://example.com/user/mouse/quotation/13/replies", "type": "Collection",