-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add Profile.bio_links property #2197
base: upcoming/v4.12
Are you sure you want to change the base?
Conversation
@@ -936,6 +936,11 @@ def followers(self) -> int: | |||
def followees(self) -> int: | |||
return self._metadata('edge_follow', 'count') | |||
|
|||
@property | |||
def bio_links(self) -> List[str]: | |||
"""list of external links given in the bio""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add a versionadded
directive here, indicating it is new in version 4.12.
@@ -936,6 +936,11 @@ def followers(self) -> int: | |||
def followees(self) -> int: | |||
return self._metadata('edge_follow', 'count') | |||
|
|||
@property | |||
def bio_links(self) -> List[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the bio_links
structure provides much more than just the URLs, e.g. a title
property that might be interesting as well. I would prefer this method to also return the other information.
[
{
"title": "",
"url": "http://taylorswift.com",
"link_type": "external"
},
{
"title": "THE TORTURED POETS DEPARTMENT 🤍",
"url": "https://taylor.lnk.to/thetorturedpoetsdepartment",
"link_type": "external"
},
{
"title": "Taylor Swift | The Eras Tour concert film",
"url": "https://taylor.lnk.to/TSTheErasTourFilm",
"link_type": "external"
}
]
@property | ||
def bio_links(self) -> List[str]: | ||
"""list of external links given in the bio""" | ||
return [links['url'] for links in self._metadata('bio_links')] if self._metadata('bio_links') else [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand the purpose of if self._metadata('bio_links')
here. If it evaluates to false due to an empty list, the left-hand statement would iterate an empty list and return an empty list, without that it needs to be explicitly checked.
Resolves #2186