Coverage for src/ss_python/settings.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-20 08:23 +0000

1"""Settings Module.""" 

2 

3import logging 

4from logging import getLevelName 

5from typing import Optional 

6 

7from pydantic_settings import BaseSettings, SettingsConfigDict 

8 

9 

10class GlobalSettings(BaseSettings): 

11 """System level settings.""" 

12 

13 ci: bool = False 

14 """Indicator for whether or not in CI/CD environment.""" 

15 

16 

17class Settings(BaseSettings): 

18 """Project specific settings.""" 

19 

20 logging_level: Optional[str] = getLevelName(logging.INFO) 

21 """Default logging level for the project.""" 

22 

23 model_config = SettingsConfigDict( 

24 env_prefix="SS_PYTHON_", 

25 ) 

26 

27 

28# NOTE(huxuan): `#:` style docstring is required for module attributes to satisfy both 

29# autodoc [1] and `check-docstring-first` in `pre-commit` [2]. 

30# [1] https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-autoattribute 

31# [2] https://github.com/pre-commit/pre-commit-hooks/issues/159#issuecomment-559886109 

32 

33#: Instance for system level settings. 

34global_settings = GlobalSettings() 

35 

36#: Instance for project specific settings. 

37settings = Settings()