Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContextManager and AsyncContextManager protocols can't be subclassed #82189

Closed
jivid mannequin opened this issue Sep 2, 2019 · 5 comments
Closed

ContextManager and AsyncContextManager protocols can't be subclassed #82189

jivid mannequin opened this issue Sep 2, 2019 · 5 comments
Labels
3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@jivid
Copy link
Mannequin

jivid mannequin commented Sep 2, 2019

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']

    @jivid jivid mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes type-bug An unexpected behavior, bug, or error labels Sep 2, 2019
    @jivid
    Copy link
    Mannequin Author

    jivid mannequin commented Sep 2, 2019

    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.

    @jivid
    Copy link
    Mannequin Author

    jivid mannequin commented Sep 2, 2019

    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.

    @ilevkivskyi
    Copy link
    Member

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

    Great, thanks! Go ahead and try it.

    @ilevkivskyi
    Copy link
    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

    @miss-islington
    Copy link
    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

    @ilevkivskyi ilevkivskyi added stdlib Python modules in the Lib dir and removed 3.7 (EOL) end of life labels Sep 12, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants