Skip to content

[docutils] Allow directive subclasses to type their options #16400

Description

@adamtheturtle

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions