classification
Title: No straightforward way to get repr of Optional
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Endill, gvanrossum
Priority: normal Keywords: patch

Created on 2020-04-25 18:03 by Endill, last changed 2020-04-30 01:07 by gvanrossum. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19714 merged Endill, 2020-04-25 18:06
Messages (2)
msg367278 - (view) Author: Vladislav Serebrennikov (Endill) * Date: 2020-04-25 18:03
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.
msg367724 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-30 01:06
New changeset 138a9b9c2a394f30f222c23391f9515a7df9d809 by Vlad Serebrennikov in branch 'master':
bpo-40389: Improve repr of typing.Optional (#19714)
https://github.com/python/cpython/commit/138a9b9c2a394f30f222c23391f9515a7df9d809
History
Date User Action Args
2020-04-30 01:07:41gvanrossumsetstatus: open -> closed
stage: patch review -> resolved
2020-04-30 01:06:43gvanrossumsetnosy: + gvanrossum
messages: + msg367724
2020-04-25 18:06:40Endillsetkeywords: + patch
stage: patch review
pull_requests: + pull_request19036
2020-04-25 18:03:02Endillcreate