Here’s a trivial example, but something which I’m trying to make use of in a project.
"""Test typing problems."""
from typing import TypeAlias
Verb: TypeAlias = str
def concats_string(base: Verb) -> str:
# Trivial example - should just append to the passed in value
return " ".join([base, "World"])
greeting: str = "Hello"
print(concats_string(greeting))
I can’t get MyPy, PyRight or pytype to raise an error about the function call.
(Indeed, the join
function should be flagged too…)
I’m guessing this is expected behaviour, since different implementations don’t complain – but what am I missing here?
Isn’t this the point of TypeAlias and exactly what a type checker should flag?