How can I write a type hint for an argument that should be an operator function? For example, see this function:
import operator
from typing import Dict, Tuple
def func(thresholds: Dict[str, Tuple[operator, float]] = None):
if thresholds is None:
thresholds = {"height": (operator.lt, 0.7), "width": (operator.gt, 0.1)}
pass
When I try to run my code I get:
TypeError: Tuple[t0, t1, ...]: each t must be a type. Got <module 'operator' from ...>.
Edit: I realize that operator is a module, not a type, and that the argument I'm looking for is a function from that module. I'm trying to see if there's any way to let the user know that I expect an operator function as the argument. Is the only way to explain in a docstring?