Repository navigation
chore: use fstrings #4794
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
chore: use fstrings #4794
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,13 +146,11 @@ def handle(self) -> int: | |
| python = self.option("python") | ||
| if not python: | ||
| current_env = SystemEnv(Path(sys.executable)) | ||
| default_python = "^{}".format( | ||
| ".".join(str(v) for v in current_env.version_info[:2]) | ||
| default_python = "^" + ".".join( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a common enough pattern that I'm wondering if it's worth factoring out into a helper. Something like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in some places, it was easier to use def fmt_version(
version: Tuple[int, int, int],
precision: Literal["major", "minor", "patch"] = "patch",
) -> str:
major, minor, patch, *_ = version
if precision == "major":
return f"{major}"
elif precision == "minor":
return f"{major}.{minor}"
else:
return f"{major}.{minor}.{patch}" |
||
| str(v) for v in current_env.version_info[:2] | ||
| ) | ||
| question = self.create_question( | ||
| "Compatible Python versions [<comment>{}</comment>]: ".format( | ||
| default_python | ||
| ), | ||
| f"Compatible Python versions [<comment>{default_python}</comment>]: ", | ||
| default=default_python, | ||
| ) | ||
| python = self.ask(question) | ||
|
|
@@ -282,9 +280,7 @@ def _determine_requirements( | |
| choices.append(found_package.pretty_name) | ||
|
|
||
| self.line( | ||
| "Found <info>{}</info> packages matching <c1>{}</c1>".format( | ||
| len(matches), package | ||
| ) | ||
| f"Found <info>{len(matches)}</info> packages matching <c1>{package}</c1>" | ||
| ) | ||
|
|
||
| package = self.choice( | ||
|
|
@@ -314,9 +310,7 @@ def _determine_requirements( | |
| ) | ||
|
|
||
| self.line( | ||
| "Using version <b>{}</b> for <c1>{}</c1>".format( | ||
| package_constraint, package | ||
| ) | ||
| f"Using version <b>{package_constraint}</b> for <c1>{package}</c1>" | ||
| ) | ||
|
|
||
| constraint["version"] = package_constraint | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,7 @@ def handle(self) -> None: | |
| if path.exists() and list(path.glob("*")): | ||
| # Directory is not empty. Aborting. | ||
| raise RuntimeError( | ||
| "Destination <fg=yellow>{}</> " "exists and is not empty".format(path) | ||
| f"Destination <fg=yellow>{path}</> " "exists and is not empty" | ||
| ) | ||
|
|
||
| readme_format = self.option("readme") or "md" | ||
|
|
@@ -64,9 +64,7 @@ def handle(self) -> None: | |
| author += f" <{author_email}>" | ||
|
|
||
| current_env = SystemEnv(Path(sys.executable)) | ||
| default_python = "^{}".format( | ||
| ".".join(str(v) for v in current_env.version_info[:2]) | ||
| ) | ||
| default_python = "^" + ".".join(str(v) for v in current_env.version_info[:2]) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above note about version specifier strings. |
||
|
|
||
| layout_ = layout_( | ||
| name, | ||
|
|
@@ -83,7 +81,5 @@ def handle(self) -> None: | |
| path = path.relative_to(Path.cwd()) | ||
|
|
||
| self.line( | ||
| "Created package <info>{}</> in <fg=blue>{}</>".format( | ||
| layout_._package_name, path.as_posix() | ||
| ) | ||
| f"Created package <info>{layout_._package_name}</> in <fg=blue>{path.as_posix()}</>" | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.