Skip to content
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

Replace format() function with PY3 fstrings #1087

Merged

Conversation

dorothykiz1
Copy link
Contributor

@dorothykiz1 dorothykiz1 commented Mar 3, 2022

xref #1077

Copy link
Member

@datapythonista datapythonista 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, thanks for working on this. Just added couple of things that need to be fixed.

@@ -52,8 +52,7 @@ def publish(cls, conf, repo, benchmarks, graphs, revisions):
pretty_name = benchmark['pretty_name']

if idx is not None:
pretty_name = '{0}({1})'.format(pretty_name,
", ".join(benchmark_param))
pretty_name = f'{pretty_name}({", ".join(benchmark_param)})'
Copy link
Member

Choose a reason for hiding this comment

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

This is fine, but I don't think we're improving readability that much. I forgot to mention in the issue I think, but for non-trivial code, would be better to first assign to a variable, and then have the f-string, but with the variable name, not with the whole expression. In this case it's not that complex a simple join, but having quotes and commas on the expression, makes the f-string quite unreadable in my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks i had thought about this,makes total sense

util.check_call([
sys.executable,
"-mvirtualenv",
"-p",
self._executable,
self._path], env=env)

log.info("Installing requirements for {0}".format(self.name))
log.info("Installing requirements for {self.name}")
Copy link
Member

Choose a reason for hiding this comment

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

Not an f-string. We need to be careful with that, since it's very likely that not flake8 and not the tests will warn us when we miss the f to make an f-string, and we'll lose the value of the variables in the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

noted

@datapythonista datapythonista merged commit 629b84f into airspeed-velocity:master Mar 3, 2022
@datapythonista
Copy link
Member

Thanks @dorothykiz1, really nice

This was referenced Mar 3, 2022
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