I think this is ready to be PEPped. Who wants to be the author? I can be sponsor.

Or perhaps you want to start with a prototype implementation? Some additions to typeshed, typing_extensions and typing are also needed, I can help with some pointers.

On Fri, Jan 29, 2021 at 04:05 Daniel Moisset <dfmoisset@gmail.com> wrote:
Ok, thanks for the detailed explanation. I stand corrected

On Thu, 28 Jan 2021, 03:44 Eric Traut, <eric@traut.com> wrote:
Adding a special type (`Missing`) to a union to indicate that a field is not required would be inconsistent with every other use of `Union`. It breaks the mental model users have for `Union`, and it would require type checkers to introduce a bunch of special-case logic in multiple places where unions are used. Please don't do this.

The proposed `Required` annotation is consistent with existing annotations like `Final`, so it will be familiar to users and will work nicely with existing type checker implementations.

I'll also note that `NoReturn` within a union makes no sense. The `NoReturn` type is semantically equivalent to an empty union. It should never appear within a union along with other types. Pyright contains special logic to remove it from a union if it is combined with other types.

-Eric

--
Eric Traut
Contributor to Pyright and Pylance
Microsoft Corp.
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: dfmoisset@gmail.com
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: guido@python.org
--
--Guido (mobile)