Skip to content

Conversation

@thatch
Copy link
Contributor

@thatch thatch commented Mar 10, 2020

The all uppercase tokens, as well as tok_name mentioned in the comment
actually come from the from token import *.

The LibCST project uses constants like Intnumber in its parsing, https://github.com/Instagram/LibCST/blob/master/libcst/_parser/conversions/expression.py

Copy link
Member

@JelleZijlstra JelleZijlstra left a 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

def compat(self, token: Sequence[Union[int, str]], iterable: Iterable[_Token]) -> None: ...

def untokenize(iterable: Iterable[_Token]) -> Any: ...
def untokenize(iterable: Iterable[_Token]) -> bytes: ...
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

@thatch
Copy link
Contributor Author

thatch commented Mar 11, 2020

PTAL

@JelleZijlstra
Copy link
Member

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 *`.
@JelleZijlstra JelleZijlstra merged commit 508fd84 into python:master Mar 11, 2020
rchen152 added a commit that referenced this pull request May 17, 2020
These constants were removed in
#3839 because they are imported
from token. However, that is only true in Python 3.7+.
JelleZijlstra pushed a commit that referenced this pull request May 18, 2020
These constants were removed in
#3839 because they are imported
from token. However, that is only true in Python 3.7+.
vishalkuo pushed a commit to vishalkuo/typeshed that referenced this pull request Jun 26, 2020
These constants were removed in
python#3839 because they are imported
from token. However, that is only true in Python 3.7+.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants