-
Notifications
You must be signed in to change notification settings - Fork 288
Clarifying appropriate use cases for Literal types in the guides #2149
-
While reading the typing guides, I noticed that Literal types are introduced,
but there isn’t much guidance on when they should or should not be used.
New users often try to apply Literal to dynamic values or user input,
which doesn’t provide useful guarantees and can lead to confusion
when using type checkers.
Would it be acceptable to add a short, non-normative note in the guides
clarifying appropriate use cases for Literal types?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
Which typing guides do you refer to specifically? In general, our documentation is very spotty, though, and we're missing a proper tutorial. Any PRs to improve the situation are welcome.
The Typing Python Libraries guide has a very brief section about literals, that could probably be extended, or point to general guidance in another document. Apart from that I mostly find references in the typing spec, which is not intended for end users.
Beta Was this translation helpful? Give feedback.