From 8d1a5736ba4dde376e3a91cfaea85db866209a10 Mon Sep 17 00:00:00 2001 From: Sean Breckenridge Date: Fri, 29 Oct 2021 12:06:46 -0700 Subject: [PATCH] add 'raw' properties to protocol members --- my/reddit/common.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/my/reddit/common.py b/my/reddit/common.py index 915455e..6cb4bd9 100644 --- a/my/reddit/common.py +++ b/my/reddit/common.py @@ -19,8 +19,29 @@ if TYPE_CHECKING: else: Protocol = object + +# common fields across all the Protocol classes, so generic code can be written +class RedditThing(Protocol): + @property + def raw(self) -> Json: ... + @property + def created(self) -> datetime_aware: ... + @property + def id(self) -> str: ... + @property + def url(self) -> str: ... + @property + def text(self) -> str: ... + + # Note: doesn't include GDPR Save's since they don't have the same metadata class Save(Protocol): + @property + def raw(self) -> Json: ... + @property + def created(self) -> datetime_aware: ... + @property + def id(self) -> str: ... @property def id(self) -> str: ... @property @@ -32,6 +53,8 @@ class Save(Protocol): # Note: doesn't include GDPR Upvote's since they don't have the same metadata class Upvote(Protocol): + @property + def raw(self) -> Json: ... @property def id(self) -> str: ... @property @@ -46,6 +69,8 @@ class Upvote(Protocol): # From rexport, pushshift and the reddit GDPR export class Comment(Protocol): + @property + def raw(self) -> Json: ... @property def id(self) -> str: ... @property @@ -58,6 +83,8 @@ class Comment(Protocol): # From rexport and the GDPR export class Submission(Protocol): + @property + def raw(self) -> Json: ... @property def id(self) -> str: ... @property