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
adamtheturtle/sphinx-literalizer#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.
Directive.optionsis annotated asdict[str, Incomplete]. Although eachdirective subclass knows the keys and converted value types defined by its
option_spec, it cannot express that shape, forcing downstream code topropagate
Anyor add casts and suppressions. One example isadamtheturtle/sphinx-literalizer#516.
Could
Directiveaccept an option-mapping type parameter, defaulting to thecurrent incomplete mapping for compatibility? This would let subclasses use a
TypedDictfor their converted options. Other designs that allow subclasses tospecialize
optionswould also solve the problem.