FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[docutils] Allow typing Directive options by adamtheturtle · Pull Request #16401 · python/typeshed · GitHub

Repository navigation

[docutils] Allow typing Directive options - #16401

Open
adamtheturtle wants to merge 4 commits into
python:mainfrom
adamtheturtle:docutils-generic-options
Open

adamtheturtle wants to merge 4 commits into
python:mainfrom
adamtheturtle:docutils-generic-options

Conversation

adamtheturtle commented Sep 16, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Closes #16400.

Allow subclasses to type Directive.options as a TypedDict; Docutils
documents that converted values depend on each directive.
The constructor still accepts dict[str, Incomplete].

Agent: Codex.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

srittau commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

I'm trying to understand the problem: The Directive.options is sub-class specific, so ideally each sub-class would type it as a TypedDict. And in the PR you linked, you would ideally also return a TypedDict from _options_with_language_defaults and use that as argument to _common_option_args.

Is that correct? Where and how would you defined the accepted fields? Like this?

class FooDirective(Directive[MyTypedDict]):
    ...

Would this work at the moment?

class FooDirective(Directive):
    options: MyTypedDict

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/domains/python/_object.py:440: error: Unused "type: ignore" comment  [unused-ignore]

Copy link
Copy Markdown
Contributor Author

Thank you for the review @srittau . I'm experimenting and iterating before answering!

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Successfully merging this pull request may close these issues.

[docutils] Allow directive subclasses to type their options

2 participants


Back | FazBrowse Home | New Git URL