Skip to content

Python 3 syntax #383

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

Merged
merged 2 commits into from
Nov 13, 2020
Merged

Python 3 syntax #383

merged 2 commits into from
Nov 13, 2020

Conversation

azmeuk
Copy link
Contributor

@azmeuk azmeuk commented Oct 1, 2020

I applied the pyupgrade tool to use a modern python syntax in the code.

find . -name "*.py" -exec pyupgrade --py36-plus "{}" +

@encukou
Copy link
Member

encukou commented Oct 1, 2020

It looks like the tool changes '%s' % ... formatting to '{}'.format(...), and '{}'.format(...) to f'{...}', but doesn't do the two steps at once.
Could you try running it again, to hopefully get a more consistent result?

@azmeuk
Copy link
Contributor Author

azmeuk commented Oct 1, 2020

The second run does not change anything :(

Copy link
Contributor

@droideck droideck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking for some time through the changes, I tend to think that the change is good as it is now.

I think it is okay to use either str.format(), either f"str".
Mostly I prefer the second option but sometimes it'll be more readable to specify the first one, i.e.:

        return '<{}.{} instance at {}: {}>'.format(
            self.__class__.__module__,
            self.__class__.__name__,
            hex(id(self)),
            self._data
        )

So, I give my ack for the change as it's an obvious improvement and we should really get rid of the old string formatting '%'.

But as always, we need a second ack here. :) Could you please double-check me, guys?
@tiran @encukou

Copy link
Member

@encukou encukou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you!

@encukou encukou merged commit 3484d57 into python-ldap:master Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy