Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JelleZijlstra
Copy link
Member

  • Replace an incorrect use of "subtype" with "assignable"
  • Remove discussion of str/bytes Literal types that seems geared towards
    Python 2. Instead, say straightforwardly that strings (str objects) and
    bytes objects are supported.
  • Rewrite an example that relies on the int/float/complex special case.
    The example was correct but I think it's confusing to readers if we have
    examples unnecessarily rely on the special case. Instead, use example
    types with more straightforward behavior.

- Replace an incorrect use of "subtype" with "assignable"
- Remove discussion of str/bytes Literal types that seems geared towards
  Python 2. Instead, say straightforwardly that strings (str objects) and
  bytes objects are supported.
- Rewrite an example that relies on the int/float/complex special case.
  The example was correct but I think it's confusing to readers if we have
  examples unnecessarily rely on the special case. Instead, use example
  types with more straightforward behavior.
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"]
Copy link
Collaborator

Choose a reason for hiding this comment

The 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. :) )

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@@ -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,
Copy link
Collaborator

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, and bool. With the proposed change, only bytes uses the actual class name.

Also, I think this requires double backticks.

Copy link
Member Author

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.

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