Skip to content

type annotation for docutils is incomplete #1269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tk0miya opened this issue May 13, 2017 · 25 comments
Closed

type annotation for docutils is incomplete #1269

tk0miya opened this issue May 13, 2017 · 25 comments
Labels
help wanted An actionable problem of low to medium complexity where a PR would be very welcome stubs: incomplete Annotations or sub-modules missing from an existing package or module

Comments

@tk0miya
Copy link

tk0miya commented May 13, 2017

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
@tk0miya
Copy link
Author

tk0miya commented Jun 4, 2017

Is there anything I can do? If needed, I'll try to create stubs.

@JelleZijlstra
Copy link
Member

Thanks for reporting this! Yes, sounds like we just need to write more stubs. PRs would be appreciated.

@tk0miya
Copy link
Author

tk0miya commented Jun 4, 2017

I'm reading CONTRIBUTING.md now. Did you already get permission from docutils project?
If done, I'll try to do it.

@JelleZijlstra
Copy link
Member

I'm not sure actually—it looks like the docutils stubs were added back in 2015 (337abed), when typeshed's norms weren't as clearly established. Perhaps @matthiaskramm remembers; I couldn't find anything on a quick search of the docutils mailing lists.

@matthiaskramm
Copy link
Contributor

337abed merged pytype's and mypy's stubs. The docutils stubs go back to 2014, when mypy still had its own pyi files.
(See e.g. python/mypy@81d515c)

@jdufresne
Copy link
Contributor

Until more complete stubs can be generated, would it be reasonable to delete the nodes.pyi file? It is extremely incomplete (just one file so not that useful) and results in the Name 'nodes.Node' is not defined described above. What do you think?

@srittau srittau added the stubs: incomplete Annotations or sub-modules missing from an existing package or module label Oct 28, 2018
@danieleades
Copy link
Contributor

not sure if this is the right place for this, but i'm having trouble getting mypy to perform typechecking of the reference class.

i'm working through the sphinx extension 'todo' tutorial here - https://www.sphinx-doc.org/en/master/development/tutorials/todo.html

but mypy is none too happy about the docutils types-

...
# Create a reference
newnode = nodes.reference("", "")
innernode = nodes.emphasis(_("here"), _("here"))
newnode["refdocname"] = todo_info["docname"]  # error: Unsupported target for indexed assignment ("reference")
...

now, looking at the docutils source code, this should be ok.

reference is derived from the Element class, which implements __getitem__ and __setitem__, so it should be fine. Indeed at runtime it is fine.

why is mypy failing to recognise the base class?

i see only this stub - https://github.com/python/typeshed/blob/4d734e38dde295e93c27efd6ead3bb5c05d03fe5/stubs/docutils/docutils/nodes.pyi, but it doesn't appear to include the base classes.

(I don't know anything about these stub files by the way)

@Akuli
Copy link
Collaborator

Akuli commented Apr 20, 2021

The docutils stubs were added in #5192, and lots of things are missing from them, including the whole Element class. Feel free to create pull requests that improve them. Let us know if you need help with that.

@danieleades
Copy link
Contributor

The docutils stubs were added in #5192, and lots of things are missing from them, including the whole Element class. Feel free to create pull requests that improve them. Let us know if you need help with that.

i need help with that

can you point me to any references on how to write stub files? best practices?

@danieleades
Copy link
Contributor

seems like it should be possible (in principle) to generate stub files from the source code. is there a tool for that?

@Akuli
Copy link
Collaborator

Akuli commented Apr 20, 2021

stubgen is a tool that generates stubs from source code, but before we rewrite the stubs with it, maybe @srittau should tell us what exactly he did in #5192. Afaik stubgen shouldn't result in so many classes missing.

Stub file syntax is a subset of Python syntax, so there isn't much to learn. Best practices etc are explained in CONTRIBUTING.md.

@danieleades
Copy link
Contributor

Will try and find some time over the next couple of days to investigate

@srittau
Copy link
Collaborator

srittau commented Apr 20, 2021

For reference, #5192 did not add docutils stubs, they existed before, but were mainly consisting of module-level __getattr__() definitions. I filled it out a bit more. More specifically, docutils.nodes.reference is pre-existing, but seems just plain wrong when compared with the implementation. I opened #5235, which just removes it for now.

@danieleades
Copy link
Contributor

i'm about a third of the way through the type annotations for the Element class and i think i know why no one has done this before...

@hauntsaninja
Copy link
Collaborator

In case it's useful, here's what stubtest has to say about docutils on master:

docutils.TransformSpec.unknown_reference_resolvers variable differs from runtime type Tuple[]
docutils.core.Publisher is not present in stub
docutils.core.publish_cmdline is not present in stub
docutils.core.publish_cmdline_to_binary is not present in stub
docutils.core.publish_doctree is not present in stub
docutils.core.publish_file is not present in stub
docutils.core.publish_from_doctree is not present in stub
docutils.core.publish_parts is not present in stub
docutils.core.publish_programmatically is not present in stub
docutils.core.publish_string is not present in stub
docutils.examples.html_body is not present in stub
docutils.examples.html_parts is not present in stub
docutils.examples.internals is not present in stub
docutils.frontend.ConfigParser.__getattr__ is not present at runtime
docutils.frontend.ConfigParser.get_section is not present in stub
docutils.frontend.ConfigParser.handle_old_config is not present in stub
docutils.frontend.ConfigParser.not_utf8_error is not present in stub
docutils.frontend.ConfigParser.old_settings is not present in stub
docutils.frontend.ConfigParser.old_warning is not present in stub
docutils.frontend.ConfigParser.read is inconsistent, stub argument "encoding" differs from runtime argument "option_parser"
docutils.frontend.ConfigParser.read is inconsistent, stub argument "encoding" has a default value but runtime argument does not
docutils.frontend.ConfigParser.validate_settings is not present in stub
docutils.frontend.OptionParser.__getattr__ is not present at runtime
docutils.frontend.OptionParser.__init__ is inconsistent, stub argument "usage" differs from runtime argument "components"
docutils.frontend.OptionParser.__init__ is inconsistent, runtime argument "components" has a default value of type Tuple[], which is incompatible with stub argument type Union[builtins.str, None]
docutils.frontend.OptionParser.__init__ is inconsistent, stub argument "option_list" differs from runtime argument "defaults"
docutils.frontend.OptionParser.__init__ is inconsistent, stub argument "option_class" differs from runtime argument "read_config_files"
docutils.frontend.OptionParser.__init__ is inconsistent, runtime argument "read_config_files" has a default value of type None, which is incompatible with stub argument type Type[optparse.Option]
docutils.frontend.OptionParser.check_args is not present in stub
docutils.frontend.OptionParser.get_config_file_settings is not present in stub
docutils.frontend.OptionParser.get_option_by_dest is not present in stub
docutils.frontend.OptionParser.get_standard_config_files is not present in stub
docutils.frontend.OptionParser.get_standard_config_settings is not present in stub
docutils.frontend.OptionParser.populate_from_components is not present in stub
docutils.frontend.OptionParser.set_defaults_from_dict is not present in stub
docutils.frontend.Values.setdefault is not present in stub
docutils.frontend.validate_ternary is not present in stub
docutils.io.FileOutput.__getattr__ is not present at runtime
docutils.io.FileOutput.__init__ is inconsistent, stub does not have argument "autoclose"
docutils.io.FileOutput.__init__ is inconsistent, stub does not have argument "handle_io_errors"
docutils.io.FileOutput.__init__ is inconsistent, stub does not have argument "mode"
docutils.io.FileOutput.close is not present in stub
docutils.io.FileOutput.open is not present in stub
docutils.io.Input.__getattr__ is not present at runtime
docutils.io.Input.__init__ is inconsistent, stub does not have argument "source"
docutils.io.Input.__init__ is inconsistent, stub does not have argument "source_path"
docutils.io.Input.__init__ is inconsistent, stub does not have argument "encoding"
docutils.io.Input.__init__ is inconsistent, stub does not have argument "error_handler"
docutils.io.Input.byte_order_marks is not present in stub
docutils.io.Input.coding_slug is not present in stub
docutils.io.Input.decode is not present in stub
docutils.io.Input.determine_encoding_from_data is not present in stub
docutils.languages.LanguageImporter is not present in stub
docutils.languages.get_language is not present in stub
docutils.nodes.Admonition is not present in stub
docutils.nodes.BackLinkable is not present in stub
docutils.nodes.Bibliographic is not present in stub
docutils.nodes.Body is not present in stub
docutils.nodes.Decorative is not present in stub
docutils.nodes.Element is not present in stub
docutils.nodes.FixedTextElement is not present in stub
docutils.nodes.General is not present in stub
docutils.nodes.GenericNodeVisitor is not present in stub
docutils.nodes.Inline is not present in stub
docutils.nodes.Invisible is not present in stub
docutils.nodes.Labeled is not present in stub
docutils.nodes.Node is not present in stub
docutils.nodes.NodeFound is not present in stub
docutils.nodes.NodeVisitor is not present in stub
docutils.nodes.Part is not present in stub
docutils.nodes.PreBibliographic is not present in stub
docutils.nodes.Referential is not present in stub
docutils.nodes.Resolvable is not present in stub
docutils.nodes.Root is not present in stub
docutils.nodes.Sequential is not present in stub
docutils.nodes.SkipChildren is not present in stub
docutils.nodes.SkipDeparture is not present in stub
docutils.nodes.SkipNode is not present in stub
docutils.nodes.SkipSiblings is not present in stub
docutils.nodes.SparseNodeVisitor is not present in stub
docutils.nodes.Special is not present in stub
docutils.nodes.StopTraversal is not present in stub
docutils.nodes.Structural is not present in stub
docutils.nodes.Targetable is not present in stub
docutils.nodes.Text is not present in stub
docutils.nodes.TextElement is not present in stub
docutils.nodes.Titular is not present in stub
docutils.nodes.TreeCopyVisitor is not present in stub
docutils.nodes.TreePruningException is not present in stub
docutils.nodes.abbreviation is not present in stub
docutils.nodes.acronym is not present in stub
docutils.nodes.address is not present in stub
docutils.nodes.admonition is not present in stub
docutils.nodes.attention is not present in stub
docutils.nodes.attribution is not present in stub
docutils.nodes.author is not present in stub
docutils.nodes.authors is not present in stub
docutils.nodes.block_quote is not present in stub
docutils.nodes.bullet_list is not present in stub
docutils.nodes.caption is not present in stub
docutils.nodes.caution is not present in stub
docutils.nodes.citation is not present in stub
docutils.nodes.citation_reference is not present in stub
docutils.nodes.classifier is not present in stub
docutils.nodes.colspec is not present in stub
docutils.nodes.comment is not present in stub
docutils.nodes.compound is not present in stub
docutils.nodes.contact is not present in stub
docutils.nodes.container is not present in stub
docutils.nodes.copyright is not present in stub
docutils.nodes.danger is not present in stub
docutils.nodes.date is not present in stub
docutils.nodes.decoration is not present in stub
docutils.nodes.definition is not present in stub
docutils.nodes.definition_list is not present in stub
docutils.nodes.definition_list_item is not present in stub
docutils.nodes.description is not present in stub
docutils.nodes.docinfo is not present in stub
docutils.nodes.doctest_block is not present in stub
docutils.nodes.document is not present in stub
docutils.nodes.dupname is not present in stub
docutils.nodes.emphasis is not present in stub
docutils.nodes.ensure_str is not present in stub
docutils.nodes.entry is not present in stub
docutils.nodes.enumerated_list is not present in stub
docutils.nodes.error is not present in stub
docutils.nodes.field is not present in stub
docutils.nodes.field_body is not present in stub
docutils.nodes.field_list is not present in stub
docutils.nodes.field_name is not present in stub
docutils.nodes.figure is not present in stub
docutils.nodes.footer is not present in stub
docutils.nodes.footnote is not present in stub
docutils.nodes.footnote_reference is not present in stub
docutils.nodes.fully_normalize_name is not present in stub
docutils.nodes.generated is not present in stub
docutils.nodes.header is not present in stub
docutils.nodes.hint is not present in stub
docutils.nodes.image is not present in stub
docutils.nodes.important is not present in stub
docutils.nodes.inline is not present in stub
docutils.nodes.label is not present in stub
docutils.nodes.legend is not present in stub
docutils.nodes.line is not present in stub
docutils.nodes.line_block is not present in stub
docutils.nodes.list_item is not present in stub
docutils.nodes.literal is not present in stub
docutils.nodes.literal_block is not present in stub
docutils.nodes.make_id is not present in stub
docutils.nodes.math is not present in stub
docutils.nodes.math_block is not present in stub
docutils.nodes.note is not present in stub
docutils.nodes.option is not present in stub
docutils.nodes.option_argument is not present in stub
docutils.nodes.option_group is not present in stub
docutils.nodes.option_list is not present in stub
docutils.nodes.option_list_item is not present in stub
docutils.nodes.option_string is not present in stub
docutils.nodes.organization is not present in stub
docutils.nodes.paragraph is not present in stub
docutils.nodes.pending is not present in stub
docutils.nodes.problematic is not present in stub
docutils.nodes.pseudo_quoteattr is not present in stub
docutils.nodes.raw is not present in stub
docutils.nodes.reference is not present in stub
docutils.nodes.revision is not present in stub
docutils.nodes.row is not present in stub
docutils.nodes.rubric is not present in stub
docutils.nodes.section is not present in stub
docutils.nodes.serial_escape is not present in stub
docutils.nodes.sidebar is not present in stub
docutils.nodes.status is not present in stub
docutils.nodes.strong is not present in stub
docutils.nodes.subscript is not present in stub
docutils.nodes.substitution_definition is not present in stub
docutils.nodes.substitution_reference is not present in stub
docutils.nodes.subtitle is not present in stub
docutils.nodes.superscript is not present in stub
docutils.nodes.system_message is not present in stub
docutils.nodes.table is not present in stub
docutils.nodes.target is not present in stub
docutils.nodes.tbody is not present in stub
docutils.nodes.term is not present in stub
docutils.nodes.tgroup is not present in stub
docutils.nodes.thead is not present in stub
docutils.nodes.tip is not present in stub
docutils.nodes.title is not present in stub
docutils.nodes.title_reference is not present in stub
docutils.nodes.topic is not present in stub
docutils.nodes.transition is not present in stub
docutils.nodes.unescape is not present in stub
docutils.nodes.version is not present in stub
docutils.nodes.warning is not present in stub
docutils.nodes.whitespace_normalize_name is not present in stub
docutils.parsers.recommonmark_wrapper.Parser is not present in stub
docutils.parsers.rst.Directive.__getattr__ is not present at runtime
docutils.parsers.rst.Directive.__init__ is inconsistent, stub does not have argument "name"
docutils.parsers.rst.Directive.__init__ is inconsistent, stub does not have argument "arguments"
docutils.parsers.rst.Directive.__init__ is inconsistent, stub does not have argument "options"
docutils.parsers.rst.Directive.__init__ is inconsistent, stub does not have argument "content"
docutils.parsers.rst.Directive.__init__ is inconsistent, stub does not have argument "lineno"
docutils.parsers.rst.Directive.__init__ is inconsistent, stub does not have argument "content_offset"
docutils.parsers.rst.Directive.__init__ is inconsistent, stub does not have argument "block_text"
docutils.parsers.rst.Directive.__init__ is inconsistent, stub does not have argument "state"
docutils.parsers.rst.Directive.__init__ is inconsistent, stub does not have argument "state_machine"
docutils.parsers.rst.Directive.add_name is not present in stub
docutils.parsers.rst.Directive.assert_has_content is not present in stub
docutils.parsers.rst.Directive.debug is not present in stub
docutils.parsers.rst.Directive.directive_error is not present in stub
docutils.parsers.rst.Directive.error is not present in stub
docutils.parsers.rst.Directive.final_argument_whitespace is not present in stub
docutils.parsers.rst.Directive.has_content is not present in stub
docutils.parsers.rst.Directive.info is not present in stub
docutils.parsers.rst.Directive.option_spec is not present in stub
docutils.parsers.rst.Directive.optional_arguments is not present in stub
docutils.parsers.rst.Directive.required_arguments is not present in stub
docutils.parsers.rst.Directive.run is not present in stub
docutils.parsers.rst.Directive.severe is not present in stub
docutils.parsers.rst.Directive.warning is not present in stub
docutils.parsers.rst.nodes failed to import: No module named 'docutils.parsers.rst.nodes'
docutils.parsers.rst.roles.CustomRole is not present in stub
docutils.parsers.rst.roles.GenericRole is not present in stub
docutils.parsers.rst.roles.code_role is not present in stub
docutils.parsers.rst.roles.generic_custom_role is not present in stub
docutils.parsers.rst.roles.math_role is not present in stub
docutils.parsers.rst.roles.pep_reference_role is not present in stub
docutils.parsers.rst.roles.raw_role is not present in stub
docutils.parsers.rst.roles.register_canonical_role is not present in stub
docutils.parsers.rst.roles.register_generic_role is not present in stub
docutils.parsers.rst.roles.rfc_reference_role is not present in stub
docutils.parsers.rst.roles.role is not present in stub
docutils.parsers.rst.roles.set_classes is not present in stub
docutils.parsers.rst.roles.set_implicit_options is not present in stub
docutils.parsers.rst.roles.unimplemented_role is not present in stub
docutils.parsers.rst.states.Body is not present in stub
docutils.parsers.rst.states.BulletList is not present in stub
docutils.parsers.rst.states.Definition is not present in stub
docutils.parsers.rst.states.DefinitionList is not present in stub
docutils.parsers.rst.states.EnumeratedList is not present in stub
docutils.parsers.rst.states.Explicit is not present in stub
docutils.parsers.rst.states.ExtensionOptions is not present in stub
docutils.parsers.rst.states.FieldList is not present in stub
docutils.parsers.rst.states.Inliner.adjust_uri is not present in stub
docutils.parsers.rst.states.Inliner.anonymous_reference is not present in stub
docutils.parsers.rst.states.Inliner.dispatch is not present in stub
docutils.parsers.rst.states.Inliner.email_pattern is not present in stub
docutils.parsers.rst.states.Inliner.emailc is not present in stub
docutils.parsers.rst.states.Inliner.emphasis is not present in stub
docutils.parsers.rst.states.Inliner.footnote_reference is not present in stub
docutils.parsers.rst.states.Inliner.implicit_inline is not present in stub
docutils.parsers.rst.states.Inliner.init_customizations is not present in stub
docutils.parsers.rst.states.Inliner.inline_internal_target is not present in stub
docutils.parsers.rst.states.Inliner.inline_obj is not present in stub
docutils.parsers.rst.states.Inliner.interpreted is not present in stub
docutils.parsers.rst.states.Inliner.interpreted_or_phrase_ref is not present in stub
docutils.parsers.rst.states.Inliner.literal is not present in stub
docutils.parsers.rst.states.Inliner.non_unescaped_whitespace_escape_before is not present in stub
docutils.parsers.rst.states.Inliner.non_whitespace_after is not present in stub
docutils.parsers.rst.states.Inliner.non_whitespace_before is not present in stub
docutils.parsers.rst.states.Inliner.non_whitespace_escape_before is not present in stub
docutils.parsers.rst.states.Inliner.parse is not present in stub
docutils.parsers.rst.states.Inliner.pep_reference is not present in stub
docutils.parsers.rst.states.Inliner.phrase_ref is not present in stub
docutils.parsers.rst.states.Inliner.problematic is not present in stub
docutils.parsers.rst.states.Inliner.quoted_start is not present in stub
docutils.parsers.rst.states.Inliner.reference is not present in stub
docutils.parsers.rst.states.Inliner.rfc_reference is not present in stub
docutils.parsers.rst.states.Inliner.rfc_url is not present in stub
docutils.parsers.rst.states.Inliner.simplename is not present in stub
docutils.parsers.rst.states.Inliner.standalone_uri is not present in stub
docutils.parsers.rst.states.Inliner.strong is not present in stub
docutils.parsers.rst.states.Inliner.substitution_reference is not present in stub
docutils.parsers.rst.states.Inliner.uri_end is not present in stub
docutils.parsers.rst.states.Inliner.uri_end_delim is not present in stub
docutils.parsers.rst.states.Inliner.uric is not present in stub
docutils.parsers.rst.states.Inliner.urilast is not present in stub
docutils.parsers.rst.states.InterpretedRoleNotImplementedError is not present in stub
docutils.parsers.rst.states.Line is not present in stub
docutils.parsers.rst.states.LineBlock is not present in stub
docutils.parsers.rst.states.MarkupError is not present in stub
docutils.parsers.rst.states.MarkupMismatch is not present in stub
docutils.parsers.rst.states.NestedStateMachine is not present in stub
docutils.parsers.rst.states.OptionList is not present in stub
docutils.parsers.rst.states.ParserError is not present in stub
docutils.parsers.rst.states.QuotedLiteralBlock is not present in stub
docutils.parsers.rst.states.RFC2822Body is not present in stub
docutils.parsers.rst.states.RFC2822List is not present in stub
docutils.parsers.rst.states.RSTState is not present in stub
docutils.parsers.rst.states.RSTStateMachine is not present in stub
docutils.parsers.rst.states.SpecializedBody is not present in stub
docutils.parsers.rst.states.SpecializedText is not present in stub
docutils.parsers.rst.states.Struct is not present in stub
docutils.parsers.rst.states.SubstitutionDef is not present in stub
docutils.parsers.rst.states.Text is not present in stub
docutils.parsers.rst.states.UnknownInterpretedRoleError is not present in stub
docutils.parsers.rst.states.build_regexp is not present in stub
docutils.readers.ReReader is not present in stub
docutils.readers.Reader is not present in stub
docutils.readers.get_reader_class is not present in stub
docutils.readers.doctree.Reader is not present in stub
docutils.readers.pep.Reader is not present in stub
docutils.readers.standalone.Reader is not present in stub
docutils.statemachine.DuplicateStateError is not present in stub
docutils.statemachine.DuplicateTransitionError is not present in stub
docutils.statemachine.SearchStateMachine is not present in stub
docutils.statemachine.SearchStateMachineWS is not present in stub
docutils.statemachine.State is not present in stub
docutils.statemachine.StateCorrection is not present in stub
docutils.statemachine.StateMachine is not present in stub
docutils.statemachine.StateMachineError is not present in stub
docutils.statemachine.StateMachineWS is not present in stub
docutils.statemachine.StateWS is not present in stub
docutils.statemachine.StringList is not present in stub
docutils.statemachine.TransitionCorrection is not present in stub
docutils.statemachine.TransitionMethodNotFound is not present in stub
docutils.statemachine.TransitionPatternNotFound is not present in stub
docutils.statemachine.UnexpectedIndentationError is not present in stub
docutils.statemachine.UnknownStateError is not present in stub
docutils.statemachine.UnknownTransitionError is not present in stub
docutils.statemachine.ViewList is not present in stub
docutils.statemachine.string2lines is not present in stub
docutils.transforms.Transform is not present in stub
docutils.transforms.TransformError is not present in stub
docutils.transforms.Transformer is not present in stub
docutils.utils.BadOptionDataError is not present in stub
docutils.utils.BadOptionError is not present in stub
docutils.utils.DuplicateOptionError is not present in stub
docutils.utils.ExtensionOptionError is not present in stub
docutils.utils.NameValueError is not present in stub
docutils.utils.Reporter is not present in stub
docutils.utils.SystemMessage is not present in stub
docutils.utils.SystemMessagePropagation is not present in stub
docutils.utils.assemble_option_dict is not present in stub
docutils.utils.clean_rcs_keywords is not present in stub
docutils.utils.column_indices is not present in stub
docutils.utils.column_width is not present in stub
docutils.utils.decode_path is not present in stub
docutils.utils.escape2null is not present in stub
docutils.utils.extract_extension_options is not present in stub
docutils.utils.extract_name_value is not present in stub
docutils.utils.extract_options is not present in stub
docutils.utils.find_combining_chars is not present in stub
docutils.utils.find_file_in_dirs is not present in stub
docutils.utils.get_source_line is not present in stub
docutils.utils.get_stylesheet_list is not present in stub
docutils.utils.get_stylesheet_reference is not present in stub
docutils.utils.get_trim_footnote_ref_space is not present in stub
docutils.utils.new_document is not present in stub
docutils.utils.new_reporter is not present in stub
docutils.utils.normalize_language_tag is not present in stub
docutils.utils.relative_path is not present in stub
docutils.utils.split_escaped_whitespace is not present in stub
docutils.utils.strip_combining_chars is not present in stub
docutils.utils.uniq is not present in stub
docutils.utils.unique_combinations is not present in stub
docutils.utils.version_identifier is not present in stub
docutils.writers.UnfilteredWriter is not present in stub
docutils.writers.Writer is not present in stub
docutils.writers.get_writer_class is not present in stub

@danieleades
Copy link
Contributor

draft pull request up (#5237)

input most welcome

@tk0miya
Copy link
Author

tk0miya commented Apr 21, 2021

FYI: https://pypi.org/project/docutils-stubs/

When I posted a comment at last, I asked about the permission to docutils project. But I did not get any answers. As a result, I made a stub package as a 3rd party package.

@danieleades
Copy link
Contributor

FYI: https://pypi.org/project/docutils-stubs/

When I posted a comment at last, I asked about the permission to docutils project. But I did not get any answers. As a result, I made a stub package as a 3rd party package.

Do you want to open a pull request to merge that into typeshed? I'd be happy to review based on the work I've done so far in #5237

@tk0miya
Copy link
Author

tk0miya commented Apr 21, 2021

AFAIK, permissions from the upstream project is needed to merge stubs into the typeshed, right? I've never gotten it. And we have to update it to the latest one (I made it for the old versions).

@danieleades
Copy link
Contributor

AFAIK, permissions from the upstream project is needed to merge stubs into the typeshed, right? I've never gotten it. And we have to update it to the latest one (I made it for the old versions).

righto. let's wait for a maintainer to chime in.

I've just tried your docutils-stubs library. It throws a few errors against the sphinx extension 'todo' example, but it looks mostly complete.

@tk0miya
Copy link
Author

tk0miya commented Apr 21, 2021

Yes. That's the reason why I made it. I've used it to type-check Sphinx project itself.

@danieleades
Copy link
Contributor

Yes. That's the reason why I made it. I've used it to type-check Sphinx project itself.

see tk0miya/docutils-stubs#38

@JelleZijlstra
Copy link
Member

We no longer require permission from the upstream library (which would be docutils here) to add stubs to typeshed. (See the changes in #2608; I can't find that wording in CONTRIBUTING.md any more but I don't think we changed our stance.) It would be great to see the different docutils stubs merged.

tsibley added a commit to nextstrain/cli that referenced this issue Feb 28, 2022
types-docutils isn't sufficient with recent (?) mypy versions, causing:

    nextstrain/cli/rst/sphinx.py:71: error: "dispatch_visit" undefined in superclass
    nextstrain/cli/rst/sphinx.py:88: error: "dispatch_departure" undefined in superclass

which seems to be because the docutils-stubs/nodes.pyi file installed by
types-docutils contains

    def __getattr__(…) -> Any

for nodes.NodeVisitor, which is apparently not understood by mypy.

Typeshed knows it's docutils stubs aren't great.¹  The docutils-stubs
distribution has a docutils-stubs/nodes.pyi² that mypy understands, but
installing that then breaks pyright.  Oy vey.

¹ python/typeshed#1269

² Yes, both the docutils-stubs and types-docutils distributions install
  a "docutils-stubs" directory in Python's site-packages.  This is how
  typestubs are supposed to be installed for the package "docutils".
@danieleades
Copy link
Contributor

danieleades commented May 22, 2022

AFAIK, permissions from the upstream project is needed to merge stubs into the typeshed, right? I've never gotten it. And we have to update it to the latest one (I made it for the old versions).

@tk0miya did this ever happen?

@AlexWaygood AlexWaygood added the help wanted An actionable problem of low to medium complexity where a PR would be very welcome label Aug 27, 2022
@JelleZijlstra
Copy link
Member

We have made numerous improvements to the docutils stubs (e.g. #7256, #7380, #8716, #5924). Further improvements are welcome, but I don't think we need this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted An actionable problem of low to medium complexity where a PR would be very welcome stubs: incomplete Annotations or sub-modules missing from an existing package or module
Projects
None yet
Development

No branches or pull requests

9 participants