Improve typing hints by alissonlauffer · Pull Request #537 · pyrogram/pyrogram · GitHub
Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Improve typing hints - #537

Merged
delivrance merged 5 commits into
pyrogram:masterfrom
alissonlauffer:typing-fixes
Dec 20, 2020
Merged

delivrance merged 5 commits into
pyrogram:masterfrom
alissonlauffer:typing-fixes

Conversation

@alissonlauffer

@alissonlauffer alissonlauffer commented Nov 14, 2020

Copy link
Copy Markdown
Contributor

Proposed changes

  • Change type1 or type2 to Union[type1, type2] because the first one is not a valid syntax for typing hints (though it does not give any SyntaxError).
  • Change Union[type1, None] to Optional[type1] as proposed in Improve typing hints #537 (review).

@KunoiSayami KunoiSayami left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Optional[X] may more intuitive than Union[X, None]
Reference: https://docs.python.org/3/library/typing.html#typing.Optional

Comment thread pyrogram/connection/connection.py Outdated
Comment thread pyrogram/connection/connection.py Outdated
Comment thread pyrogram/connection/transport/tcp/tcp_abridged.py Outdated
Comment thread pyrogram/connection/transport/tcp/tcp_abridged.py Outdated
Comment thread pyrogram/connection/transport/tcp/tcp_abridged_o.py Outdated
Comment thread pyrogram/connection/transport/tcp/tcp_intermediate_o.py Outdated
Comment thread pyrogram/types/messages_and_media/message_entity.py Outdated
Comment thread pyrogram/types/messages_and_media/message_entity.py Outdated
Comment thread pyrogram/types/user_and_chats/user.py Outdated
Comment thread pyrogram/types/user_and_chats/user.py Outdated
@alissonlauffer
alissonlauffer force-pushed the typing-fixes branch 2 times, most recently from ecc796c to a26e648 Compare November 29, 2020 22:26
@alissonlauffer
alissonlauffer force-pushed the typing-fixes branch 2 times, most recently from 36df8dc to e45fea1 Compare December 8, 2020 20:32
Comment thread pyrogram/filters.py Outdated
Comment thread pyrogram/filters.py Outdated
@delivrance
delivrance merged commit 1dc4df8 into pyrogram:master Dec 20, 2020
@alissonlauffer
alissonlauffer deleted the typing-fixes branch December 3, 2021 10:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants