I try to restrict the 'parameter' type to be int or list like the function 'f' below. However, Pycharm does not show a warning at the line f("weewfwef") about wrong parameter type, which means this (parameter : [int, list]) is not correct.
In Python, is it possible to restrict the type of a python function parameter to two possible types?
def f(parameter : [int, list]):
if len(str(parameter)) <= 3:
return 3
else:
return [1]
if __name__ == '__main__':
f("weewfwef")