typing module doesn't make python a statically typed language.
The interpreter is still the same duck-typed goo that we all love.
The interpreter doesn't have any special knowledge about the types in the
It semantically ignores all type annotations in code.
Take the following snippet -
names: typing.List[str] = ["guido", "tim", "barry"]
From the perspective of the interpreter, the object pointed to by
names is a
There's no discrimination based on the specific container type.
are all the same
list type, internally.
Which is the reason why the following, surprisingly, raises a
This is all very unfortunate. All that work spent on annotating thousands of lines of code,
and its basically useless at runtime? (Well, except
NamedTuple and friends)
Typeguard to the rescue!