Yes, when we talk about type safety, we generally mean "compile time" type safety. Python is also "type safe" at runtime (which is to say, "it's strongly typed"), but we don't conventionally consider Python to be type-safe.
Bringing this type information at "compile-time" into your language of choice where you embed your queries can also be done but is a harder problem. There is good progress in that sphere but it is still in it is infancy.
The GraphQL eco-system for example, has this figured out using code generators. A similar thing can be done with DBs.
def do(s: int) -> str:
return 5
print(do("123"))
Python is duck-typed. Wrong types aren't detected until they fail to quack correctly.