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

No straightforward way to get repr of Optional #84569

Closed
Endilll mannequin opened this issue Apr 25, 2020 · 2 comments
Closed

No straightforward way to get repr of Optional #84569

Endilll mannequin opened this issue Apr 25, 2020 · 2 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Endilll
Copy link
Mannequin

Endilll mannequin commented Apr 25, 2020

BPO 40389
Nosy @gvanrossum, @Endilll
PRs
  • bpo-40389: Improve repr of typing.Optional #19714
  • 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 2020-04-30.01:07:41.786>
    created_at = <Date 2020-04-25.18:03:02.571>
    labels = ['type-bug', 'library', '3.9']
    title = 'No straightforward way to get repr of Optional'
    updated_at = <Date 2020-04-30.01:07:41.785>
    user = 'https://github.com/Endilll'

    bugs.python.org fields:

    activity = <Date 2020-04-30.01:07:41.785>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-04-30.01:07:41.786>
    closer = 'gvanrossum'
    components = ['Library (Lib)']
    creation = <Date 2020-04-25.18:03:02.571>
    creator = 'Endill'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40389
    keywords = ['patch']
    message_count = 2.0
    messages = ['367278', '367724']
    nosy_count = 2.0
    nosy_names = ['gvanrossum', 'Endill']
    pr_nums = ['19714']
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue40389'
    versions = ['Python 3.9']

    @Endilll
    Copy link
    Mannequin Author

    Endilll mannequin commented Apr 25, 2020

    When source code is not available, "typing.Union[T, NoneType]" is what autocompletion engines left with, if they don't have additional logic to cover this case. Which is noisy compared to typing.Optional[T].

    Usecase when source code is not available

    Consider the following: C++ library has C++ plugins, supplied by user. It provides Python wrappers for their functions, dynamically filling out their type annotations.

    @Endilll Endilll mannequin added 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 25, 2020
    @gvanrossum
    Copy link
    Member

    New changeset 138a9b9 by Vlad Serebrennikov in branch 'master':
    bpo-40389: Improve repr of typing.Optional (bpo-19714)
    138a9b9

    @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.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

    1 participant