✨ Add Typing for select of arbitrary length#839
✨ Add Typing for select of arbitrary length#839maxispeicher wants to merge 2 commits intofastapi:mainfrom
Conversation
|
@Seluj78 I'm not sure if @maxispeicher is active these days and there were a few conflicts (filename changes) that I could not resolve on their branch, so I changed an open PR I had to be Maxi's changes without the conflicts. Credits go to @maxispeicher ofc - it'd be awesome if we can get better typing :) Thank you for your work! |
|
I do not think this can work unfortunately. Python's type system doesn't provide a clean way to have variadic generic types that preserve the individual types of each argument without listing all possibilities. This approach would remove the type specificity of individual arguments and break a lot of consumers that rely on it. |
|
Thanks @maxispeicher and @GiorgioPorgio for the investigation and work on this! 🤓 Indeed, I had played around with this a lot and concluded that the best I could provide was some amount of overrides. Unfortunately, because they can be of several types, it requires all the combinations, so adding each extra param supported is a combinatorial explosion, that's why there's only 4 now. Hopefully with future improvements in the Python type system this could be solved. 🤓 For now, I'll pass on this. Thanks! ☕ |
Running
mypyor similar type checkers onselectqueries with more than 4 arguments will lead to errors due to the limited type overloads.In order to at least somehow circumvent this, this PR adds overloads for an arbitrary amount of arguments to
select.resolves #92