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
types.py:8: 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

0

Please sign in to leave a comment.