This will work for dict and list, but not for any generic type:
from typing import Any, Mapping, Sequence, Union
def my_function(hasitems: Union[Mapping, Sequence], locator: Any) -> Any:
return hasitems[locator]
This will work for dict and list, but not for any generic type:
from typing import Any, Mapping, Sequence, Union
def my_function(hasitems: Union[Mapping, Sequence], locator: Any) -> Any:
return hasitems[locator]