From 9091a41ece3a2384ba36a4e524fc3ee1acea129e Mon Sep 17 00:00:00 2001 From: Normann Date: Fri, 21 Aug 2026 02:29:40 +0200 Subject: [PATCH] test: satisfy mypy for docutils settings API --- tests/test_docstringrst.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_docstringrst.py b/tests/test_docstringrst.py index ad482a72..a9becb25 100644 --- a/tests/test_docstringrst.py +++ b/tests/test_docstringrst.py @@ -6,8 +6,9 @@ import re import sys from difflib import SequenceMatcher from pathlib import Path +from typing import cast -from docutils import nodes +from docutils import SettingsSpec, nodes from docutils.core import publish_parts from docutils.frontend import get_default_settings from docutils.parsers.rst import Directive, Parser, directives @@ -256,8 +257,10 @@ def validate_rst(text: str) -> list[tuple[int, str]]: warnings.append((line or 0, message)) return nodes.system_message(message, level=level, type=self.levels[level], *children, **kwargs) - # Create default parser settings without the deprecated Docutils OptionParser. - settings = get_default_settings(Parser) + # Docutils expects the SettingsSpec subclass itself here. The stubs bundled with + # our current docutils/types-docutils pins still describe this argument as an + # instance; upstream fixed that annotation in 2026. + settings = get_default_settings(cast(SettingsSpec, Parser)) document = new_document("", settings=settings)