-
-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
narrow client request methods down #303
Conversation
d3a0cce
to
41b7392
Compare
Interesting take, thanks! It’s great to see a possible solution to better typing support of **kwargs. How well does this work with autocompletion, though? I suppose this was the main motivation for repeating the keyword arguments in the client methods. I think there’s a big blocker, though — TypeDict is a new, 3.8-only feature of the typing module, but we support 3.6 and up. So I don’t think this will make it but I really appreciate you giving this a shot. (Though, I’m not sure the approach demonstrated here was the idea behind #174. We definitely need to discuss the proposed scope and API of build_request() there.) |
Thanks for review.
I've been trying to fix two things. First, use one line client functions and decorate them with a generic function to handle their signature. Second, when I don't know how IDEs handle moving autocomplete arguments. added a decorator to override client function's signature. With bind or bind_partial functions, I can check their arguments in runtime but in design time it doesn't work. I use vscode but I'm not sure about Pycharm.
Are you sure about this? because it comes from |
Oh, indeed. Cool!
From experience, signature-altering decorators don't play that well with IDEs (because those generally rely on the initial signature of the function). I'll give it a go in VSCode when I have some time, and we'll see. :) |
by the way, I came across this issue I'm watching it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I'm not sure this is something we even want to have. Sure, repeating the arguments looks cumbersome but it's not that much of a maintenance burden, it makes very explicit what these methods accept, and it gives a nice editor experience.
(Edit: there's also the question of what we would do with the AsyncClient
's methods? Really, I think we're fine with things are they are today.)
Would love to have @sethmlarson's point of view on this. :-)
41b7392
to
0537204
Compare
at least I added
|
So, I’m going to close this because I think it’s not something we need, esp with respect to maintaining the readability, ease of maintenance and editor support of the client. But thanks again for trying it out! (In the future, feel free to open issues to discuss this kind of idea, if you’d like a quick feedback on whether it’s something worth working on.) |
#174
Hi, I tried to narrow
Client
methods down withTypeDict
. However, does not seem possible until the issue fixed. This code may be useful.