I want to add type hints to a function that will accept any object with a __getitem__ method. For instance, in
__getitem__
def my_function(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]