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
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
1"""Pydoclint docstring style options."""
3from __future__ import annotations
5from enum import StrEnum, auto
7from loguru import logger
10class PydoclintStyle(StrEnum):
11 """Docstring style formats recognized by pydoclint."""
13 GOOGLE = auto()
14 NUMPY = auto()
15 SPHINX = auto()
18def normalize_pydoclint_style(
19 value: str | PydoclintStyle,
20) -> PydoclintStyle:
21 """Normalize a style value, defaulting to GOOGLE on error.
23 Args:
24 value: String or enum member representing style.
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