Implicit tuple return type

I don’t think people expect it to work the way you describe:

Note: this doesn’t only include type hints.

Also, it’s worth pointing out that this notation could also be used to some extend in 3.5, 3.6, 3.7 & 3.8 without importing typing.

Are you saying that new syntax that you’re proposing today could be used in Python 3.5?

I believe so, even without from __future__ import annotations, this would be valid syntax in 3.5. And type checkers could understand this if implemented:

foo: [int] = [1, 2, 3]

But this this is not:

-foo: Optional[[int]] = [1, 2, 3]
+foo: Optional[list] = [1, 2, 3]

I think his point was that 3.5 is EOL since 2020 and 3.8 will be EOL in October. So your argument is incredibly weak.

I just thought it was interesting that the syntax is backwards compatible with every Python version since 3.5 without using from __future__ import annotations or importing typing.

But yeah, 3.5 & 3.6 have reached EOL, so shouldn’t be considered and you can always use __future__ import annotations starting from 3.7.

@Jelle, you clearly expect tuple[()] to represent the empty tuple and not a tuple with an empty tuple.

So, why do you think at the same time that tuple[(int, str),] is confusing? I think it’s less confusing than tuple[()].

Also, just to confirm, you know that the instances are converted to generic aliases at runtime using a function, right?