Does this apply to return values as well? I suspect this is where the pain point is.
I find that these annotations are typically unnecessary, at least when using pyright or mypy. I'm not sure about other Python type checkers.
When pyright sees an unannotated `self` or `cls` parameter, it infers its type to be an internally-synthesized TypeVar that is bound to the parent class. If that method then returns `self` or `cls` or `cls()`, it infers the proper return type. It appears that mypy does something similar.
Because of this behavior, I rarely need to annotate `self` or `cls` explicitly in my code. It's still required in overloads or in stub files because the return type cannot be inferred without the function's implementation.
-Eric
--
Eric Traut
Contributor to Pyright & Pylance
Microsoft Corp
_______________________________________________