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
Type hinting #2152
Conversation
There was a problem hiding this 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 namingto
telegram.utils.typingand same for
int`
elif isinstance(lang, List[str]): | ||
lang = cast(List[str], lang) | ||
self.lang = lang | ||
else: | ||
lang = cast(Tuple[str], lang) | ||
self.lang = lang |
There was a problem hiding this comment.
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
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) |
There was a problem hiding this comment.
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.
Fixes Issue #2125
A better type hinting to allow Tuples along with Lists wherever it can be used that way.