@@ -357,7 +357,7 @@ def source_file_def_line(self):
357
357
@property
358
358
def github_url (self ):
359
359
url = "https://github.com/pandas-dev/pandas/blob/master/"
360
- url += "{ }#L{}" . format ( self .source_file_name , self . source_file_def_line )
360
+ url += f" { self . source_file_name } #L{ self .source_file_def_line } "
361
361
return url
362
362
363
363
@property
@@ -501,7 +501,7 @@ def parameter_desc(self, param):
501
501
desc = self .doc_parameters [param ][1 ]
502
502
# Find and strip out any sphinx directives
503
503
for directive in DIRECTIVES :
504
- full_directive = ".. {}" . format ( directive )
504
+ full_directive = f ".. { directive } "
505
505
if full_directive in desc :
506
506
# Only retain any description before the directive
507
507
desc = desc [: desc .index (full_directive )]
@@ -825,14 +825,12 @@ def get_validation_data(doc):
825
825
"EX03" ,
826
826
error_code = err .error_code ,
827
827
error_message = err .message ,
828
- times_happening = " ({} times)" .format (err .count )
829
- if err .count > 1
830
- else "" ,
828
+ times_happening = f" ({ err .count } times)" if err .count > 1 else "" ,
831
829
)
832
830
)
833
831
examples_source_code = "" .join (doc .examples_source_code )
834
832
for wrong_import in ("numpy" , "pandas" ):
835
- if "import {}" . format ( wrong_import ) in examples_source_code :
833
+ if f "import { wrong_import } " in examples_source_code :
836
834
errs .append (error ("EX04" , imported_library = wrong_import ))
837
835
return errs , wrns , examples_errs
838
836
@@ -920,7 +918,7 @@ def validate_all(prefix, ignore_deprecated=False):
920
918
api_item_names = set (list (zip (* api_items ))[0 ])
921
919
for class_ in (pandas .Series , pandas .DataFrame ):
922
920
for member in inspect .getmembers (class_ ):
923
- func_name = "pandas.{}.{}" . format ( class_ .__name__ , member [0 ])
921
+ func_name = f "pandas.{ class_ .__name__ } . { member [0 ]} "
924
922
if not member [0 ].startswith ("_" ) and func_name not in api_item_names :
925
923
if prefix and not func_name .startswith (prefix ):
926
924
continue
@@ -938,13 +936,9 @@ def header(title, width=80, char="#"):
938
936
full_line = char * width
939
937
side_len = (width - len (title ) - 2 ) // 2
940
938
adj = "" if len (title ) % 2 == 0 else " "
941
- title_line = "{side} {title}{adj} {side}" .format (
942
- side = char * side_len , title = title , adj = adj
943
- )
939
+ title_line = f"{ char * side_len } { title } { adj } { char * side_len } "
944
940
945
- return "\n {full_line}\n {title_line}\n {full_line}\n \n " .format (
946
- full_line = full_line , title_line = title_line
947
- )
941
+ return f"\n { full_line } \n { title_line } \n { full_line } \n \n "
948
942
949
943
exit_status = 0
950
944
if func_name is None :
@@ -986,24 +980,24 @@ def header(title, width=80, char="#"):
986
980
987
981
else :
988
982
result = validate_one (func_name )
989
- sys .stderr .write (header ("Docstring ({})" . format ( func_name ) ))
990
- sys .stderr .write ("{} \n " . format ( result [" docstring" ]) )
983
+ sys .stderr .write (header (f "Docstring ({ func_name } )" ))
984
+ sys .stderr .write (f" { result [' docstring' ] } \n " )
991
985
sys .stderr .write (header ("Validation" ))
992
986
if result ["errors" ]:
993
- sys .stderr .write ("{ } Errors found:\n ". format ( len ( result [ "errors" ])) )
987
+ sys .stderr .write (f" { len ( result [ 'errors' ]) } Errors found:\n " )
994
988
for err_code , err_desc in result ["errors" ]:
995
989
# Failing examples are printed at the end
996
990
if err_code == "EX02" :
997
991
sys .stderr .write ("\t Examples do not pass tests\n " )
998
992
continue
999
- sys .stderr .write ("\t {}\n " . format ( err_desc ) )
993
+ sys .stderr .write (f "\t { err_desc } \n " )
1000
994
if result ["warnings" ]:
1001
- sys .stderr .write ("{ } Warnings found:\n ". format ( len ( result [ "warnings" ])) )
995
+ sys .stderr .write (f" { len ( result [ 'warnings' ]) } Warnings found:\n " )
1002
996
for wrn_code , wrn_desc in result ["warnings" ]:
1003
- sys .stderr .write ("\t {}\n " . format ( wrn_desc ) )
997
+ sys .stderr .write (f "\t { wrn_desc } \n " )
1004
998
1005
999
if not result ["errors" ]:
1006
- sys .stderr .write ('Docstring for "{}" correct. :)\n ' . format ( func_name ) )
1000
+ sys .stderr .write (f 'Docstring for "{ func_name } " correct. :)\n ' )
1007
1001
1008
1002
if result ["examples_errors" ]:
1009
1003
sys .stderr .write (header ("Doctests" ))
@@ -1027,7 +1021,7 @@ def header(title, width=80, char="#"):
1027
1021
choices = format_opts ,
1028
1022
help = "format of the output when validating "
1029
1023
"multiple docstrings (ignored when validating one)."
1030
- "It can be {}" . format ( str (format_opts )[1 :- 1 ]) ,
1024
+ f "It can be { str (format_opts )[1 :- 1 ]} " ,
1031
1025
)
1032
1026
argparser .add_argument (
1033
1027
"--prefix" ,
0 commit comments