[docutils] Allow directive subclasses to type their options
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
Directive.options is annotated as dict[str, Incomplete]. Although each
directive subclass knows the keys and converted value types defined by its
option_spec, it cannot express that shape, forcing downstream code to
propagate Any or add casts and suppressions. One example is
https://github.com/adamtheturtle/sphinx-literalizer/pull/516.
Could Directive accept an option-mapping type parameter, defaulting to the
current incomplete mapping for compatibility? This would let subclasses use a
TypedDict for their converted options. Other designs that allow subclasses to
specialize options would also solve the problem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the docutils Directive entry point, focusing on the options annotation and option_spec relationship. Explore how a generic option-mapping parameter could preserve the current incomplete mapping by default while allowing subclasses to use a TypedDict; done means downstream code can obtain specialized converted option types without Any, casts, or suppressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100