diff --git a/config_converter/converters/base.py b/config_converter/converters/base.py index 5f51fbc..15ec6bb 100644 --- a/config_converter/converters/base.py +++ b/config_converter/converters/base.py @@ -2,7 +2,7 @@ from abc import ABC, abstractmethod from pathlib import Path -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union class ConversionError(Exception): @@ -18,11 +18,11 @@ class BaseConverter(ABC): FILE_EXTENSIONS: list[str] = [] @abstractmethod - def read(self, source: str | Path) -> Dict[str, Any]: + def read(self, source: Union[str, Path]) -> Dict[str, Any]: """Read and parse a configuration file.""" @abstractmethod - def write(self, data: Dict[str, Any], target: str | Path) -> None: + def write(self, data: Dict[str, Any], target: Union[str, Path]) -> None: """Write configuration data to a file.""" @abstractmethod @@ -62,7 +62,7 @@ class BaseConverter(ABC): return ["json", "yaml", "yml", "toml", "ini"] @classmethod - def guess_format(cls, filepath: str | Path) -> Optional[str]: + def guess_format(cls, filepath: Union[str, Path]) -> Optional[str]: """Guess format from file extension.""" ext = Path(filepath).suffix.lower().lstrip(".") format_map: Dict[str, str] = {