77Fully compliant with the XDG Base Directory Specification.
88"""
99
10- from enum import Enum
11- from pathlib import Path
12- from typing import Any , Dict , Optional , Tuple , Union
1310import copy
1411import dataclasses as dc
1512import json
1613import os
17- import os
1814import sys
15+ from enum import Enum
16+ from pathlib import Path
17+ from typing import Any , Dict , Optional , Tuple , Union
1918
20- File = Tuple [Union [Path , str ]]
19+ File = tuple [Union [Path , str ]]
2120_NONE = object ()
2221
2322
@@ -50,7 +49,7 @@ def load(self, *files: File):
5049 def load_from_environ (
5150 self ,
5251 prefix : str ,
53- environ : Optional [ Dict ] = None ,
52+ environ : dict | None = None ,
5453 verbose : bool = True ,
5554 ):
5655 if environ is None :
@@ -268,7 +267,7 @@ def open(self, filename=None):
268267 if not filename :
269268 basename = os .path .basename (self .home )
270269 suffix = FORMAT_TO_SUFFIX [self .format .name ]
271- filename = '%s%s' % (basename , suffix )
270+ filename = '{}{}' . format (basename , suffix )
272271 elif filename .startswith ('/' ):
273272 filename = filename [1 :]
274273
@@ -283,7 +282,7 @@ def all_files(self, filename):
283282 full_path = os .path .join (p , filename )
284283 try :
285284 yield open (full_path ) and full_path
286- except IOError :
285+ except OSError :
287286 pass
288287
289288 def full_name (self , filename ):
@@ -322,7 +321,7 @@ def read(self):
322321 try :
323322 with open (self .filename ) as fp :
324323 self .contents = self .format .read (fp )
325- except IOError :
324+ except OSError :
326325 self .contents = self .format .create ()
327326 return self .contents
328327
@@ -510,7 +509,7 @@ def __init__(self):
510509 def read (self , fp ):
511510 """Read contents from an open file in this format"""
512511 contents = self .create ()
513- contents .readfp (fp )
512+ contents .read_file (fp )
514513 return contents
515514
516515 def write (self , contents , fp ):
@@ -519,7 +518,7 @@ def write(self, contents, fp):
519518
520519 def create (self ):
521520 """Return new, empty contents"""
522- return self ._parser .SafeConfigParser ()
521+ return self ._parser .ConfigParser ()
523522
524523 def as_dict (self , contents ):
525524 """Convert the contents to a dict"""
0 commit comments