mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-03 17:52:31 +01:00
Fix documentation & coding style of User.name & User.full_name (#956)
- Use string `format` instead of dict comprehension. - Better documentation to signify the semantics difference between `name` and `full_name`. - Use string `format` instead of dict comprehension. - Better documentation to signify the semantics difference between `name` and `full_name`. * Removed the NOTE and mentinoed the "@" prefix.
This commit is contained in:
parent
0faa19726a
commit
a2c04313d3
1 changed files with 7 additions and 10 deletions
|
@ -72,26 +72,23 @@ class User(TelegramObject):
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""
|
"""
|
||||||
:obj:`str`: The users :attr:`username` if available, if not it returns the first name and
|
:obj:`str`: Convenience property. If available, returns the user's :attr:`username`
|
||||||
if present :attr:`first_name` and :attr:`last_name`.
|
prefixed with "@". If :attr:`username` is not available, returns :attr:`full_name`.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.username:
|
if self.username:
|
||||||
return '@%s' % self.username
|
return '@{}'.format(self.username)
|
||||||
if self.last_name:
|
return self.full_name
|
||||||
return '%s %s' % (self.first_name, self.last_name)
|
|
||||||
return self.first_name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def full_name(self):
|
def full_name(self):
|
||||||
"""
|
"""
|
||||||
:obj:`str`: The users :attr:`first_name` and if present :attr:`last_name`.
|
:obj:`str`: Convenience property. The user's :attr:`first_name`, followed by (if available)
|
||||||
|
:attr:`last_name`.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.last_name:
|
if self.last_name:
|
||||||
return '%s %s' % (self.first_name, self.last_name)
|
return '{} {}'.format(self.first_name, self.last_name)
|
||||||
return self.first_name
|
return self.first_name
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in a new issue