updates type hints, implements linting suggestions

This commit is contained in:
Mose Mueller
2024-01-11 18:03:32 +01:00
parent 480f0f40fc
commit 6592f92cee
4 changed files with 46 additions and 44 deletions

View File

@@ -1,6 +1,6 @@
import logging
from pathlib import Path
from typing import Optional, TypeVar
from typing import TypeVar
from confz import BaseConfig, FileSource
@@ -15,7 +15,7 @@ class NoConfigSourceError(Exception):
def create_config(
config_class: type[T],
config_folder: Optional[Path | str] = None,
config_folder: Path | str | None = None,
config_file: str = "",
) -> T:
if config_class.CONFIG_SOURCES is not None or config_folder is not None:
@@ -23,13 +23,13 @@ def create_config(
if config_folder is not None:
config_sources = FileSource(Path(config_folder) / config_file)
return config_class(config_sources=config_sources)
else:
error_msg = (
"No 'database_config' folder found in the root directory. Please ensure "
"that a 'database_config' folder exists in your project's root directory. "
"Alternatively, you can provide a different config folder by passing its "
"path to the constructor."
)
logger.error(error_msg)
raise NoConfigSourceError(error_msg)
error_msg = (
"No 'database_config' folder found in the root directory. Please ensure "
"that a 'database_config' folder exists in your project's root directory. "
"Alternatively, you can provide a different config folder by passing its "
"path to the constructor."
)
logger.error(error_msg)
raise NoConfigSourceError(error_msg)