Skip to content

Allow issubclass for protocols with class variables #822

Open

Description

@vnmabus

Currently issubclass cannot be used for runtime_checkable protocols with data members, because those attributes could be set in __init__. I propose to relax this restriction to allow protocols with ClassVar members, as those should be present in the class definition.

Activity

  1. gvanrossum commented on Jul 7, 2021

    @gvanrossum
    Member

    That looks reasonable. Could you submit a PR? Does this need changing in mypy too?

  2. vnmabus commented on Jul 7, 2021

    @vnmabus
    Author

    I do not think this needs to change in mypy, as the problem is using issubclass at runtime. I am also not familiar with the codebase, so I do not know how to made the PR.

  3. gvanrossum commented on Jul 7, 2021

    @gvanrossum
    Member

    Maybe a project for @Fidget-Spinner? This would be a new feature in 3.11.

  4. Fidget-Spinner commented on Jul 7, 2021

    @Fidget-Spinner
    Member

    Sure, I'll take a shot at this. Currently I'm a little busy with other things in CPython, so I might not be able to work on this immediately.

    We're not in a hurry (yet), 3.11's first alpha is in October 2021, and beta freeze in April 2022.

  5. uriyyo commented on Jul 30, 2021

    @uriyyo
    Member

    @gvanrossum @Fidget-Spinner I can help with this feature if you need help. I am familiar with typing module so I think it won't be a problem to implement this feature.

  6. Fidget-Spinner commented on Jul 30, 2021

    @Fidget-Spinner
    Member

    @uriyyo sorry, I'm working on this. I will tell you if I need any help.

  7. uriyyo commented on Jul 30, 2021

    @uriyyo
    Member

    @Fidget-Spinner Great, I am waiting to see your implementation)

  8. Fidget-Spinner commented on Aug 22, 2021

    @Fidget-Spinner
    Member

    PR for CPython is open at python/cpython#27883. Once that is merged, we can downstream it to typing_extensions.

  9. added
    topic: featureDiscussions about new features for Python's type annotations
    on Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: featureDiscussions about new features for Python's type annotations

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions