-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand tokenize stub to include Intnumber etc #3839
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
Conversation
JelleZijlstra
left a comment
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! Left a few comments
stdlib/3/tokenize.pyi
Outdated
| def compat(self, token: Sequence[Union[int, str]], iterable: Iterable[_Token]) -> None: ... | ||
|
|
||
| def untokenize(iterable: Iterable[_Token]) -> Any: ... | ||
| def untokenize(iterable: Iterable[_Token]) -> bytes: ... |
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.
I haven't tried but I think this returns a str if there is no ENCODING token in the input.
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.
You're right. I looked again; the docstring is wrong. Would you like this Union[str, bytes] instead of Any?
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.
Any is fine, we generally avoid Union return types.
|
PTAL |
|
There's a stubtest failure—apparently a couple of constants are dicts instead of sets in 3.5. |
The all uppercase tokens, as well as tok_name mentioned in the comment actually come from the `from token import *`.
These constants were removed in #3839 because they are imported from token. However, that is only true in Python 3.7+.
These constants were removed in #3839 because they are imported from token. However, that is only true in Python 3.7+.
These constants were removed in python#3839 because they are imported from token. However, that is only true in Python 3.7+.
The all uppercase tokens, as well as
tok_namementioned in the commentactually come from the
from token import *.The LibCST project uses constants like
Intnumberin its parsing, https://github.com/Instagram/LibCST/blob/master/libcst/_parser/conversions/expression.py