Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@DimitriPapadopoulos
Copy link
Contributor

No description provided.

@@ -1,4 +1,3 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

This whitespace is significant.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

@DimitriPapadopoulos DimitriPapadopoulos force-pushed the pyupgrade branch 4 times, most recently from ac8e499 to 3ba033b Compare December 17, 2022 13:59
Copy link
Contributor

@effigies effigies left a 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.

f.write(SHORT_VERSION_PY.format(contents))

print("set %s to '%s'" % (filename, versions["version"]))
print("set {} to '{}'".format(filename, versions["version"]))
Copy link
Contributor

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.

Suggested change
print("set {} to '{}'".format(filename, versions["version"]))
print(f"set {filename} to {versions['version']:r}")

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Dec 18, 2022

I still need to fix these flake8 errors, don't I?

  git_version.py:335:89: E501 line too long (90 > 88 characters)
  versioneer.py:809:89: E501 line too long (90 > 88 characters)
  versioneer.py:1330:89: E501 line too long (90 > 88 characters)

I believe this flake8 line length limit is complete nonsense when applied to strings, especially f-strings with longer replacement fields.

See for example what the Linux kernel coding style has to say about it:

The limit on the length of lines is 80 columns and this is a strongly preferred limit.

[...] However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them.

Use f-strings wherever possible.
* [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
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.

2 participants