Skip to content

Commit

Permalink
Merge pull request #11 from jordantshaw/rc-0.2.1
Browse files Browse the repository at this point in the history
Fixing issue with config_file_encoding not working
  • Loading branch information
jordantshaw committed Jul 19, 2023
2 parents 3621621 + 792faaf commit 3485db7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "pydantic-config"
description = "Support for Pydantic settings configuration file loading"
version = "0.2.0"
version = "0.2.1"
authors = [{name="Jordan Shaw"}]
readme = "README.md"
requires-python = ">=3.7"
Expand Down
9 changes: 5 additions & 4 deletions src/pydantic_config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SettingsError(ValueError):
pass


class SettingsConfig(SettingsConfigDict):
class SettingsConfig(SettingsConfigDict, total=False):
config_file: Union[ConfigFileType, None]
config_file_encoding: Union[str, None]
config_merge: bool
Expand Down Expand Up @@ -56,14 +56,15 @@ def __init__(
settings_cls: Type[BaseSettings],
case_sensitive: Union[bool, None] = None,
config_file: Union[ConfigFileType, None] = None,
file_encoding: Union[str, None] = None,
config_file_encoding: Union[str, None] = None,
config_merge: bool = True,
config_merge_unique: bool = True,

) -> None:
super().__init__(settings_cls, case_sensitive)
self.config: SettingsConfig
self.config_file = config_file or self.config.get('config_file', None)
self.file_encoding = file_encoding or self.config.get('file_encoding', None)
self.config_file_encoding = config_file_encoding or self.config.get('config_file_encoding', None)
self.config_merge = config_merge or self.config.get('config_merge', True)
self.config_merge_unique = config_merge_unique or self.config.get('config_merge_unique', True)
self.config_values = self._load_config_values()
Expand Down Expand Up @@ -125,7 +126,7 @@ def _read_config_file(self, file: Path) -> Dict[str, Any]:
'.json': json_file_reader,
}

return file_loaders.get(file.suffix)(str(file), self.file_encoding)
return file_loaders.get(file.suffix)(str(file), self.config_file_encoding)

def __call__(self) -> Dict[str, Any]:
data: Dict[str, Any] = super().__call__()
Expand Down

0 comments on commit 3485db7

Please sign in to comment.