Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Apply pyupgrade and refurb suggestions#352

Draft
DimitriPapadopoulos wants to merge 2 commits intopython-versioneer:masterpython-versioneer/python-versioneer:masterfrom
DimitriPapadopoulos:pyupgradeDimitriPapadopoulos/python-versioneer:pyupgradeCopy head branch name to clipboard
Draft

Apply pyupgrade and refurb suggestions#352
DimitriPapadopoulos wants to merge 2 commits intopython-versioneer:masterpython-versioneer/python-versioneer:masterfrom
DimitriPapadopoulos:pyupgradeDimitriPapadopoulos/python-versioneer:pyupgradeCopy head branch name to clipboard

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.

src/render.py Show resolved Hide resolved
src/setupfunc.py Show resolved Hide resolved
@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.

src/from_parentdir.py Show resolved Hide resolved
src/git/from_vcs.py Show resolved Hide resolved
src/git/from_vcs.py Show resolved Hide resolved
@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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.