Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving type annotations in Sphinx #11621

Open
danieleades opened this issue Mar 17, 2024 · 1 comment
Open

Improving type annotations in Sphinx #11621

danieleades opened this issue Mar 17, 2024 · 1 comment

Comments

@danieleades
Copy link
Contributor

danieleades commented Mar 17, 2024

@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 - sphinx-doc/sphinx#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?

@danieleades
Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants