-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: replacing '.format' with f-strings in various files #30706
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
Changes from 5 commits
0cb2412
45ece11
4ca8179
180c7a6
9cbd530
8ff9bf7
05cefa2
c77d0a9
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 |
---|---|---|
|
@@ -127,13 +127,13 @@ def main(conda_fname, pip_fname, compare=False): | |
) | ||
if res: | ||
msg = ( | ||
"`requirements-dev.txt` has to be generated with `{}` after " | ||
"`environment.yml` is modified.\n".format(sys.argv[0]) | ||
f"`requirements-dev.txt` has to be generated with `{sys.argv[0]}` after " | ||
f"`environment.yml` is modified.\n" | ||
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. same 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. Thanks for your feedback, I just changed it |
||
) | ||
if args.azure: | ||
msg = ( | ||
"##vso[task.logissue type=error;" | ||
"sourcepath=requirements-dev.txt]{}".format(msg) | ||
f"##vso[task.logissue type=error;" | ||
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. same |
||
f"sourcepath=requirements-dev.txt]{msg}" | ||
) | ||
sys.stderr.write(msg) | ||
sys.exit(res) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,7 +357,7 @@ def source_file_def_line(self): | |
@property | ||
def github_url(self): | ||
url = "https://github.com/pandas-dev/pandas/blob/master/" | ||
url += "{}#L{}".format(self.source_file_name, self.source_file_def_line) | ||
url += f"{self.source_file_name}#L{self.source_file_def_line}" | ||
return url | ||
|
||
@property | ||
|
@@ -501,7 +501,7 @@ def parameter_desc(self, param): | |
desc = self.doc_parameters[param][1] | ||
# Find and strip out any sphinx directives | ||
for directive in DIRECTIVES: | ||
full_directive = ".. {}".format(directive) | ||
full_directive = f".. {directive}" | ||
if full_directive in desc: | ||
# Only retain any description before the directive | ||
desc = desc[: desc.index(full_directive)] | ||
|
@@ -825,14 +825,14 @@ def get_validation_data(doc): | |
"EX03", | ||
error_code=err.error_code, | ||
error_message=err.message, | ||
times_happening=" ({} times)".format(err.count) | ||
times_happening=f" ({err.count} times)" | ||
if err.count > 1 | ||
else "", | ||
) | ||
) | ||
examples_source_code = "".join(doc.examples_source_code) | ||
for wrong_import in ("numpy", "pandas"): | ||
if "import {}".format(wrong_import) in examples_source_code: | ||
if f"import {wrong_import}" in examples_source_code: | ||
errs.append(error("EX04", imported_library=wrong_import)) | ||
return errs, wrns, examples_errs | ||
|
||
|
@@ -920,7 +920,7 @@ def validate_all(prefix, ignore_deprecated=False): | |
api_item_names = set(list(zip(*api_items))[0]) | ||
for class_ in (pandas.Series, pandas.DataFrame): | ||
for member in inspect.getmembers(class_): | ||
func_name = "pandas.{}.{}".format(class_.__name__, member[0]) | ||
func_name = f"pandas.{class_.__name__}.{member[0]}" | ||
if not member[0].startswith("_") and func_name not in api_item_names: | ||
if prefix and not func_name.startswith(prefix): | ||
continue | ||
|
@@ -938,13 +938,9 @@ def header(title, width=80, char="#"): | |
full_line = char * width | ||
side_len = (width - len(title) - 2) // 2 | ||
adj = "" if len(title) % 2 == 0 else " " | ||
title_line = "{side} {title}{adj} {side}".format( | ||
side=char * side_len, title=title, adj=adj | ||
) | ||
title_line = f"{char * side_len} {title}{adj} {side}" | ||
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. Replace the 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. Now I see, thank you. |
||
|
||
return "\n{full_line}\n{title_line}\n{full_line}\n\n".format( | ||
full_line=full_line, title_line=title_line | ||
) | ||
return f"\n{full_line}\n{title_line}\n{full_line}\n\n" | ||
|
||
exit_status = 0 | ||
if func_name is None: | ||
|
@@ -986,24 +982,24 @@ def header(title, width=80, char="#"): | |
|
||
else: | ||
result = validate_one(func_name) | ||
sys.stderr.write(header("Docstring ({})".format(func_name))) | ||
sys.stderr.write("{}\n".format(result["docstring"])) | ||
sys.stderr.write(header(f"Docstring ({func_name})")) | ||
sys.stderr.write(f"{result['docstring']}\n") | ||
sys.stderr.write(header("Validation")) | ||
if result["errors"]: | ||
sys.stderr.write("{} Errors found:\n".format(len(result["errors"]))) | ||
sys.stderr.write(f"{len(result['errors'])} Errors found:\n") | ||
for err_code, err_desc in result["errors"]: | ||
# Failing examples are printed at the end | ||
if err_code == "EX02": | ||
sys.stderr.write("\tExamples do not pass tests\n") | ||
continue | ||
sys.stderr.write("\t{}\n".format(err_desc)) | ||
sys.stderr.write(f"\t{err_desc}\n") | ||
if result["warnings"]: | ||
sys.stderr.write("{} Warnings found:\n".format(len(result["warnings"]))) | ||
sys.stderr.write(f"{len(result['warnings'])} Warnings found:\n") | ||
for wrn_code, wrn_desc in result["warnings"]: | ||
sys.stderr.write("\t{}\n".format(wrn_desc)) | ||
sys.stderr.write(f"\t{wrn_desc}\n") | ||
|
||
if not result["errors"]: | ||
sys.stderr.write('Docstring for "{}" correct. :)\n'.format(func_name)) | ||
sys.stderr.write(f'Docstring for "{func_name}" correct. :)\n') | ||
|
||
if result["examples_errors"]: | ||
sys.stderr.write(header("Doctests")) | ||
|
@@ -1027,7 +1023,7 @@ def header(title, width=80, char="#"): | |
choices=format_opts, | ||
help="format of the output when validating " | ||
"multiple docstrings (ignored when validating one)." | ||
"It can be {}".format(str(format_opts)[1:-1]), | ||
f"It can be {str(format_opts)[1:-1]}", | ||
) | ||
argparser.add_argument( | ||
"--prefix", | ||
|
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.
f string prefix not needed here