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 — PEP 695: typing.TypeVar should be subclassable · Issue #104662 · python/cpython

PEP 695: typing.TypeVar should be subclassable #104662

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
PEP 695: typing.TypeVar should be subclassable#104662
Copy link
Assignees
JelleZijlstra
Labels
topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@JelleZijlstra
JelleZijlstra
opened on May 19, 2023
Issue body actions

Previously typing.TypeVar could be subclassed, and typing_extensions actually does this. However, the new C implementation of TypeVar doesn't allow subclassing. For compatibility, let's restore the ability to subclass it.

Reacted by Alex Waygood and Carl Meyer

Activity

  1. JelleZijlstra
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-typing
    on May 19, 2023
  2. JelleZijlstra
    self-assigned this
    on May 19, 2023
  3. JelleZijlstra commented on May 19, 2023

    @JelleZijlstra
    JelleZijlstra
    on May 19, 2023
    MemberAuthor
    More actions

    Looking more at the previous implementation, it wasn't actually subclassable normally, only if you passed the special _root=True argument to __init_subclass__:

    cpython/Lib/typing.py

    Line 397 in 702ce87

    def __init_subclass__(cls, /, *args, **kwds):

    That was an explicitly private API, so I don't think we need to preserve this behavior in C.

    Reacted by Alex Waygood
  4. JelleZijlstra commented on May 20, 2023

    @JelleZijlstra
    JelleZijlstra
    on May 20, 2023
    MemberAuthor
    More actions

    Alternative solution in python/typing_extensions#162.

  5. JelleZijlstra
    closed this as not plannedon May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @JelleZijlstra
    JelleZijlstra

Labels

topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

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.