I don’t think that’s what the star in mypy,means. IIRC it has something to do with whether it is an inferred type.

On Sun, Feb 7, 2021 at 22:44 David Foster <davidfstr@gmail.com> wrote:
On 2/5/21 2:16 AM, Ran Benita via Typing-sig wrote:
> Hi David,
>
> First, I agree with Tukka that the `| Missing` (special vlaue) proposal should be discussed in the "Rejected Ideas" section, as it's one of the first alternatives that come to mind.
>
> I would also mention that a similar situation also can occur in regular classes (unlike, say, in Java) which currently cannot be represented with Python typing:
>
>      class C:
>          def __init__(self, set_it: bool) -> None:
>              if set_it:
>                  self.attr = 10
>
>      C(set_it=False).attr  # type checks with mypy, but crashes
>
> While this is bad code IMO, it does occur quite often in the wild (especially in pre-typing code). If there is ever a Python checker that aims for soundness, it would either have to reject this code (like Java etc. do, "possibly uninitialized variable") or it would need to represent it in the type system. And if it is to be represented in the type system, a `Required[..]` wouldn't work well, due to backward compatibility and obviously being the wrong default in terms of boilerplate.

I believe mypy currently represents the type of `C.attr` in the above
example as `int*` (vice `int`) which means "if it's defined then it's an
`int`". I don't think this interpretation is standardized by any PEP
I've read though. In particular not the original PEP 484 ("Type Hints").

--
David Foster | Seattle, WA, USA
Contributor to TypedDict support for mypy
_______________________________________________
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)