Python 3 type check not works with use typing module?

Viewed 5937

Why does type checking not work in Python 3?

I have done the following code with type checks or hints:

import typing

def hello(message: str):
    print(type(message))
    print(message)

hello('Hello!')
hello(1)
hello(1.1)

It produces valid output (but no errors on int or float).

<class 'str'>
Hello!
<class 'int'>
1
<class 'float'>
1.1

Why does it works this way? Maybe I don't understand the typing module and Python hints.

5 Answers
Related