GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Document PEP 695 · Issue #103921 · python/cpython

Document PEP 695 #103921

New issue
Copy link
New issue
Copy link
Closed
Closed
Document PEP 695#103921
Copy link
Assignees
JelleZijlstra
Labels
3.12only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirtopic-typing

Description

@JelleZijlstra
JelleZijlstra
opened on Apr 27, 2023
Issue body actions

We should document PEP-695 for Python 3.12 (issue #103763, PR #103764 for implementation). I am leaving docs out of the PR to avoid complicating an already huge PR with a tight deadline, but let's start thinking about what we need to document:

  • New AST nodes in ast.rst
  • Language reference should be updated to include the new grammar changes
  • Language reference should be updated to reflect new scoping rules (https://docs.python.org/3.12/reference/executionmodel.html#naming-and-binding)
  • typing.rst should list the PEP
  • typing.rst should mention that TypeVar gained an infer_variance argument and that it now supports lazily evaluated bounds/constraints
  • Examples of generics in typing.rst should use the new syntax
  • typing.rst should document the new TypeAliasType
  • typing.TypeAlias should be mentioned as deprecated (including in the deprecation timeline at the bottom of typing.rst), and any examples of type aliases should be updated to use the new syntax
  • New opcodes need to be mentioned in dis.rst. dis.dis docs should mention new contexts where nested code objects can appear. The CALL_INTRINSIC_1 and 2 opcodes should mention the new intrinsics.

Linked PRs

  • gh-103921: Document PEP 695 #104642
  • gh-103921: Rename "type" header in argparse docs #104654
  • [3.12] gh-103921: Document PEP 695 (GH-104642) #104989
  • [3.11] gh-103921: Improve typing documentation (GH-104642) #105007
  • gh-103921: Minor PEP-695 fixes to the ast module docs #105093
  • [3.12] gh-103921: Minor PEP-695 fixes to the ast module docs (GH-105093) #105101

Activity

  1. JelleZijlstra
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    topic-typing
    3.12only security fixesonly security fixes
    on Apr 27, 2023
  2. JelleZijlstra
    self-assigned this
    on Apr 27, 2023
  3. Fidget-Spinner commented on Apr 27, 2023

    @Fidget-Spinner
    Fidget-Spinner
    on Apr 27, 2023
    Member
    More actions

    Ideally we should also add the new builtin types to the list of stdtypes https://docs.python.org/3/library/stdtypes.html#type-annotation-types-generic-alias-union

    IMO, they ought to belong there instead of typing.rst as typing.rst is for the stdlib module.

    Reacted by Alex Waygood
  4. AlexWaygood commented on Apr 27, 2023

    @AlexWaygood
    AlexWaygood
    on Apr 27, 2023
    Member
    More actions
    • Examples of generics in typing.rst should use the new syntax

    I agree that we should make sure that PEP 695 is presented as the idiomatic, modern way of writing generic functions and classes. But I'd like us to make sure that the old-style way of doing things also continues to be well documented in typing.rst, with plenty of examples. Many projects will continue to use the old way of defining generics for a long time after the release of Python 3.12, so that they'll be able to continue supporting older versions of Python. Unlike most other typing features, it will be impossible for us to backport most of PEP 695 to typing_extensions — we can't backport a syntax change.

  5. JelleZijlstra
    added a commit that references this issue on May 19, 2023

    pythongh-103921: Rename "type" header in argparse docs

    6dae39a
  6. JelleZijlstra commented on May 19, 2023

    @JelleZijlstra
    JelleZijlstra
    on May 19, 2023
    MemberAuthor
    More actions

    Ideally we should also add the new builtin types to the list of stdtypes https://docs.python.org/3/library/stdtypes.html#type-annotation-types-generic-alias-union

    IMO, they ought to belong there instead of typing.rst as typing.rst is for the stdlib module.

    I'm not sure about this. The types still claim that their __module__ is typing, and they are accessible as e.g. typing.TypeVar. I feel they'd be more discoverable in the typing docs than the stdtypes page.

  7. JelleZijlstra
    added a commit that references this issue on May 19, 2023

    gh-103921: Rename "type" header in argparse docs (#104654)

    ab8f546
  8. AlexWaygood commented on May 19, 2023

    @AlexWaygood
    AlexWaygood
    on May 19, 2023
    Member
    More actions

    I agree with @Fidget-Spinner. types.GenericAlias and types.UnionType both claim that their module is types, but we only have "stub entries" for them in types.rst; the extensive documentation for these classes is in stdtypes.rst:

    >>> type(list[int]).__module__
    'types'
    >>> type(int | str).__module__
    'types'

    Builtin types that have dedicated syntax should all be documented in the same place (stdtypes.rst).

  9. JelleZijlstra commented on May 19, 2023

    @JelleZijlstra
    JelleZijlstra
    on May 19, 2023
    MemberAuthor
    More actions

    I know, and I don't really like how the docs for GenericAlias and UnionType are organized; they'd probably also be cleaner if more of the docs were under types.

    As a contrary example, types.ModuleType documents its attributes at https://docs.python.org/3.10/library/types.html#types.ModuleType, even though it claims its module is __builtins__.

    Concrete problems I see with documenting these types in stdtypes:

    • What would we put in typing.rst about them? We'll need to put some reference to the stdtypes description.
    • It's going to be natural to refer to e.g. :class:typing.TypeVar elsewhere in the docs, but that would link to a stub description in the typing docs.

    My preference would be to keep the main documentation for TypeVar etc. in typing.rst, but add a note about them to https://docs.python.org/3.10/library/stdtypes.html#type-annotation-types-generic-alias-union.

  10. AlexWaygood commented on May 19, 2023

    @AlexWaygood
    AlexWaygood
    on May 19, 2023
    Member
    More actions

    I know, and I don't really like how the docs for GenericAlias and UnionType are organized; they'd probably also be cleaner if more of the docs were under types.

    Fair enough, I've also thought this in the past.

    I see the point about not wanting to break all cross-references to TypeVar, ParamSpec, etc. -- it makes sense to leave those where they are. TypeAliasType still feels like it belongs next to the docs for UnionType and GenericAlias, to me. But, I agree that there's not perfect solution, and don't have a hugely strong opinion.

  11. carljm
    added a commit that references this issue on May 20, 2023

    Merge branch 'main' into gsallam/main

    ea5965a
  12. JelleZijlstra
    added a commit that references this issue on May 26, 2023

    gh-103921: Document PEP 695 (#104642)

    060277d
  13. miss-islington
    added a commit that references this issue on May 26, 2023

    pythongh-103921: Document PEP 695 (pythonGH-104642)

    8fd4ab8
  14. JelleZijlstra
    added a commit that references this issue on May 26, 2023

    [3.12] gh-103921: Document PEP 695 (GH-104642) (#104989)

    dcee0aa
  15. AlexWaygood commented on May 26, 2023

    @AlexWaygood
    AlexWaygood
    on May 26, 2023
    Member
    More actions

    I think we're done here!

    Reacted by Hugo van Kemenade
  16. AlexWaygood
    closed this as completedon May 26, 2023
  17. JelleZijlstra
    added 3 commits that reference this issue on May 27, 2023

    [3.11] pythongh-103921: Document PEP 695 (pythonGH-104642)

    0428d38

    [3.11] gh-103921: Improve typing documentation (GH-104642) (#105007)

    d34e58a

    gh-103921: Minor PEP-695 fixes to the `ast` module docs (#105093)

    c8c1e73
  18. miss-islington
    added a commit that references this issue on May 30, 2023

    pythongh-103921: Minor PEP-695 fixes to the `ast` module docs (python…

    9f193f3
  19. JelleZijlstra
    added a commit that references this issue on May 30, 2023

    [3.12] gh-103921: Minor PEP-695 fixes to the `ast` module docs (GH-10…

    9fb7abb
  20. carljm
    added a commit that references this issue on May 30, 2023

    Merge branch 'main' into superbadgetattro

    24e1159
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @JelleZijlstra
    JelleZijlstra

Labels

3.12only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirtopic-typing

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.