Coverage for src / puzzletree / config / main_config.py: 100.00%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-12 20:35 +0000

1"""Configuration management for puzzletree.""" 

2 

3# Template note: These imports are kept for potential future use in template expansions 

4# They may be used conditionally based on template variables or in extended configurations 

5import json # noqa: F401 - Reserved for future JSON config file handling 

6from pathlib import Path # noqa: F401 - Reserved for future path-based config loading 

7 

8from pydantic import ( # noqa: F401 - Reserved for future field validation 

9 Field, 

10 field_validator, 

11 model_validator, 

12) 

13from pydantic_settings import ( 

14 BaseSettings, 

15 JsonConfigSettingsSource, # noqa: F401 - Reserved for future JSON config source 

16 PydanticBaseSettingsSource, # noqa: F401 - Reserved for future custom config sources 

17 SettingsConfigDict, 

18) 

19 

20from puzzletree._version import get_version 

21 

22 

23class Config(BaseSettings): 

24 """Configuration class for loading environment variables. 

25 

26 This class uses pydantic and pydantic-settings to define and load environment variables. 

27 It supports loading from .env and .env.prod files (lowest to highest priority), 

28 and uses field validators for data validation. 

29 """ 

30 

31 schema_version: str = "1.0.0" 

32 model_config = SettingsConfigDict( 

33 env_file=(".env", ".env.dev", ".env.prod"), 

34 env_file_encoding="utf-8", 

35 json_file="puzzletree_config.json", 

36 ) 

37 # Configurations for the application 

38 app_name: str = "puzzletree" 

39 app_description: str = "JigSaw Puzzle reconstruction with Spanning Trees." 

40 app_author: str = "lalmei" 

41 app_version: str = get_version() 

42 log_format: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"