On Mon, Jan 4, 2021 at 7:37 AM Tuukka Mustonen <tuukka.mustonen@gmail.com> wrote:
I believe I was suggested to post this here (instead of at https://github.com/python/mypy/issues/9867).

TLDR; Allow `Omittable[...]` annotation, to mark fields that may not exist. Current way of doing this, with `total=False`, is verbose and forces to break the natural grouping of data.

As I understand, `total=False` was discussed/added in https://github.com/python/mypy/issues/2632. There's not much debate about the syntax there - the examples/suggestions there are `MayExist[...]`, `NotRequired[...]`, `Checked[...]`, `OptionalItem[...]` or (the other way around) `Required[...]`. However, none of these were considered good enough, so `total=False` got chosen instead.

How about `Omittable[...]`? It's only +1 char to `Optional`, which would be perfect, but of course cannot be used here.

Longer explanation for why we should need this below, or view the https://github.com/python/mypy/issues/9867 which has Markdown formatting. Though, Guido already said that "There is not much disagreement on the problem".

I'm not crazy about Omittable, because it starts with the same letter as Optional and my poor eyesight is likely to confuse these. So here's a proposed bikeshed color:
```
class MyThing(TypedDict, total=False):
    req1: Required[int]
    opt1: str
    req2: Required[float]
```
In a TypedDict subclass with total=True, all fields are Required and Required is redundant.
 
--
--Guido van Rossum (python.org/~guido)