-
Notifications
You must be signed in to change notification settings - Fork 152
Apply pyupgrade and refurb suggestions #352
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
base: master
Are you sure you want to change the base?
Apply pyupgrade and refurb suggestions #352
Conversation
src/header.py
Outdated
@@ -1,4 +1,3 @@ | |||
|
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 whitespace is significant.
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.
That's what I suspected, but it's not clear why. Is additional code added in front of 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.
Yes, these files are compiled into the single-file versioneer.py
file.
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.
The alternative would be to add the extra line when compiling the versioneer.py
file in setup.py
. But then, why change something that works?
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.
Fixed, but I still need to look into the files under test
.
ac8e499
to
3ba033b
Compare
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.
All seems fine. Some small suggestions, but I'm okay to merge as-is.
|
||
print("set %s to '%s'" % (filename, versions["version"])) | ||
print("set {} to '{}'".format(filename, versions["version"])) |
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.
Might as well use an f-string if we're here.
print("set {} to '{}'".format(filename, versions["version"])) | |
print(f"set {filename} to {versions['version']:r}") |
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.
But then we're modifying functionality, by changing '%s'
to {...}
instead of '{...}'
, aren't we?
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.
Also, I suspect you meant !r
instead of :r
. It will call repr()
, but then how is that helpful?
>>> i = 2
>>>
>>> f"We print 'i' as '{i}'"
"We print 'i' as '2'"
>>>
>>> f"We print 'i' as {i!r}"
"We print 'i' as 2"
>>>
We might use triple quotes instead:
f"""set {filename} to '{versions["version"]}'"""
But then it gets unreadable.
I still need to fix these
I believe this See for example what the Linux kernel coding style has to say about it:
|
Use f-strings wherever possible.
* [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
a07d0fd
to
f3846e0
Compare
No description provided.