Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
merged 2 commits into from
May 29, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
reword more
  • Loading branch information
JelleZijlstra committed May 25, 2025
commit 39dd3c5e3a033a98d98324872c3a1a0c84e951a1
15 changes: 10 additions & 5 deletions 15 docs/spec/literal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,23 @@ expressions, and nothing else.
Legal parameters for ``Literal`` at type check time
"""""""""""""""""""""""""""""""""""""""""""""""""""

``Literal`` may be parameterized with literal ints, strings, `bytes` objects,
bools, Enum values and ``None``. So for example, all of
``Literal`` may be parameterized with literal ``int``, ``str``, ``bytes``,
and ``bool`` objects, instances of ``enum.Enum`` subclasses, and ``None``. So for example, all of
the following would be legal::

Literal[26]
Literal[0x1A] # Exactly equivalent to Literal[26]
Literal[0x1A] # Equivalent to Literal[26]
Literal[-4]
Literal["hello world"]
Literal[u"hello world"] # Exactly equivalent to Literal["hello world"]
Literal[u"hello world"] # Equivalent to Literal["hello world"]
Literal[b"hello world"]
Literal[True]
Literal[Color.RED] # Assuming Color is some enum

class Color(enum.Enum):
RED = 1
GREEN = 2

Literal[Color.RED]
Literal[None]

**Note:** Since the type ``None`` is inhabited by just a single
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.