diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2025-08-16 08:43:11 -0400 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2025-08-16 08:43:11 -0400 |
| commit | 837b9b8f8ba4c395ea6379ac243adcd7a5ac4c92 (patch) | |
| tree | 8d367b1f0cfb2c29060d0a312be9f0aa32590c7e /config_file | |
| parent | Remove -x for run tests (diff) | |
| download | config-file-837b9b8f8ba4c395ea6379ac243adcd7a5ac4c92.zip | |
Fix config file path subclasses in 3.13
Diffstat (limited to 'config_file')
| -rw-r--r-- | config_file/config_file.py | 2 | ||||
| -rw-r--r-- | config_file/config_file_path.py | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/config_file/config_file.py b/config_file/config_file.py index 079c903..b5083ff 100644 --- a/config_file/config_file.py +++ b/config_file/config_file.py @@ -24,7 +24,7 @@ class ConfigFile: ParsingError: If the file_path could not be parsed. """ self.__path = ConfigFilePath(file_path).validate() - self.__parser = self.__path.parser + self.__parser = self.__path.file_parser @property def path(self) -> Path: diff --git a/config_file/config_file_path.py b/config_file/config_file_path.py index 1daad7b..e4f3ef7 100644 --- a/config_file/config_file_path.py +++ b/config_file/config_file_path.py @@ -1,6 +1,5 @@ import os -from pathlib import Path -from typing import Type +import pathlib from config_file.parsers.abstract_parser import AbstractParser from config_file.parsers.ini_parser import IniParser @@ -10,8 +9,12 @@ from config_file.parsers.yaml_parser import YamlParser from .utils import split_on_dot +if os.name == "nt": + base = pathlib.WindowsPath +else: + base = pathlib.PosixPath -class ConfigFilePath(type(Path())): +class ConfigFilePath(base): """A ConfigFilePath object, which subclasses Path. It provides us easy ways to grab the original config file @@ -47,7 +50,7 @@ class ConfigFilePath(type(Path())): return extension[1:] @property - def parser(self) -> Type[AbstractParser]: + def file_parser(self) -> AbstractParser: """Determine what parser should be used for this file. Raises: |