Quote type hints

Otherwise, sphinx completely butchers the documentation.
This commit is contained in:
Lonami Exo 2019-05-08 17:16:09 +02:00
parent c6691dc6a8
commit d92d989569
11 changed files with 74 additions and 74 deletions

View File

@ -252,7 +252,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
*, *,
password: str = None, password: str = None,
bot_token: str = None, bot_token: str = None,
phone_code_hash: str = None) -> types.User: phone_code_hash: str = None) -> 'types.User':
""" """
Logs in to Telegram to an existing user or bot account. Logs in to Telegram to an existing user or bot account.
@ -327,7 +327,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
last_name: str = '', last_name: str = '',
*, *,
phone: str = None, phone: str = None,
phone_code_hash: str = None) -> types.User: phone_code_hash: str = None) -> 'types.User':
""" """
Signs up to Telegram as a new user account. Signs up to Telegram as a new user account.
@ -406,7 +406,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
self: 'TelegramClient', self: 'TelegramClient',
phone: str, phone: str,
*, *,
force_sms: bool = False) -> types.auth.SentCode: force_sms: bool = False) -> 'types.auth.SentCode':
""" """
Sends the Telegram code needed to login to the given phone number. Sends the Telegram code needed to login to the given phone number.

View File

@ -11,11 +11,11 @@ if typing.TYPE_CHECKING:
class BotMethods(UserMethods): class BotMethods(UserMethods):
async def inline_query( async def inline_query(
self: 'TelegramClient', self: 'TelegramClient',
bot: hints.EntityLike, bot: 'hints.EntityLike',
query: str, query: str,
*, *,
offset: str = None, offset: str = None,
geo_point: types.GeoPoint = None) -> custom.InlineResults: geo_point: 'types.GeoPoint' = None) -> custom.InlineResults:
""" """
Makes an inline query to the specified bot (e.g. ``@vote New Poll``). Makes an inline query to the specified bot (e.g. ``@vote New Poll``).

View File

@ -11,8 +11,8 @@ if typing.TYPE_CHECKING:
class ButtonMethods(UpdateMethods): class ButtonMethods(UpdateMethods):
@staticmethod @staticmethod
def build_reply_markup( def build_reply_markup(
buttons: typing.Optional[hints.MarkupLike], buttons: 'typing.Optional[hints.MarkupLike]',
inline_only: bool = False) -> typing.Optional[types.TypeReplyMarkup]: inline_only: bool = False) -> 'typing.Optional[types.TypeReplyMarkup]':
""" """
Builds a :tl:`ReplyInlineMarkup` or :tl:`ReplyKeyboardMarkup` for Builds a :tl:`ReplyInlineMarkup` or :tl:`ReplyKeyboardMarkup` for
the given buttons. the given buttons.

View File

@ -280,11 +280,11 @@ class ChatMethods(UserMethods):
def iter_participants( def iter_participants(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
limit: float = None, limit: float = None,
*, *,
search: str = '', search: str = '',
filter: types.TypeChannelParticipantsFilter = None, filter: 'types.TypeChannelParticipantsFilter' = None,
aggressive: bool = False) -> _ParticipantsIter: aggressive: bool = False) -> _ParticipantsIter:
""" """
Iterator over the participants belonging to the specified chat. Iterator over the participants belonging to the specified chat.
@ -341,7 +341,7 @@ class ChatMethods(UserMethods):
async def get_participants( async def get_participants(
self: 'TelegramClient', self: 'TelegramClient',
*args, *args,
**kwargs) -> hints.TotalList: **kwargs) -> 'hints.TotalList':
""" """
Same as `iter_participants`, but returns a Same as `iter_participants`, but returns a
`TotalList <telethon.helpers.TotalList>` instead. `TotalList <telethon.helpers.TotalList>` instead.
@ -350,13 +350,13 @@ class ChatMethods(UserMethods):
def iter_admin_log( def iter_admin_log(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
limit: float = None, limit: float = None,
*, *,
max_id: int = 0, max_id: int = 0,
min_id: int = 0, min_id: int = 0,
search: str = None, search: str = None,
admins: hints.EntitiesLike = None, admins: 'hints.EntitiesLike' = None,
join: bool = None, join: bool = None,
leave: bool = None, leave: bool = None,
invite: bool = None, invite: bool = None,
@ -485,7 +485,7 @@ class ChatMethods(UserMethods):
async def get_admin_log( async def get_admin_log(
self: 'TelegramClient', self: 'TelegramClient',
*args, *args,
**kwargs) -> hints.TotalList: **kwargs) -> 'hints.TotalList':
""" """
Same as `iter_admin_log`, but returns a ``list`` instead. Same as `iter_admin_log`, but returns a ``list`` instead.
""" """
@ -493,11 +493,11 @@ class ChatMethods(UserMethods):
def action( def action(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
action: typing.Union[str, types.TypeSendMessageAction], action: 'typing.Union[str, types.TypeSendMessageAction]',
*, *,
delay: float = 4, delay: float = 4,
auto_cancel: bool = True) -> typing.Union[_ChatAction, typing.Coroutine]: auto_cancel: bool = True) -> 'typing.Union[_ChatAction, typing.Coroutine]':
""" """
Returns a context-manager object to represent a "chat action". Returns a context-manager object to represent a "chat action".

View File

@ -105,9 +105,9 @@ class DialogMethods(UserMethods):
self: 'TelegramClient', self: 'TelegramClient',
limit: float = None, limit: float = None,
*, *,
offset_date: hints.DateLike = None, offset_date: 'hints.DateLike' = None,
offset_id: int = 0, offset_id: int = 0,
offset_peer: hints.EntityLike = types.InputPeerEmpty(), offset_peer: 'hints.EntityLike' = types.InputPeerEmpty(),
ignore_migrated: bool = False ignore_migrated: bool = False
) -> _DialogsIter: ) -> _DialogsIter:
""" """
@ -148,7 +148,7 @@ class DialogMethods(UserMethods):
ignore_migrated=ignore_migrated ignore_migrated=ignore_migrated
) )
async def get_dialogs(self: 'TelegramClient', *args, **kwargs) -> hints.TotalList: async def get_dialogs(self: 'TelegramClient', *args, **kwargs) -> 'hints.TotalList':
""" """
Same as `iter_dialogs`, but returns a Same as `iter_dialogs`, but returns a
`TotalList <telethon.helpers.TotalList>` instead. `TotalList <telethon.helpers.TotalList>` instead.
@ -167,7 +167,7 @@ class DialogMethods(UserMethods):
# TODO Passing a limit here makes no sense # TODO Passing a limit here makes no sense
return _DraftsIter(self, None) return _DraftsIter(self, None)
async def get_drafts(self: 'TelegramClient') -> hints.TotalList: async def get_drafts(self: 'TelegramClient') -> 'hints.TotalList':
""" """
Same as :meth:`iter_drafts`, but returns a list instead. Same as :meth:`iter_drafts`, but returns a list instead.
""" """
@ -175,7 +175,7 @@ class DialogMethods(UserMethods):
def conversation( def conversation(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
*, *,
timeout: float = 60, timeout: float = 60,
total_timeout: float = None, total_timeout: float = None,

View File

@ -23,8 +23,8 @@ class DownloadMethods(UserMethods):
async def download_profile_photo( async def download_profile_photo(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
file: hints.FileLike = None, file: 'hints.FileLike' = None,
*, *,
download_big: bool = True) -> typing.Optional[str]: download_big: bool = True) -> typing.Optional[str]:
""" """
@ -128,11 +128,11 @@ class DownloadMethods(UserMethods):
async def download_media( async def download_media(
self: 'TelegramClient', self: 'TelegramClient',
message: hints.MessageLike, message: 'hints.MessageLike',
file: hints.FileLike = None, file: 'hints.FileLike' = None,
*, *,
thumb: hints.FileLike = None, thumb: 'hints.FileLike' = None,
progress_callback: hints.ProgressCallback = None) -> typing.Optional[str]: progress_callback: 'hints.ProgressCallback' = None) -> typing.Optional[str]:
""" """
Downloads the given media from a message object. Downloads the given media from a message object.
@ -208,12 +208,12 @@ class DownloadMethods(UserMethods):
async def download_file( async def download_file(
self: 'TelegramClient', self: 'TelegramClient',
input_location: hints.FileLike, input_location: 'hints.FileLike',
file: hints.OutFileLike = None, file: 'hints.OutFileLike' = None,
*, *,
part_size_kb: float = None, part_size_kb: float = None,
file_size: int = None, file_size: int = None,
progress_callback: hints.ProgressCallback = None, progress_callback: 'hints.ProgressCallback' = None,
dc_id: int = None) -> None: dc_id: int = None) -> None:
""" """
Low-level method to download files from their input location. Low-level method to download files from their input location.

View File

@ -298,21 +298,21 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
def iter_messages( def iter_messages(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
limit: float = None, limit: float = None,
*, *,
offset_date: hints.DateLike = None, offset_date: 'hints.DateLike' = None,
offset_id: int = 0, offset_id: int = 0,
max_id: int = 0, max_id: int = 0,
min_id: int = 0, min_id: int = 0,
add_offset: int = 0, add_offset: int = 0,
search: str = None, search: str = None,
filter: typing.Union[types.TypeMessagesFilter, typing.Type[types.TypeMessagesFilter]] = None, filter: 'typing.Union[types.TypeMessagesFilter, typing.Type[types.TypeMessagesFilter]]' = None,
from_user: hints.EntityLike = None, from_user: 'hints.EntityLike' = None,
wait_time: float = None, wait_time: float = None,
ids: typing.Union[int, typing.Sequence[int]] = None, ids: 'typing.Union[int, typing.Sequence[int]]' = None,
reverse: bool = False reverse: bool = False
) -> typing.Union[_MessagesIter, _IDsIter]: ) -> 'typing.Union[_MessagesIter, _IDsIter]':
""" """
Iterator over the messages for the given chat. Iterator over the messages for the given chat.
@ -434,7 +434,7 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
search=search search=search
) )
async def get_messages(self: 'TelegramClient', *args, **kwargs) -> hints.TotalList: async def get_messages(self: 'TelegramClient', *args, **kwargs) -> 'hints.TotalList':
""" """
Same as `iter_messages`, but returns a Same as `iter_messages`, but returns a
`TotalList <telethon.helpers.TotalList>` instead. `TotalList <telethon.helpers.TotalList>` instead.
@ -475,17 +475,17 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
async def send_message( async def send_message(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
message: hints.MessageLike = '', message: 'hints.MessageLike' = '',
*, *,
reply_to: typing.Union[int, types.Message] = None, reply_to: 'typing.Union[int, types.Message]' = None,
parse_mode: typing.Optional[str] = (), parse_mode: typing.Optional[str] = (),
link_preview: bool = True, link_preview: bool = True,
file: hints.FileLike = None, file: 'hints.FileLike' = None,
force_document: bool = False, force_document: bool = False,
clear_draft: bool = False, clear_draft: bool = False,
buttons: hints.MarkupLike = None, buttons: 'hints.MarkupLike' = None,
silent: bool = None) -> types.Message: silent: bool = None) -> 'types.Message':
""" """
Sends a message to the specified user, chat or channel. Sends a message to the specified user, chat or channel.
@ -636,12 +636,12 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
async def forward_messages( async def forward_messages(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
messages: typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]], messages: 'typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]]',
from_peer: hints.EntityLike = None, from_peer: 'hints.EntityLike' = None,
*, *,
silent: bool = None, silent: bool = None,
as_album: bool = None) -> typing.Sequence[types.Message]: as_album: bool = None) -> 'typing.Sequence[types.Message]':
""" """
Forwards the given messages to the specified entity. Forwards the given messages to the specified entity.
@ -755,14 +755,14 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
async def edit_message( async def edit_message(
self: 'TelegramClient', self: 'TelegramClient',
entity: typing.Union[hints.EntityLike, types.Message], entity: 'typing.Union[hints.EntityLike, types.Message]',
message: hints.MessageLike = None, message: 'hints.MessageLike' = None,
text: str = None, text: str = None,
*, *,
parse_mode: str = (), parse_mode: str = (),
link_preview: bool = True, link_preview: bool = True,
file: hints.FileLike = None, file: 'hints.FileLike' = None,
buttons: hints.MarkupLike = None) -> types.Message: buttons: 'hints.MarkupLike' = None) -> 'types.Message':
""" """
Edits the given message to change its text or media. Edits the given message to change its text or media.
@ -867,10 +867,10 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
async def delete_messages( async def delete_messages(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
message_ids: typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]], message_ids: 'typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]]',
*, *,
revoke: bool = True) -> typing.Sequence[types.messages.AffectedMessages]: revoke: bool = True) -> 'typing.Sequence[types.messages.AffectedMessages]':
""" """
Deletes the given messages, optionally "for everyone". Deletes the given messages, optionally "for everyone".
@ -924,8 +924,8 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
async def send_read_acknowledge( async def send_read_acknowledge(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
message: typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]] = None, message: 'typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]]' = None,
*, *,
max_id: int = None, max_id: int = None,
clear_mentions: bool = False) -> bool: clear_mentions: bool = False) -> bool:

View File

@ -164,17 +164,17 @@ class TelegramBaseClient(abc.ABC):
def __init__( def __init__(
self: 'TelegramClient', self: 'TelegramClient',
session: typing.Union[str, Session], session: 'typing.Union[str, Session]',
api_id: int, api_id: int,
api_hash: str, api_hash: str,
*, *,
connection: typing.Type[Connection] = ConnectionTcpFull, connection: 'typing.Type[Connection]' = ConnectionTcpFull,
use_ipv6: bool = False, use_ipv6: bool = False,
proxy: typing.Union[tuple, dict] = None, proxy: typing.Union[tuple, dict] = None,
timeout: int = 10, timeout: int = 10,
request_retries: int = 5, request_retries: int = 5,
connection_retries: int =5, connection_retries: int =5,
retry_delay: int =1, retry_delay: int = 1,
auto_reconnect: bool = True, auto_reconnect: bool = True,
sequential_updates: bool = False, sequential_updates: bool = False,
flood_sleep_threshold: int = 60, flood_sleep_threshold: int = 60,

View File

@ -137,7 +137,7 @@ class UpdateMethods(UserMethods):
return found return found
def list_event_handlers(self: 'TelegramClient')\ def list_event_handlers(self: 'TelegramClient')\
-> typing.Sequence[typing.Tuple[callable, EventBuilder]]: -> 'typing.Sequence[typing.Tuple[callable, EventBuilder]]':
""" """
Lists all registered event handlers. Lists all registered event handlers.

View File

@ -89,23 +89,23 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
async def send_file( async def send_file(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntityLike, entity: 'hints.EntityLike',
file: hints.FileLike, file: 'hints.FileLike',
*, *,
caption: str = None, caption: str = None,
force_document: bool = False, force_document: bool = False,
progress_callback: hints.ProgressCallback = None, progress_callback: 'hints.ProgressCallback' = None,
reply_to: hints.MessageIDLike = None, reply_to: 'hints.MessageIDLike' = None,
attributes: typing.Sequence[types.TypeDocumentAttribute] = None, attributes: 'typing.Sequence[types.TypeDocumentAttribute]' = None,
thumb: hints.FileLike = None, thumb: 'hints.FileLike' = None,
allow_cache: bool = True, allow_cache: bool = True,
parse_mode: str = (), parse_mode: str = (),
voice_note: bool = False, voice_note: bool = False,
video_note: bool = False, video_note: bool = False,
buttons: hints.MarkupLike = None, buttons: 'hints.MarkupLike' = None,
silent: bool = None, silent: bool = None,
supports_streaming: bool = False, supports_streaming: bool = False,
**kwargs) -> types.Message: **kwargs) -> 'types.Message':
""" """
Sends message with the given file to the specified entity. Sends message with the given file to the specified entity.
@ -379,12 +379,12 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
async def upload_file( async def upload_file(
self: 'TelegramClient', self: 'TelegramClient',
file: hints.FileLike, file: 'hints.FileLike',
*, *,
part_size_kb: float = None, part_size_kb: float = None,
file_name: str = None, file_name: str = None,
use_cache: type = None, use_cache: type = None,
progress_callback: hints.ProgressCallback = None) -> types.TypeInputFile: progress_callback: 'hints.ProgressCallback' = None) -> 'types.TypeInputFile':
""" """
Uploads a file to Telegram's servers, without sending it. Uploads a file to Telegram's servers, without sending it.

View File

@ -102,7 +102,7 @@ class UserMethods(TelegramBaseClient):
# region Public methods # region Public methods
async def get_me(self: 'TelegramClient', input_peer: bool = False) \ async def get_me(self: 'TelegramClient', input_peer: bool = False) \
-> typing.Union[types.User, types.InputPeerUser]: -> 'typing.Union[types.User, types.InputPeerUser]':
""" """
Gets "me", the current :tl:`User` who is logged in. Gets "me", the current :tl:`User` who is logged in.
@ -159,7 +159,7 @@ class UserMethods(TelegramBaseClient):
async def get_entity( async def get_entity(
self: 'TelegramClient', self: 'TelegramClient',
entity: hints.EntitiesLike) -> hints.Entity: entity: 'hints.EntitiesLike') -> 'hints.Entity':
""" """
Turns the given entity into a valid Telegram :tl:`User`, :tl:`Chat` Turns the given entity into a valid Telegram :tl:`User`, :tl:`Chat`
or :tl:`Channel`. You can also pass a list or iterable of entities, or :tl:`Channel`. You can also pass a list or iterable of entities,
@ -253,7 +253,7 @@ class UserMethods(TelegramBaseClient):
async def get_input_entity( async def get_input_entity(
self: 'TelegramClient', self: 'TelegramClient',
peer: hints.EntityLike) -> types.TypeInputPeer: peer: 'hints.EntityLike') -> 'types.TypeInputPeer':
""" """
Turns the given entity into its input entity version. Turns the given entity into its input entity version.
@ -380,7 +380,7 @@ class UserMethods(TelegramBaseClient):
async def get_peer_id( async def get_peer_id(
self: 'TelegramClient', self: 'TelegramClient',
peer: hints.EntityLike, peer: 'hints.EntityLike',
add_mark: bool = True) -> int: add_mark: bool = True) -> int:
""" """
Gets the ID for the given entity. Gets the ID for the given entity.