Skip to content

Add name and full_name properties to the SharedUser class#4708

Closed
david-shiko wants to merge 1 commit intopython-telegram-bot:masterfrom
david-shiko:SharedUserProperties
Closed

Add name and full_name properties to the SharedUser class#4708
david-shiko wants to merge 1 commit intopython-telegram-bot:masterfrom
david-shiko:SharedUserProperties

Conversation

@david-shiko
Copy link
Contributor

P.S. I failed to update the documentation. Sphinx requires Python 3.12, but I intentionally use Python 3.10. The documentation states that Python 3.9+ is supported, as mentioned in the introduction section: python-telegram-bot Introduction.

Please review the PR, and if everything is okay, I will try to write the documentation.

@Bibo-Joshi
Copy link
Member

Hi. Thanks for the PR, nice idea 👍
Looking at the code base, I see that we already have the properties

  • User.name
  • User.full_name
  • Chat.full_name

and your PR basically copies User.name and Chat.full_name to SharedUser.
To avoid too much duplication, I would like you instead introduce a new module telegram._utils.usernames whith two function get_name and get_full_name. They would both accept a object of type

class UserLike(typing.Protocol):
    first_name: typing.Optional[str]
    last_name: typing.Optional[str]
    username: typing.Optional[str]

Would that be doable for you?

Note that you can copy the tests from test_chat/test_user. I'd like to avoid introducing unittest into our test suite b/c we use nowhere else.

@Bibo-Joshi Bibo-Joshi added the 🔌 enhancement pr description: enhancement label Mar 8, 2025
@Bibo-Joshi
Copy link
Member

Closing in favor of #4713

@Bibo-Joshi Bibo-Joshi closed this Mar 10, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🔌 enhancement pr description: enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants