From d3ffe6f0d9c9216b88cead3f5abaee28a5d6e4eb Mon Sep 17 00:00:00 2001 From: A_D Date: Fri, 7 May 2021 14:27:32 +0200 Subject: [PATCH] Removed useless check, added doc comments --- config.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/config.py b/config.py index 1a388fce..67ea52d8 100644 --- a/config.py +++ b/config.py @@ -836,14 +836,10 @@ class LinuxConfig(AbstractConfig): self.filename.parent.mkdir(exist_ok=True, parents=True) self.config: Optional[ConfigParser] = ConfigParser(comment_prefixes=('#',), interpolation=None) + self.config.read(self.filename) # read() ignores files that dont exist - try: - self.config.read(self.filename) - except Exception as e: - logger.debug(f'Error occurred while reading in file. Assuming that we are creating a new one: {e}') - self.config.add_section(self.SECTION) - - # Ensure that our section exists + # Ensure that our section exists. This is here because configparser will happily create files for us, but it + # does not magically create sections try: self.config[self.SECTION].get("this_does_not_exist", fallback=None) except KeyError: