logoalt Hacker News

dwatttttlast Wednesday at 8:41 AM1 replyview on HN

True, you could annotate 3 of the 4 literals in this without annotating the List, which is ambiguous. In the absence of an explicit annotation (because those are optional), type checkers are left to guess intent to determine whether you wanted a List[Any] or List[number | string], or whether you wanted a List[number] or List[string].


Replies

MangoToupelast Wednesday at 5:03 PM

Right. And the fact that python doesn't specify the semantics of its type annotations is a super interesting experiment.

Optimally, this will result in a democratic consensus of semantics.

Pessimistically, this will result in dialects of semantics that result in dialects of runtime languages as folks adopt type checkers.

show 1 reply