Accept suggestions from new toolchain · rec/cfgs@df989d1
@@ -7,17 +7,16 @@
77Fully compliant with the XDG Base Directory Specification.
88"""
9910-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
191820-File = Tuple[Union[Path, str]]
19+File = tuple[Union[Path, str]]
2120_NONE = object()
22212322@@ -50,7 +49,7 @@ def load(self, *files: File):
5049def load_from_environ(
5150self,
5251prefix: str,
53-environ: Optional[Dict] = None,
52+environ: dict | None = None,
5453verbose: bool = True,
5554 ):
5655if environ is None:
@@ -268,7 +267,7 @@ def open(self, filename=None):
268267if not filename:
269268basename = os.path.basename(self.home)
270269suffix = FORMAT_TO_SUFFIX[self.format.name]
271-filename = '%s%s' % (basename, suffix)
270+filename = '{}{}'.format(basename, suffix)
272271elif filename.startswith('/'):
273272filename = filename[1:]
274273@@ -283,7 +282,7 @@ def all_files(self, filename):
283282full_path = os.path.join(p, filename)
284283try:
285284yield open(full_path) and full_path
286-except IOError:
285+except OSError:
287286pass
288287289288def full_name(self, filename):
@@ -322,7 +321,7 @@ def read(self):
322321try:
323322with open(self.filename) as fp:
324323self.contents = self.format.read(fp)
325-except IOError:
324+except OSError:
326325self.contents = self.format.create()
327326return self.contents
328327@@ -510,7 +509,7 @@ def __init__(self):
510509def read(self, fp):
511510"""Read contents from an open file in this format"""
512511contents = self.create()
513-contents.readfp(fp)
512+contents.read_file(fp)
514513return contents
515514516515def write(self, contents, fp):
@@ -519,7 +518,7 @@ def write(self, contents, fp):
519518520519def create(self):
521520"""Return new, empty contents"""
522-return self._parser.SafeConfigParser()
521+return self._parser.ConfigParser()
523522524523def as_dict(self, contents):
525524"""Convert the contents to a dict"""