Skip to content

Conversation

@u-harshitha007
Copy link

@u-harshitha007 u-harshitha007 commented Dec 12, 2025

This PR improves documentation clarity in the typing specification by:

  • Adding cross-references between related sections (e.g. Literal types and type aliases)
  • Clarifying how Literal arithmetic inference precision is handled
  • Making small wording and link fixes to aid reader understanding

No semantic or behavioral changes are intended.

@u-harshitha007
Copy link
Author

This PR is ready for review.

@u-harshitha007
Copy link
Author

Thank you for reviewing.
This PR adds a short introduction to improve clarity for readers.
Happy to revise anything if needed! 😊

@u-harshitha007 u-harshitha007 changed the title Add introductory description to typing specification index Add cross-references and clarifications to Literal type specification Dec 15, 2025
@u-harshitha007
Copy link
Author

Thanks for your time reviewing this.
I realize this PR may have grown broader than ideal.
I’m happy to split this into smaller, more focused PRs if preferred.
Please let me know how you’d like me to proceed.

type ``Literal[3]``, we are declaring that ``foo`` must be exactly equal
to ``3`` and no other value.

Example
Copy link
Collaborator

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.
Copy link
Collaborator

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:
Copy link
Collaborator

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.

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