(self, backup: bool = True)
| 167 | return self.config |
| 168 | |
| 169 | def write(self, backup: bool = True) -> None: |
| 170 | content = self._generate_content() |
| 171 | |
| 172 | if self.config_path.exists(): |
| 173 | try: |
| 174 | with self.config_path.open("r", encoding="utf-8") as f: |
| 175 | current = f.read() |
| 176 | if current == content: |
| 177 | return |
| 178 | except Exception: |
| 179 | pass |
| 180 | |
| 181 | effective_backup = ( |
| 182 | backup and self.auto_backup_enabled and self.config_path.exists() |
| 183 | ) |
| 184 | if effective_backup and not self._have_backed_up_this_session: |
| 185 | self._backup_file() |
| 186 | self._have_backed_up_this_session = True |
| 187 | |
| 188 | self._atomic_write(content) |
| 189 | |
| 190 | def validate(self) -> List[str]: |
| 191 | errors: List[str] = [] |
no test coverage detected