On Wed, Apr 21, 2021 at 3:04 AM Mark Shannon <mark@hotpy.org> wrote:
Then came type hints. PEP 484 explicitly said that type hints were optional and would *always* be optional.
Then came along many typing PEPs that assumed that type hints would only used for static typing, making static typing a bit less optional.
How do they make type hints less optional?
Then came PEP 563 and said that if you wanted to access the annotations of an object, you needed to call typing.get_type_hints() to get annotations in a meaningful form. This smells a bit like enforced static typing to me.
How?
An extreme example of that is this:
# Some magic code to mess with collections.abc.Sequence
match {}: ... case []: ... print("WTF!") ... WTF!
With duck typing this would be impossible (unless you use ctypes to mess with the dict object).
Why would you want to? A dict is not a sequence.
So, lets stick to our promise that type hints will always be optional, and restore duck typing.
I'm not suggesting that we get rid type hints and abstract base classes. They are popular for a reason. But let's treat them as useful tools, not warp the rest of the language to fit them.
So if you're not asking for them to be removed, then what ARE you asking for? Is there any evidence that type hints will, in the future, become mandatory? I don't understand. ChrisA