-
Notifications
You must be signed in to change notification settings - Fork 168
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
String Formatting Updated #141
Conversation
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.
Thank you for the contribution here @vkmrishad! Is there a specific reason for this change, like better performance?
hi @joshcanhelp, I can list some benefits of formatting:
|
Great response @vkmrishad, thank you! We'll get this reviewed ASAP 👍 |
@lbalmaceda and @joshcanhelp |
@vkmrishad - We'll get to it when we can. This is not a bug or a critical fix so it's not high priority. Thanks again for your contribution and we'll take a look when we can. |
@joshcanhelp Thanks. |
@vkmrishad - Understood. I'd prefer to keep it open so we don't lose track of it but will leave that up to you. |
@joshcanhelp |
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.
@vkmrishad - I have one change request on this one and then we'll merge this ... one additional question though ... is these the extent of where this string formatting can be improved? I'm seeing another type of string formatting here:
https://github.com/auth0/auth0-python/blob/master/auth0/v3/management/users.py#L154
Could that be updated as well? Would be helpful to get all these in one PR, if you're willing/able.
Thanks again! I'll stick with this until we get it merged.
auth0/v3/management/connections.py
Outdated
@@ -128,5 +128,4 @@ def delete_user_by_email(self, id, email): | |||
Returns: | |||
An empty dict. | |||
""" | |||
return self.client.delete(self._url(id) + '/users', params={'email': email}) | |||
|
|||
return self.client.delete('%s/users' % self._url(id), params={'email': email}) |
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.
@vkmrishad - This jumped out at us ... this is not a very clear way to represent that URL. I would change this to do what we're doing here:
https://github.com/auth0/auth0-python/blob/master/auth0/v3/management/users.py#L169
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.
@joshcanhelp
For your information %s formatting is soon to be deprecated. Actually, I thought to use placeholder {} formatting or f-string formation.
I used %s because is mostly used in this project.
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.
If its ok, we can change all formatting from %s to "{}.format()"
@vkmrishad - No need to tag us, we get notifications 😄 I think this is a big improvement and thank you for sticking with it. We'll review it ASAP and let you know if we have any feedback here. |
@joshcanhelp I know 😄 |
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.
@vkmrishad - 2 minor things here and we'll get this merged. Both are open to discussion, just ones that jumped out at me.
Thank you!
auth0/v3/management/blacklists.py
Outdated
params = { | ||
'aud': aud | ||
} | ||
self.aud_ = {'aud': aud} |
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.
Out of scope, let's leave this out.
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.
Code reverted
auth0/v3/management/connections.py
Outdated
@@ -138,5 +138,4 @@ def delete_user_by_email(self, id, email): | |||
Returns: | |||
An empty dict. | |||
""" | |||
return self.client.delete(self._url(id) + '/users', params={'email': email}) | |||
|
|||
return self.client.delete('{}/users'.format(self._url(id)), params={'email': email}) |
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.
This is confusing to read ... how about:
return self.client.delete( self._url( '{}/users'.format( id ) ) ...
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.
@joshcanhelp
return self.client.delete( self._url( '{}/users'.format( id ) ) ...
Only 'id' is expected in self._url(id) in this method. Above mentioned code passing both id+'/users'.
This will cause problem to
def _url(self, id=None):
url = 'https://{}/api/v2/connections'.format(self.domain)
if id is not None:
return '{}/{}'.format(url, id)
return url
For readability we can change this to
return self.client.delete('{_url}/users'.format(_url=self._url(id)), params={'email': email})
or use the same return self.client.delete('{}/users'.format(self._url(id)), params={'email': email})
.
or can use return self.client.delete(self._url(id) + '/users', params={'email': email})
without formatting.
Let me know your thought on this.
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.
Let's leave it as it was before:
self._url(id) + '/users'
I don't think the string formatting is adding anything here.
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.
Ok, left it as it was before.
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.
LGTM! Thanks again!
Thank you :) |
BTW I have formatted string in the entire project.