This question is concrete for select in sqlmodel. In the code, the author uses lots of overload to define different situations. However, this method is verbose and not good. For example, select can accept any number of parameters, but if we pass more than 3 parameters, mypy or pyright would complain. But I also don't know how to make it better. Ideally, I think the type hint of select should be: reserve _TScalar, as the type of _TScalar should be restricted; parameters could be of any number, and each parameter could be a _TCCA[_T] or a _TScalar, and different parameter's _T or _TScalar could be different; the return values should be a tuple with the same length of parameters. If one parameter is _TCCA[_T], then its return type should be _T; if one parameter is _TScalar, then its return type should be _TScalar. The restrictions make the type hints too hard. I know Unpack and TypeVarTuple, but I don't think it's enough. Is there any good way to solve this? Continue reading...