multiple inheritance to make protocols work
This commit is contained in:
parent
39828d07c5
commit
53e3099e08
1 changed files with 5 additions and 46 deletions
|
@ -21,8 +21,6 @@ else:
|
||||||
|
|
||||||
|
|
||||||
# common fields across all the Protocol classes, so generic code can be written
|
# common fields across all the Protocol classes, so generic code can be written
|
||||||
# doesnt seem we can subclass this to the other Protocols though sadly, see
|
|
||||||
# https://www.python.org/dev/peps/pep-0544/#toc-entry-28
|
|
||||||
class RedditBase(Protocol):
|
class RedditBase(Protocol):
|
||||||
@property
|
@property
|
||||||
def raw(self) -> Json: ...
|
def raw(self) -> Json: ...
|
||||||
|
@ -37,62 +35,23 @@ class RedditBase(Protocol):
|
||||||
|
|
||||||
|
|
||||||
# Note: doesn't include GDPR Save's since they don't have the same metadata
|
# Note: doesn't include GDPR Save's since they don't have the same metadata
|
||||||
class Save(Protocol):
|
class Save(Protocol, RedditBase):
|
||||||
@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: ...
|
|
||||||
@property
|
@property
|
||||||
def subreddit(self) -> str: ...
|
def subreddit(self) -> str: ...
|
||||||
|
|
||||||
# Note: doesn't include GDPR Upvote's since they don't have the same metadata
|
# Note: doesn't include GDPR Upvote's since they don't have the same metadata
|
||||||
class Upvote(Protocol):
|
class Upvote(Protocol, RedditBase):
|
||||||
@property
|
|
||||||
def raw(self) -> Json: ...
|
|
||||||
@property
|
|
||||||
def id(self) -> str: ...
|
|
||||||
@property
|
|
||||||
def created(self) -> datetime_aware: ...
|
|
||||||
@property
|
|
||||||
def url(self) -> str: ...
|
|
||||||
@property
|
|
||||||
def text(self) -> str: ...
|
|
||||||
@property
|
@property
|
||||||
def title(self) -> str: ...
|
def title(self) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
# From rexport, pushshift and the reddit GDPR export
|
# From rexport, pushshift and the reddit GDPR export
|
||||||
class Comment(Protocol):
|
class Comment(Protocol, RedditBase):
|
||||||
@property
|
pass
|
||||||
def raw(self) -> Json: ...
|
|
||||||
@property
|
|
||||||
def id(self) -> str: ...
|
|
||||||
@property
|
|
||||||
def created(self) -> datetime_aware: ...
|
|
||||||
@property
|
|
||||||
def url(self) -> str: ...
|
|
||||||
@property
|
|
||||||
def text(self) -> str: ...
|
|
||||||
|
|
||||||
|
|
||||||
# From rexport and the GDPR export
|
# From rexport and the GDPR export
|
||||||
class Submission(Protocol):
|
class Submission(Protocol, RedditBase):
|
||||||
@property
|
|
||||||
def raw(self) -> Json: ...
|
|
||||||
@property
|
|
||||||
def id(self) -> str: ...
|
|
||||||
@property
|
|
||||||
def created(self) -> datetime_aware: ...
|
|
||||||
@property
|
|
||||||
def url(self) -> str: ...
|
|
||||||
@property
|
|
||||||
def text(self) -> str: ...
|
|
||||||
@property
|
@property
|
||||||
def title(self) -> str: ...
|
def title(self) -> str: ...
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue