-
Notifications
You must be signed in to change notification settings - Fork 234
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
Why are properties on Requestbuilders not defined as python properties? #2024
Comments
This language semantics support it https://www.geeksforgeeks.org/getter-and-setter-in-python/ |
This is something we looked into during implementation of generation but ultimately decided not to for the following reasons.
This means for paths that require arguments a user can't do this: await client.users_by_id('USER_ID').messages_by_id('MESSAGE_ID').get() and will have to do this instead: user = client.users_by_id = 'USER_ID'
message = user.messages_by_id = 'MESSAGE_ID'
await message.get() Not only is this not fluent, but introduces differences in API calls depending on the path. Using |
Also, unlike methods, property setters do not support multiple arguments. You'll have to pass a |
@darrelmiller, please let us know if you have further questions on this matter. |
Properties on request builders do not mutate the underlying request object, nor do they return the same object that was called. They return a new request factory for the child path segment. Request chaining is considered pythonic as per the email I shared from Guido in the past. It is true that when accessing an Item request factory we will need to make that a method in order to pass the parameter. If the language supports property accessors then I see no reason not to use them to avoid developers have to type redundant parentheses. If accessing the request builder requires a parameter, then use a method. If it does not, then use a property. With this approach we should be able to implement: client.me.get()
client.me.messages_by_id('MESSAGE_ID').get()
client.users_by_id('USER_ID').messages_by_id('MESSAGE_ID').get()
client.solutions.bookings.bookingbusinesses.get()
client.solutions.bookings.bookingbusinesses_by_id("someid").get() |
e.g. Why do we do
client.me().get()
instead ofclient.me.get()
?The text was updated successfully, but these errors were encountered: