Is there a Pythonic way of creating a Callable type like below (TypeScript and C# examples)?
TypeScript:
export type MyHandler = (paramOne: ClassOne, num: int) => null;
C#:
public delegate void MyHandler(ClassOne paramOne, int num);
Python:
MyHandler = Callable[[ClassOne, int], None] # No lint errors...
While I'm not getting any lint errors in PyCharm; I haven't bothered running my snippet yet because of how not-Pythonic this feels. If this was going to be my own code for private consumption I don't think I would bother with creating this type, but it's going to be part of a library so I feel more obligated to create the type.
In usage, this type would show up in something like:
class SomeClass(ProbablyAnABC):
# __init__ where self._handlers is created
def register_handler(self, handler: MyHandler) -> None:
self._handlers.append(handler)