-
Notifications
You must be signed in to change notification settings - Fork 280
Add cross-references and clarifications to Literal type specification #2130
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
base: main
Are you sure you want to change the base?
Conversation
|
This PR is ready for review. |
|
Thank you for reviewing. |
|
Thanks for your time reviewing this. |
| type ``Literal[3]``, we are declaring that ``foo`` must be exactly equal | ||
| to ``3`` and no other value. | ||
|
|
||
| Example |
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.
This example looks like something that should go in the guides, not the spec.
| it’s safe to do things like ``foo + 5`` since ``foo`` inherits ``int``’s | ||
| ``__add__`` method. The resulting type of ``foo + 5`` is ``int``. | ||
|
|
||
| The specification does not mandate the level of precision required for such inference, and type checkers may choose to infer a more precise ``Literal`` result where possible. |
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.
In general, if the spec doesn't mandate behavior, it's assumed that type checkers are free to choose their own behavior, so I don't think this is necessary to state here.
| ## Repository Content | ||
|
|
||
| This GitHub repository is used for several things: | ||
| This GitHub repository serves multiple purposes related to Python's static type system: |
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.
I don't think this is a useful change.
This PR improves documentation clarity in the typing specification by:
No semantic or behavioral changes are intended.