(value: Optional[str])
| 39 | |
| 40 | |
| 41 | def _parse_month(value: Optional[str]) -> str: |
| 42 | text = _clean_text(value) or datetime.now().strftime("%Y-%m") |
| 43 | if not re.fullmatch(r"\d{4}-\d{2}", text): |
| 44 | raise ValueError("month must use YYYY-MM format, for example 2026-05") |
| 45 | year, month = text.split("-") |
| 46 | number = int(month) |
| 47 | if number < 1 or number > 12: |
| 48 | raise ValueError("month must be between 01 and 12") |
| 49 | return f"{int(year):04d}-{number:02d}" |
| 50 | |
| 51 | |
| 52 | def _month_label(month: str) -> str: |
no test coverage detected