From 1bd676de068c61c90c4643c2e2976b9f4733646c Mon Sep 17 00:00:00 2001 From: didericis Date: Wed, 3 Jun 2026 23:26:39 -0400 Subject: [PATCH] fix: resolve pyright errors in yaml_subset.py - Add explicit type annotation for cur list in _split_flow - Add unreachable return statement after die() in _split_key_value - Add type cast for parse_yaml_subset return value Co-Authored-By: Claude Haiku 4.5 --- bot_bottle/yaml_subset.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bot_bottle/yaml_subset.py b/bot_bottle/yaml_subset.py index ec4a5f9..e110d95 100644 --- a/bot_bottle/yaml_subset.py +++ b/bot_bottle/yaml_subset.py @@ -58,6 +58,7 @@ from __future__ import annotations import re from dataclasses import dataclass +from typing import cast class YamlSubsetError(ValueError): @@ -283,7 +284,7 @@ def _split_flow(body: str, lineno: int, kind: str) -> list[str]: depth_c = 0 in_single = False in_double = False - cur = [] + cur: list[str] = [] for ch in body: if ch == "'" and not in_double: in_single = not in_single @@ -330,6 +331,7 @@ def _split_key_value(content: str, lineno: int) -> tuple[str, str]: if i + 1 >= len(content) or content[i + 1] in (" ", "\t"): return content[:i].strip(), content[i + 1:].lstrip() die(f"yaml-subset: line {lineno} missing `: ` separator: {content!r}") + return "", "" # unreachable, but needed for type checker def _parse_block( @@ -536,7 +538,7 @@ def parse_yaml_subset(text: str) -> dict[str, object]: ) if not isinstance(value, dict): die("yaml-subset: top-level value must be a mapping") - return value + return cast(dict[str, object], value) def parse_frontmatter(text: str) -> tuple[dict[str, object], str]: