This is "type checking". Its effectiveness will depend on your IDE's capabilities. It has nothing to do with runtime behaviour.
For example:
x:str = 0
The type hint suggests that x should only ever refer to a str type. However, here we assign zero (an int). At runtime the assignment will take place as written. However, your IDE may highlight a potential issue.
Type hinting has limited use in my opinion. Here's another example:
def afunc(s):
i:str = s
return i
def bfunc():
return 0
afunc(bfunc())
In this case the variable i will be assigned int at runtime but the IDE cannot detect any potential problem. [caveat: Pylance in VSCode can't detect the problem. Other static type checkers may be more intelligent]