Coverage for lintro / enums / pydoclint_style.py: 0%

15 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Pydoclint docstring style options.""" 

2 

3from __future__ import annotations 

4 

5from enum import StrEnum, auto 

6 

7from loguru import logger 

8 

9 

10class PydoclintStyle(StrEnum): 

11 """Docstring style formats recognized by pydoclint.""" 

12 

13 GOOGLE = auto() 

14 NUMPY = auto() 

15 SPHINX = auto() 

16 

17 

18def normalize_pydoclint_style( 

19 value: str | PydoclintStyle, 

20) -> PydoclintStyle: 

21 """Normalize a style value, defaulting to GOOGLE on error. 

22 

23 Args: 

24 value: String or enum member representing style. 

25 

26 Returns: 

27 PydoclintStyle: Normalized style enum value. 

28 """ 

29 if isinstance(value, PydoclintStyle): 

30 return value 

31 try: 

32 return PydoclintStyle[value.upper()] 

33 except (KeyError, AttributeError) as e: 

34 logger.debug( 

35 f"Invalid PydoclintStyle value '{value}': {e}. Defaulting to GOOGLE.", 

36 ) 

37 return PydoclintStyle.GOOGLE