typeshed
typeshed copied to clipboard
Improving type annotations in Sphinx
@JelleZijlstra, @srittau thanks for all your help with the docutils type stubs.
The point of all these PRs is facilitate migrating the venerable Sphinx project from docutils-stubs to types-docutils.
There's a PR for that here - https://github.com/sphinx-doc/sphinx/pull/12012
there's still a number of errors remaining. Some are issues with Sphinx, others with the type annotations themselves. I wonder if you have any bandwidth to help me get this PR over the line, and get Sphinx using typeshed once and for all?
i have a lot of these sort of errors:
sphinx/util/docutils.py: note: In function "register_role":
sphinx/util/docutils.py:104:37: error: Argument 2 to "register_local_role" has incompatible type "Callable[[str, str, str, int, Inliner, dict[str, Any], Sequence[str]], tuple[list[Node], list[system_message]]]"; expected "Callable[[str, str, str, int, Inliner, Mapping[str, Any], Sequence[str]], tuple[Sequence[reference], Sequence[reference]]]" [arg-type]
sphinx/util/docutils.py: note: In function "patched_get_language":
sphinx/util/docutils.py:153:43: error: Incompatible types in assignment (expression has type "Callable[[str, Optional[Reporter]], Any]", variable has type "LanguageImporter") [assignment]
sphinx/util/docutils.py: note: In function "patched_rst_get_language":
sphinx/util/docutils.py:177:55: error: Incompatible types in assignment (expression has type "Callable[[str, Optional[Reporter]], Any]", variable has type "RstLanguageImporter") [assignment]
sphinx/util/docutils.py: note: In member "enable" of class "CustomReSTDispatcher":
sphinx/util/docutils.py:266:32: error: Incompatible types in assignment (expression has type "Callable[[str, Module, document], tuple[Optional[type[Directive]], list[system_message]]]", variable has type "Callable[[str, _LanguageModule, document], tuple[Optional[type[Directive]], list[SystemMessage]]]") [assignment]
sphinx/util/docutils.py:267:[22](https://github.com/sphinx-doc/sphinx/actions/runs/8313640709/job/22749851894?pr=12012#step:5:23): error: Incompatible types in assignment (expression has type "Callable[[str, Module, int, Reporter], tuple[Callable[[str, str, str, int, Inliner, dict[str, Any], Sequence[str]], tuple[list[Node], list[system_message]]], list[system_message]]]", variable has type "Callable[[str, _LanguageModule, int, Reporter], tuple[Optional[Callable[[str, str, str, int, Inliner, Mapping[str, Any], Sequence[str]], tuple[Sequence[reference], Sequence[reference]]]], list[SystemMessage]]]") [assignment]
have i typed the callable incorrectly? should this be using a protocol instead or something?