Skip to content

type annotation for docutils is incomplete #1269

Closed
@tk0miya

Description

@tk0miya

It seems third_party/3/docutils contains only very few classes and modules of docutils.
https://github.com/python/typeshed/tree/master/third_party/3/docutils

For example, the only one class reference is defined at nodes.pyi. But actual docutils.nodes module provides many classes and functions:

>>> import docutils.nodes
>>> dir(docutils.nodes)
['Admonition', 'BackLinkable', 'Bibliographic', 'Body', 'Decorative', 'Element', 'FixedTextElement', 'General', 'GenericNodeVisitor', 'Inline', 'Invisible', 'Labeled', 'Node', 'NodeFound', 'NodeVisitor', 'Part', 'PreBibliographic', 'Referential', 'Resolvable', 'Root', 'Sequential', 'SkipChildren', 'SkipDeparture', 'SkipNode', 'SkipSiblings', 'SparseNodeVisitor', 'Special', 'StopTraversal', 'Structural', 'Targetable', 'Text', 'TextElement', 'Titular', 'TreeCopyVisitor', 'TreePruningException', '__builtins__', '__cached__', '__doc__', '__docformat__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_add_node_class_names', '_call_default_departure', '_call_default_visit', '_non_id_at_ends', '_non_id_chars', '_non_id_translate', '_non_id_translate_digraphs', '_nop', 'abbreviation', 'acronym', 'address', 'admonition', 'attention', 'attribution', 'author', 'authors', 'block_quote', 'bullet_list', 'caption', 'caution', 'citation', 'citation_reference', 'classifier', 'colspec', 'comment', 'compound', 'contact', 'container', 'copyright', 'danger', 'date', 'decoration', 'definition', 'definition_list', 'definition_list_item', 'description', 'docinfo', 'doctest_block', 'document', 'dupname', 'emphasis', 'ensure_str', 'entry', 'enumerated_list', 'error', 'field', 'field_body', 'field_list', 'field_name', 'figure', 'footer', 'footnote', 'footnote_reference', 'fully_normalize_name', 'generated', 'header', 'hint', 'image', 'important', 'inline', 'label', 'legend', 'line', 'line_block', 'list_item', 'literal', 'literal_block', 'make_id', 'math', 'math_block', 'node_class_names', 'note', 'option', 'option_argument', 'option_group', 'option_list', 'option_list_item', 'option_string', 'organization', 'os', 'paragraph', 'pending', 'problematic', 'pseudo_quoteattr', 'raw', 're', 'reference', 'reprunicode', 'revision', 'row', 'rubric', 'section', 'serial_escape', 'sidebar', 'status', 'strong', 'subscript', 'substitution_definition', 'substitution_reference', 'subtitle', 'superscript', 'sys', 'system_message', 'table', 'target', 'tbody', 'term', 'tgroup', 'thead', 'tip', 'title', 'title_reference', 'topic', 'transition', 'types', 'unicodedata', 'version', 'warning', 'warnings', 'whitespace_normalize_name']

As a result, mypy fails for hinting.

from docutils import nodes

def hello(node):
    # type: (nodes.Node) -> None
    pass
$ mypy foo.py
foo.py:3: error: Name 'nodes.Node' is not defined

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedAn actionable problem of low to medium complexity where a PR would be very welcomestubs: incompleteAnnotations or sub-modules missing from an existing package or module

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions