Skip to content

Commit

Permalink
Improved typing
Browse files Browse the repository at this point in the history
  • Loading branch information
MujyKun committed Jul 20, 2021
1 parent 8ba0d6e commit 202c04e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Weverse/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .artist import Artist
from .comment import Comment
from .artist import Artist
from .community import Community
from .notification import Notification
from .photo import Photo
Expand Down
8 changes: 7 additions & 1 deletion Weverse/models/artist.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from typing import Optional, TYPE_CHECKING

if TYPE_CHECKING:
from Weverse.models import Community


class Artist:
r"""An Artist object that represents a Weverse Artist that belongs in a community.
Expand Down Expand Up @@ -111,5 +117,5 @@ def __init__(self, **kwargs):
self.to_fan_last_created_at = kwargs.get('to_fan_last_created_at')
self.to_fan_last_expire_in = kwargs.get('to_fan_last_expire_in')
self.birthday_img_url = kwargs.get('birthday_img_url')
self.community = None
self.community: Optional[Community] = None
self.posts = []
7 changes: 6 additions & 1 deletion Weverse/models/comment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from typing import Optional, TYPE_CHECKING

if TYPE_CHECKING:
from Weverse.models import Post

class Comment:
r"""A Comment object that represents a Weverse Comment that belongs to an Artist.
Expand Down Expand Up @@ -60,4 +65,4 @@ def __init__(self, **kwargs):
self.post_id = kwargs.get('post_id')
self.created_at = kwargs.get('created_at')
self.updated_at = kwargs.get('updated_at')
self.post = None
self.post: Optional[Post] = None
10 changes: 8 additions & 2 deletions Weverse/models/community.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from typing import List, TYPE_CHECKING

if TYPE_CHECKING:
from Weverse.models import Artist, Tab


class Community:
r"""A Comment object that represents a Weverse Comment that belongs to an Artist.
Expand Down Expand Up @@ -67,6 +73,6 @@ def __init__(self, **kwargs):
self.full_name = kwargs.get('full_name')
self.fc_member = kwargs.get('fc_member')
self.show_member_count = kwargs.get('show_member_count')
self.artists = []
self.tabs = []
self.artists: List[Artist] = []
self.tabs: List[Tab] = []

8 changes: 7 additions & 1 deletion Weverse/models/photo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from typing import Optional, TYPE_CHECKING

if TYPE_CHECKING:
from Weverse.models import Post


class Photo:
r"""A Photo object that represents a Weverse Photo that belongs to media or a post.
Expand Down Expand Up @@ -63,5 +69,5 @@ def __init__(self, **kwargs):
self.original_img_width = kwargs.get('original_img_width')
self.original_img_height = kwargs.get('original_img_height')
self.file_name = kwargs.get('file_name')
self.post = None
self.post: Optional[Post] = None

8 changes: 7 additions & 1 deletion Weverse/models/video.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from typing import Optional, TYPE_CHECKING

if TYPE_CHECKING:
from Weverse.models import Post


class Video:
r"""A Video object that represents a Weverse Video that belongs to media or a post.
Expand Down Expand Up @@ -42,5 +48,5 @@ def __init__(self, **kwargs):
self.thumbnail_width = kwargs.get('thumbnail_width')
self.thumbnail_height = kwargs.get('thumbnail_height')
self.length = kwargs.get('length')
self.post = None
self.post: Optional[Post] = None

0 comments on commit 202c04e

Please sign in to comment.