Skip to content
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

Open
wants to merge 1 commit into
base: upcoming/v4.12
Choose a base branch
from

Conversation

SayanthD
Copy link
Contributor

Resolves #2186

@aandergr aandergr changed the base branch from upcoming/v4.11 to upcoming/v4.12 March 18, 2024 07:18
@@ -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"""
Copy link
Member

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]:
Copy link
Member

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 []
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants