Pycharm Edu 2019.2 Type annotations

import typing
def greeting(name: str) -> str:
l_name = name
return 'Hello ' + name

I am using Python3.7. However the above code shows errors: type annotation not supported in python2. But I am not using python2.

How do I get type annotations to work.

print(greeting(42)) ==> should show error: Argument 1 to "greeting" has incompatible type "int"; expected "str".

But instead I get a runtime error.

1 comment
Comment actions Permalink

Please check File | Settings | Editor | Inspections > Python > Code compatibility inspection.

Make sure python 2.x is disabled


Please sign in to leave a comment.