|
4 | 4 | from pathlib import Path |
5 | 5 | from typing import Any, Optional, Union |
6 | 6 |
|
7 | | -from tomlkit import TOMLDocument, dumps, parse, table |
| 7 | +from tomlkit import TOMLDocument, dumps, load, table |
8 | 8 |
|
9 | 9 | from twyn.base.constants import ( |
10 | 10 | DEFAULT_PROJECT_TOML_FILE, |
|
22 | 22 | TOMLError, |
23 | 23 | ) |
24 | 24 | from twyn.file_handler.exceptions import PathNotFoundError |
25 | | -from twyn.file_handler.file_handler import BaseFileHandler |
| 25 | +from twyn.file_handler.file_handler import FileHandler |
26 | 26 |
|
27 | 27 | logger = logging.getLogger("twyn") |
28 | 28 |
|
@@ -54,7 +54,7 @@ class ReadTwynConfiguration: |
54 | 54 | class ConfigHandler: |
55 | 55 | """Manage reading and writing configurations for Twyn.""" |
56 | 56 |
|
57 | | - def __init__(self, file_handler: Optional[BaseFileHandler] = None) -> None: |
| 57 | + def __init__(self, file_handler: Optional[FileHandler] = None) -> None: |
58 | 58 | self.file_handler = file_handler |
59 | 59 |
|
60 | 60 | def resolve_config( |
@@ -160,7 +160,8 @@ def _read_toml(self) -> TOMLDocument: |
160 | 160 | if not self.file_handler: |
161 | 161 | raise ConfigFileNotConfiguredError("Config file not configured. Cannot perform read operation.") |
162 | 162 | try: |
163 | | - return parse(self.file_handler.read()) |
| 163 | + with self.file_handler.open("rb") as fp: |
| 164 | + return load(fp) |
164 | 165 | except PathNotFoundError: |
165 | 166 | if self.file_handler.is_handler_of_file(DEFAULT_PROJECT_TOML_FILE): |
166 | 167 | return TOMLDocument() |
|
0 commit comments