-
Notifications
You must be signed in to change notification settings - Fork 292
spec: various minor changes #2013
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,16 +98,16 @@ expressions, and nothing else. | |
| Legal parameters for ``Literal`` at type check time | ||
| """"""""""""""""""""""""""""""""""""""""""""""""""" | ||
|
|
||
| ``Literal`` may be parameterized with literal ints, byte and unicode strings, | ||
| ``Literal`` may be parameterized with literal ints, strings, `bytes` objects, | ||
| bools, Enum values and ``None``. So for example, all of | ||
| the following would be legal:: | ||
|
|
||
| Literal[26] | ||
| Literal[0x1A] # Exactly equivalent to Literal[26] | ||
| Literal[-4] | ||
| Literal["hello world"] | ||
| Literal[u"hello world"] # Exactly equivalent to Literal["hello world"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommend deleting "Exactly" here. Including it might be confusing. (I'm not sure how equivalency could be inexact. :) )
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this for consistency with a few lines up, but I'll remove it there too. |
||
| Literal[b"hello world"] | ||
| Literal[u"hello world"] | ||
| Literal[True] | ||
| Literal[Color.RED] # Assuming Color is some enum | ||
| Literal[None] | ||
|
|
@@ -143,17 +143,6 @@ This should be exactly equivalent to the following type:: | |
|
|
||
| Literal[1, 2, 3, "foo", 5] | None | ||
|
|
||
| **Note:** String literal types like ``Literal["foo"]`` should subtype either | ||
| bytes or unicode in the same way regular string literals do at runtime. | ||
|
|
||
| For example, in Python 3, the type ``Literal["foo"]`` is equivalent to | ||
| ``Literal[u"foo"]``, since ``"foo"`` is equivalent to ``u"foo"`` in Python 3. | ||
|
|
||
| Similarly, in Python 2, the type ``Literal["foo"]`` is equivalent to | ||
| ``Literal[b"foo"]`` -- unless the file includes a | ||
| ``from __future__ import unicode_literals`` import, in which case it would be | ||
| equivalent to ``Literal[u"foo"]``. | ||
|
|
||
| Illegal parameters for ``Literal`` at type check time | ||
| """"""""""""""""""""""""""""""""""""""""""""""""""""" | ||
|
|
||
|
|
||
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.
For consistency, maybe use the class names for
int,str,bytes, andbool. With the proposed change, onlybytesuses the actual class name.Also, I think this requires double backticks.
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.
Done. Also ended up making the enum example more explicit.