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

12 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-31 13:48 +0000

1"""Settings Module.""" 

2 

3import logging 

4from logging import getLevelName 

5 

6from pydantic_settings import BaseSettings, SettingsConfigDict 

7 

8 

9class GlobalSettings(BaseSettings): 

10 """System level settings.""" 

11 

12 ci: bool = False 

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

14 

15 

16class Settings(BaseSettings): 

17 """Project specific settings.""" 

18 

19 logging_level: str | None = getLevelName(logging.INFO) 

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

21 

22 model_config = SettingsConfigDict( 

23 env_prefix="IPTVTOOLS_", 

24 ) 

25 

26 

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

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

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

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

31 

32#: Instance for system level settings. 

33global_settings = GlobalSettings() 

34 

35#: Instance for project specific settings. 

36settings = Settings()