@@ -116,10 +116,10 @@ def setup_and_check(self, data, title='', readonly=False, caller_info=None, **kw
116116
117117 # permanently display caller info in the status bar
118118 if caller_info is not None :
119- caller_info = 'launched from file {} at line {}' . format ( caller_info .filename , caller_info . lineno )
119+ caller_info = f 'launched from file { caller_info . filename } at line { caller_info .lineno } '
120120 self .statusBar ().addPermanentWidget (QLabel (caller_info ))
121121 # display welcome message
122- self .statusBar ().showMessage ("Welcome to the {}" . format ( self .name ) , 4000 )
122+ self .statusBar ().showMessage (f "Welcome to the { self .name } " , 4000 )
123123
124124 # set central widget
125125 widget = QWidget ()
@@ -224,12 +224,12 @@ def _report_issue(*args, **kwargs):
224224## Version and main components
225225* Python {python} on {system} {bitness:d}bits
226226"""
227- issue_template += "* {package} {{{package}}}\n " . format ( package = package )
227+ issue_template += f "* { package } {{{ package } }}\n "
228228 for dep in dependencies [package ]:
229- issue_template += "* {dep} {{{dep}}}\n " . format ( dep = dep )
229+ issue_template += f "* { dep } {{{ dep } }}\n "
230230 issue_template = issue_template .format (** versions )
231231
232- url = QUrl (urls ['new_issue_{}' . format ( package ) ])
232+ url = QUrl (urls [f 'new_issue_{ package } ' ])
233233 if PYQT5 :
234234 from qtpy .QtCore import QUrlQuery
235235 query = QUrlQuery ()
@@ -263,7 +263,7 @@ def about(self):
263263"""
264264 for dep in dependencies ['editor' ]:
265265 if kwargs [dep ] != 'N/A' :
266- message += "<li>{dep} {{{dep}}}</li>\n " . format ( dep = dep )
266+ message += f "<li>{ dep } {{{ dep } }}</li>\n "
267267 message += "</ul>"
268268 QMessageBox .about (self , _ ("About LArray Editor" ), message .format (** kwargs ))
269269
@@ -276,14 +276,14 @@ def _update_title(self, title, array, name):
276276 # current file (if not None)
277277 if isinstance (array , la .Array ):
278278 # array info
279- shape = ['{ } ({})' . format ( display_name , len (axis ))
279+ shape = [f' { display_name } ({ len (axis )} )'
280280 for display_name , axis in zip (array .axes .display_names , array .axes )]
281281 else :
282282 # if it's not an Array, it must be a Numpy ndarray
283283 assert isinstance (array , np .ndarray )
284284 shape = [str (length ) for length in array .shape ]
285285 # name + shape + dtype
286- array_info = ' x ' .join (shape ) + ' [{}]' . format ( dtype )
286+ array_info = ' x ' .join (shape ) + f ' [{ dtype } ]'
287287 if name :
288288 title += [name + ': ' + array_info ]
289289 else :
@@ -306,7 +306,7 @@ def save_widgets_state_and_geometry(self):
306306 settings .setValue ('geometry' , self .saveGeometry ())
307307 settings .setValue ('state' , self .saveState ())
308308 for widget_name , widget in self .widget_state_settings .items ():
309- settings .setValue ('state/{}' . format ( widget_name ) , widget .saveState ())
309+ settings .setValue (f 'state/{ widget_name } ' , widget .saveState ())
310310 settings .endGroup ()
311311
312312 def restore_widgets_state_and_geometry (self ):
@@ -319,7 +319,7 @@ def restore_widgets_state_and_geometry(self):
319319 if state :
320320 self .restoreState (state )
321321 for widget_name , widget in self .widget_state_settings .items ():
322- state = settings .value ('state/{}' . format ( widget_name ) )
322+ state = settings .value (f 'state/{ widget_name } ' )
323323 if state :
324324 widget .restoreState (state )
325325 settings .endGroup ()
@@ -440,7 +440,7 @@ def void_formatter(array, *args, **kwargs):
440440 funcname = frame_summary .name
441441 filename = os .path .basename (frame_summary .filename )
442442 listitem = QListWidgetItem (stack_frame_widget )
443- listitem .setText ("{ }, {}:{}" . format ( funcname , filename , frame_summary .lineno ) )
443+ listitem .setText (f" { funcname } , { filename } :{ frame_summary .lineno } " )
444444 # we store the frame summary object in the user data of the list
445445 listitem .setData (Qt .UserRole , frame_summary )
446446 listitem .setToolTip (frame_summary .line )
@@ -474,7 +474,7 @@ def void_formatter(array, *args, **kwargs):
474474 if os .path .isfile (data ):
475475 self ._open_file (data )
476476 else :
477- QMessageBox .critical (self , "Error" , "File {} could not be found" . format ( data ) )
477+ QMessageBox .critical (self , "Error" , f "File { data } could not be found" )
478478 self .new ()
479479 elif not debug :
480480 self ._push_data (data )
@@ -757,15 +757,15 @@ def update_title(self):
757757 basename = os .path .basename (self .current_file )
758758 if os .path .isdir (self .current_file ):
759759 assert not name .endswith ('.csv' )
760- fname = os .path .join (basename , '{ }.csv'. format ( name ) )
760+ fname = os .path .join (basename , f' { name } .csv' )
761761 name = ''
762762 else :
763763 fname = basename
764764 else :
765765 fname = '<new>'
766766
767767 array = self .current_array
768- title = ['{}{}' . format ( unsaved_marker , fname ) ]
768+ title = [f' { unsaved_marker } { fname } ' ]
769769 self ._update_title (title , array , name )
770770
771771 def set_current_array (self , array , name ):
@@ -838,8 +838,7 @@ def _load_script(self, filepath):
838838 self .ipython_cell_executed ()
839839 self .recent_loaded_scripts .add (filepath )
840840 except Exception as e :
841- QMessageBox .critical (self , "Error" , "Cannot load script file {}:\n {}"
842- .format (os .path .basename (filepath ), e ))
841+ QMessageBox .critical (self , "Error" , f"Cannot load script file { os .path .basename (filepath )} :\n { e } " )
843842
844843 def load_script (self , filepath = None ):
845844 # %load add automatically the extension .py if not present in passed filename
@@ -923,12 +922,11 @@ def _save_script(self, filepath, lines, overwrite):
923922 if lines :
924923 lines = lines .replace ('..' , '-' )
925924 else :
926- lines = '1-{}' . format ( self .kernel .shell .execution_count )
927- self .kernel .shell .run_line_magic ('save' , '{ } {} {}' . format ( overwrite , filepath , lines ) )
925+ lines = f '1-{ self .kernel .shell .execution_count } '
926+ self .kernel .shell .run_line_magic ('save' , f' { overwrite } { filepath } { lines } ' )
928927 self .recent_saved_scripts .add (filepath )
929928 except Exception as e :
930- QMessageBox .critical (self , "Error" , "Cannot save history as {}:\n {}"
931- .format (os .path .basename (filepath ), e ))
929+ QMessageBox .critical (self , "Error" , f"Cannot save history as { os .path .basename (filepath )} :\n { e } " )
932930
933931 # See http://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-save
934932 # for more details
@@ -1007,7 +1005,7 @@ def save_script(self):
10071005 overwrite = radio_button_overwrite .isChecked ()
10081006 if overwrite and os .path .isfile (filepath ):
10091007 ret = QMessageBox .warning (self , "Warning" ,
1010- "File `{}` exists. Are you sure to overwrite it?" . format ( filepath ) ,
1008+ f "File `{ filepath } ` exists. Are you sure to overwrite it?" ,
10111009 QMessageBox .Save | QMessageBox .Discard | QMessageBox .Cancel )
10121010 if ret == QMessageBox .Save :
10131011 self ._save_script (filepath , lines , overwrite )
@@ -1043,10 +1041,9 @@ def _open_file(self, filepath: Union[str, Path]):
10431041 self ._push_data (session )
10441042 self .set_current_file (current_file_name )
10451043 self .unsaved_modifications = False
1046- self .statusBar ().showMessage ("Loaded: {}" . format ( display_name ) , 4000 )
1044+ self .statusBar ().showMessage (f "Loaded: { display_name } " , 4000 )
10471045 except Exception as e :
1048- QMessageBox .critical (self , "Error" , "Something went wrong during load of file(s) {}:\n {}"
1049- .format (display_name , e ))
1046+ QMessageBox .critical (self , "Error" , f"Something went wrong during load of file(s) { display_name } :\n { e } " )
10501047
10511048 def open_data (self ):
10521049 if self ._ask_to_save_if_unsaved_modifications ():
@@ -1073,7 +1070,7 @@ def open_recent_file(self):
10731070 if os .path .exists (filepath ):
10741071 self ._open_file (filepath )
10751072 else :
1076- QMessageBox .warning (self , "Warning" , "File {} could not be found" . format ( filepath ) )
1073+ QMessageBox .warning (self , "Warning" , f "File { filepath } could not be found" )
10771074
10781075 def _save_data (self , filepath ):
10791076 try :
@@ -1082,9 +1079,9 @@ def _save_data(self, filepath):
10821079 self .set_current_file (filepath )
10831080 self .edit_undo_stack .clear ()
10841081 self .unsaved_modifications = False
1085- self .statusBar ().showMessage ("Arrays saved in file {}" . format ( filepath ) , 4000 )
1082+ self .statusBar ().showMessage (f "Arrays saved in file { filepath } " , 4000 )
10861083 except Exception as e :
1087- QMessageBox .critical (self , "Error" , "Something went wrong during save in file {}:\n {}" . format ( filepath , e ) )
1084+ QMessageBox .critical (self , "Error" , f "Something went wrong during save in file { filepath } :\n { e } " )
10881085
10891086 def save_data (self ):
10901087 """
0 commit comments