Skip to content

Commit 7f9e84c

Browse files
ayhammoudaclaude
andcommitted
fix(types): resolve 3 pyright errors in sphinx_json.py
- Wrap next_heading.get("id") in str() to satisfy _StrainableAttribute - Use `div.get("class") or []` to avoid list[Any] vs _AttributeValue mismatch - Assert cursor.lastrowid is not None before dict assignment Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dbf081c commit 7f9e84c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/mcp_server_python_docs/ingestion/sphinx_json.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def extract_sections(body_html: str, doc_uri: str) -> list[dict]:
130130
if isinstance(sibling, Tag):
131131
# Check if this tag contains the next heading
132132
if next_heading is not None and sibling.find(
133-
re.compile(r"^h[1-6]$"), id=next_heading.get("id")
133+
re.compile(r"^h[1-6]$"), id=str(next_heading.get("id", ""))
134134
):
135135
break
136136
content_parts.append(str(sibling))
@@ -183,7 +183,7 @@ def extract_code_blocks(body_html: str) -> list[dict]:
183183
)
184184

185185
for i, div in enumerate(highlight_divs):
186-
classes = div.get("class", [])
186+
classes = div.get("class") or []
187187
class_str = " ".join(classes) if isinstance(classes, list) else str(classes)
188188

189189
is_doctest = 1 if "highlight-pycon" in class_str else 0
@@ -297,7 +297,9 @@ def ingest_fjson_file(
297297
section["char_count"],
298298
),
299299
)
300-
section_id_by_anchor[section["anchor"]] = cursor.lastrowid
300+
row_id = cursor.lastrowid
301+
assert row_id is not None
302+
section_id_by_anchor[section["anchor"]] = row_id
301303

302304
# Extract and insert code blocks
303305
code_blocks = extract_code_blocks(body_html)

0 commit comments

Comments
 (0)