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

Type hinting #2152

Closed
wants to merge 4 commits into from
Closed

Conversation

Pranjalya
Copy link
Contributor

Fixes Issue #2125
A better type hinting to allow Tuples along with Lists wherever it can be used that way.

Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I didn't go over in in detail, yet, but I have some more general remarks:

  • Please have a look at our contribution guide on how to run the tests locally
  • Please merge from master (so, we can see code coverage results here, see Switch Codecov to GH Action #2127)
  • Tuples should only be allowed where it really doesn't matter if it's a tuple or a list and for interal stuff we should stick to one. I saw some private methods (with leading underscore) changed, where that should be double checked (ignore this comment, if you already did that ;) )
  • I might be a good idea to add a custom type StrInput = Union[str, List[str], Tuple[str]] (or similar namingtotelegram.utils.typingand same forint`

Comment on lines +1594 to +1599
elif isinstance(lang, List[str]):
lang = cast(List[str], lang)
self.lang = lang
else:
lang = cast(Tuple[str], lang)
self.lang = lang
Copy link
Member

Choose a reason for hiding this comment

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

This change is responsible for the failing tests ;) Probably change it to something like

Suggested change
elif isinstance(lang, List[str]):
lang = cast(List[str], lang)
self.lang = lang
else:
lang = cast(Tuple[str], lang)
self.lang = lang
elif isinstance(lang, list):
self.lang = lang
else:
lang = cast(Tuple[str], lang)
self.lang = list(lang)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sorry. I did change that but I think it got stashed when I was fixing something. I'll do that right now.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants