File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -207,13 +207,14 @@ class Config:
207207 },
208208 }
209209
210- def __init__ (self , config_path : Path ) -> None :
210+ def __init__ (self , config_path : Path | None = None ) -> None :
211211 """Loads .ini configuration file and stores its values."""
212212
213213 config = ConfigParser ()
214214 fill_config_with_default_values (config , self .defaults )
215215 try :
216- config .read (config_path )
216+ if config_path is not None :
217+ config .read (config_path )
217218 except UnicodeDecodeError as e :
218219 sys .stderr .write (
219220 "Error: Unable to parse config file at '{}' due to an "
@@ -243,7 +244,9 @@ def get_key_no_doublebind(command: str) -> str:
243244
244245 return requested_key
245246
246- self .config_path = Path (config_path ).absolute ()
247+ self .config_path = (
248+ config_path .absolute () if config_path is not None else None
249+ )
247250 self .hist_file = Path (config .get ("general" , "hist_file" )).expanduser ()
248251
249252 self .dedent_after = config .getint ("general" , "dedent_after" )
Original file line number Diff line number Diff line change @@ -1216,6 +1216,10 @@ def open_in_external_editor(self, filename):
12161216 return subprocess .call (args ) == 0
12171217
12181218 def edit_config (self ):
1219+ if self .config .config_path is None :
1220+ self .interact .notify (_ ("No config file specified." ))
1221+ return
1222+
12191223 if not self .config .config_path .is_file ():
12201224 if self .interact .confirm (
12211225 _ ("Config file does not exist - create new from default? (y/N)" )
You can’t perform that action at this time.
0 commit comments