I'm a big fan and advocate for static type hints in Python 3. I've been using them for a while with no problems.
I just ran into a new edge case that I can't seem to compile. What if I want to define a custom type, then define its parameters?
For example, this is common in Python 3:
from typing import List, NewType
CustomObject = NewType('CustomObject', List[int])
def f(data: List[CustomObject]):
# do something
But this won't compile:
class MyContainer():
# some class definition ...
from typing import NewType
SpecialContainer = NewType('SpecialContainer', MyContainer)
def f(data: SpecialContainer[str]):
# do something
I realize that SpecialContainer is technically a function in this case, but it shouldn't be evaluated as one in the context of a type signature. The second code snippet fails with TypeError: 'function' object is not subscriptable.