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

Implement PEP 647 (User-Defined Type Guards) in typing.py #87932

Closed
Fidget-Spinner opened this issue Apr 7, 2021 · 6 comments
Closed

Implement PEP 647 (User-Defined Type Guards) in typing.py #87932

Fidget-Spinner opened this issue Apr 7, 2021 · 6 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir

Comments

@Fidget-Spinner
Copy link
Member

BPO 43766
Nosy @gvanrossum, @rhettinger, @Fidget-Spinner
PRs
  • bpo-43766: Implement PEP 647 (User-Defined Type Guards) in typing.py #25282
  • bpo-43766: Fix TypeGuard docs #25660
  • 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 2021-04-27.15:59:43.758>
    created_at = <Date 2021-04-07.14:27:50.266>
    labels = ['library', '3.10']
    title = 'Implement PEP 647 (User-Defined Type Guards) in typing.py'
    updated_at = <Date 2021-04-27.15:59:43.757>
    user = 'https://github.com/Fidget-Spinner'

    bugs.python.org fields:

    activity = <Date 2021-04-27.15:59:43.757>
    actor = 'kj'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-04-27.15:59:43.758>
    closer = 'kj'
    components = ['Library (Lib)']
    creation = <Date 2021-04-07.14:27:50.266>
    creator = 'kj'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43766
    keywords = ['patch']
    message_count = 6.0
    messages = ['390436', '390458', '390537', '392078', '392095', '392097']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'rhettinger', 'kj']
    pr_nums = ['25282', '25660']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue43766'
    versions = ['Python 3.10']

    @Fidget-Spinner
    Copy link
    Member Author

    PEP-647 was recently accepted by the SC:
    https://mail.python.org/archives/list/python-dev@python.org/thread/2ME6F6YUVKHOQYKSHTVQQU5WD4CVAZU4/

    I'd like to work on the implementation for typing.py and any required docs later on (unless someone is already working on it, then I hope you'd let me help too ;). Hopefully I can get it in before the 3.10 beta freeze.

    typing_extensions will need a port too, though that is much less urgent at the moment.

    @Fidget-Spinner Fidget-Spinner added 3.10 only security fixes stdlib Python modules in the Lib dir labels Apr 7, 2021
    @gvanrossum
    Copy link
    Member

    Go for it! I assume that this will be pretty simple, right? TypeGuard[X] should show up in __annotations__ as exactly that. It can be implemented in pure Python.

    @Fidget-Spinner
    Copy link
    Member Author

    I assume that this will be pretty simple, right?

    Yep! The PR speaks for itself ;). typing.py has pretty nice internal constructs to make these types of additions a breeze. I'm really grateful to whoever wrote/refactored the _SpecialForm decorator to what it is today.

    @gvanrossum
    Copy link
    Member

    New changeset 05ab4b6 by Ken Jin in branch 'master':
    bpo-43766: Implement PEP-647 (User-Defined Type Guards) in typing.py (bpo-25282)
    05ab4b6

    @gvanrossum
    Copy link
    Member

    New changeset 99fdd78 by Ken Jin in branch 'master':
    bpo-43766: Fix TypeGuard docs (bpo-25660)
    99fdd78

    @Fidget-Spinner
    Copy link
    Member Author

    Guido, thanks so much for reviewing the docs for TypeGuard so thoroughly even with how busy you are. I hope you enjoy your upcoming vacation :).

    I'm closing this issue as all PRs have landed. Please don't hesitate to re-open this if you feel something's amiss. Thanks!

    @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.10 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants