← 输入框|github.com|刷新
Skip to content

ContextManager and AsyncContextManager protocols can't be subclassed #82189

Closed

Description

@jivid
mannequin
BPO 38008
Nosy @ilevkivskyi, @miss-islington, @jivid
PRs
  • bpo-38008: Move builtin protocol whitelist to mapping instead of list #15647
  • [3.8] bpo-38008: Move builtin protocol whitelist to mapping instead of list (GH-15647) #16021
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-09-12.11:59:49.588>
    created_at = <Date 2019-09-02.11:44:10.836>
    labels = ['3.8', 'type-bug', 'library', '3.9']
    title = "ContextManager and AsyncContextManager protocols can't be subclassed"
    updated_at = <Date 2019-09-12.11:59:49.587>
    user = 'https://github.com/jivid'

    bugs.python.org fields:

    activity = <Date 2019-09-12.11:59:49.587>
    actor = 'levkivskyi'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-09-12.11:59:49.588>
    closer = 'levkivskyi'
    components = ['Library (Lib)']
    creation = <Date 2019-09-02.11:44:10.836>
    creator = 'divijrajkumar'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38008
    keywords = ['patch']
    message_count = 5.0
    messages = ['350988', '350989', '351000', '352088', '352096']
    nosy_count = 3.0
    nosy_names = ['levkivskyi', 'miss-islington', 'divijrajkumar']
    pr_nums = ['15647', '16021']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38008'
    versions = ['Python 3.8', 'Python 3.9']

    Activity

    1. added
      3.7 (EOL)
      3.8 (EOL)
      3.9 (EOL)
      type-bug
      on Sep 2, 2019
    2. jivid commented on Sep 2, 2019

      jividmannequin
      MannequinAuthor

      Reported this initially on github - python/typing#650

      The problem is in the typing code that checks if any of the parent classes for a Protocol are builtin protocols. The code today maintains a whitelist of builtin protocols that are okay to be subclassed, but expects them all to live within the 'collections.abc' module. This means 'typing.ContextManager' and 'typing.AsyncContextManager' cannot be subclassed, even though those protocols are listing in the whitelist.

    3. jivid commented on Sep 2, 2019

      jividmannequin
      MannequinAuthor

      I'd like to take a stab at putting up a patch for this but I've never contributed anything to Python before, so I'll have a read through the contribution docs and put up a PR.

    4. ilevkivskyi commented on Sep 2, 2019

      @ilevkivskyi
      Member

      I'd like to take a stab at putting up a patch for this

      Great, thanks! Go ahead and try it.

    5. ilevkivskyi commented on Sep 12, 2019

      @ilevkivskyi
      Member

      New changeset 692a0dc by Ivan Levkivskyi (Divij Rajkumar) in branch 'master':
      bpo-38008: Move builtin protocol whitelist to mapping instead of list (GH-15647)
      692a0dc

    6. miss-islington commented on Sep 12, 2019

      @miss-islington
      Contributor

      New changeset 52baf90 by Miss Islington (bot) in branch '3.8':
      bpo-38008: Move builtin protocol whitelist to mapping instead of list (GH-15647)
      52baf90

    7. added
      stdlib
      and removed
      3.7 (EOL)
      on Sep 12, 2019
    8. transferred this issue fromon Apr 10, 2022
    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

      3.8 (EOL)3.9 (EOL)stdlibtype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions