Conversation
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: alectryon (https://github.com/cpitclaudel/alectryon)
+ alectryon/docutils.py:912: error: Unused "type: ignore" comment [unused-ignore]
+ alectryon/docutils.py:913: error: Unused "type: ignore" comment [unused-ignore]
sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/ext/autodoc/_directive_options.py:349: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/search/__init__.py: note: In member "dispatch_visit" of class "WordCollector":
+ sphinx/search/__init__.py:249:23: error: Value of type "Element | None" is not indexable [index]
+ sphinx/search/__init__.py: note: In function "_feed_visit_nodes":
+ sphinx/search/__init__.py:642:15: error: Value of type "Element | None" is not indexable [index]
+ sphinx/util/nodes.py: note: In function "apply_source_workaround":
+ sphinx/util/nodes.py:140:23: error: Item "None" of "Element | None" has no attribute "source" [union-attr]
+ sphinx/util/nodes.py:141:21: error: Item "None" of "Element | None" has no attribute "line" [union-attr]
+ sphinx/util/nodes.py:141:21: note: Error code "union-attr" not covered by "type: ignore[operator]" comment
+ sphinx/util/nodes.py:145:23: error: Item "None" of "Element | None" has no attribute "source" [union-attr]
+ sphinx/util/nodes.py:152:34: error: Item "None" of "Element | None" has no attribute "source" [union-attr]
+ sphinx/util/nodes.py:152:54: error: Item "None" of "Element | None" has no attribute "line" [union-attr]
+ sphinx/util/nodes.py:159:34: error: Item "None" of "Element | None" has no attribute "source" [union-attr]
+ sphinx/util/nodes.py:159:54: error: Item "None" of "Element | None" has no attribute "line" [union-attr]
+ sphinx/util/nodes.py:167:41: error: Item "None" of "Element | None" has no attribute "findall" [union-attr]
+ sphinx/util/nodes.py:178:34: error: Item "None" of "Element | None" has no attribute "source" [union-attr]
+ sphinx/util/nodes.py:178:54: error: Item "None" of "Element | None" has no attribute "line" [union-attr]
+ sphinx/util/nodes.py: note: In function "traverse_parent":
+ sphinx/util/nodes.py:369:16: error: Incompatible types in assignment (expression has type "Element | None", variable has type "Element") [assignment]
+ sphinx/util/nodes.py: note: In function "get_prev_node":
+ sphinx/util/nodes.py:373:11: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/util/nodes.py:375:16: error: Value of type "Element | None" is not indexable [index]
+ sphinx/util/nodes.py: note: In function "clean_astext":
+ sphinx/util/nodes.py:416:9: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/util/nodes.py: note: In function "inline_all_toctrees":
+ sphinx/util/nodes.py:533:9: error: Item "None" of "Element | None" has no attribute "replace" [union-attr]
+ sphinx/util/nodes.py: note: In function "is_smartquotable":
+ sphinx/util/nodes.py:710:34: error: Argument 1 to "traverse_parent" has incompatible type "Element | None"; expected "Element" [arg-type]
+ sphinx/transforms/__init__.py: note: In member "apply" of class "DefaultSubstitutions":
+ sphinx/transforms/__init__.py:122:68: error: Argument 1 to "_handle_default_substitution" of "DefaultSubstitutions" has incompatible type "str"; expected "Literal['version', 'release', 'today', 'translation progress']" [arg-type]
+ sphinx/transforms/__init__.py: note: In member "apply" of class "FilterSystemMessages":
+ sphinx/transforms/__init__.py:347:17: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/transforms/__init__.py: note: In function "_reorder_index_target_nodes":
+ sphinx/transforms/__init__.py:502:21: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/transforms/__init__.py:503:20: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/transforms/__init__.py:505:13: error: Unsupported target for indexed assignment ("Element | None") [index]
+ sphinx/util/rst.py:69: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/util/docutils.py:132: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/util/docutils.py: note: In member "enable" of class "CustomReSTDispatcher":
+ sphinx/util/docutils.py:266:31: error: Incompatible types in assignment (expression has type "Callable[[str, RSTLanguageModule | None, document], tuple[type[Directive] | None, list[system_message]]]", variable has type "_DirectivesDispatcher") [assignment]
+ sphinx/util/docutils.py:266:31: note: "_DirectivesDispatcher.__call__" has type "Callable[[str, _LanguageModule, document], tuple[type[Directive] | None, list[system_message]]]"
+ sphinx/util/docutils.py: note: In member "from_reporter" of class "LoggingReporter":
+ sphinx/util/docutils.py:403:13: error: Argument 1 to "LoggingReporter" has incompatible type "str | PathLike[str]"; expected "str" [arg-type]
+ sphinx/util/docutils.py:457:21: error: Argument 1 of "write" is incompatible with supertype "docutils.io.Output"; supertype defines the argument type as "str | bytes" [override]
+ sphinx/util/docutils.py: note: In function "_parse_str_to_doctree":
+ sphinx/util/docutils.py:872:15: error: Argument "debug" to "LoggingReporter" has incompatible type "bool | None"; expected "bool" [arg-type]
+ sphinx/roles.py:635: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/roles.py:636: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/roles.py:639: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/roles.py:643: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/writers/html5.py: note: In member "depart_desc_signature_line" of class "HTML5Translator":
+ sphinx/writers/html5.py:107:36: error: Argument 1 to "add_permalink_ref" of "HTML5Translator" has incompatible type "Element | None"; expected "Element" [arg-type]
+ sphinx/writers/html5.py: note: In member "depart_term" of class "HTML5Translator":
+ sphinx/writers/html5.py:509:27: error: Item "None" of "Element | None" has no attribute "parent" [union-attr]
+ sphinx/writers/html5.py:509:27: error: Item "None" of "Element | Any | None" has no attribute "parent" [union-attr]
+ sphinx/writers/html5.py: note: In member "visit_title" of class "HTML5Translator":
+ sphinx/writers/html5.py:538:28: error: Argument 1 to "add_fignumber" of "HTML5Translator" has incompatible type "Element | None"; expected "Element" [arg-type]
+ sphinx/writers/html5.py: note: In member "depart_title" of class "HTML5Translator":
+ sphinx/writers/html5.py:558:17: error: Item "None" of "Element | None" has no attribute "hasattr" [union-attr]
+ sphinx/writers/html5.py:559:17: error: Value of type "Element | None" is not indexable [index]
+ sphinx/writers/html5.py:563:40: error: Argument 1 to "add_permalink_ref" of "HTML5Translator" has incompatible type "Element | None"; expected "Element" [arg-type]
+ sphinx/writers/html5.py:566:63: error: Value of type "Element | None" is not indexable [index]
+ sphinx/writers/html5.py: note: In member "visit_caption" of class "HTML5Translator":
+ sphinx/writers/html5.py:640:28: error: Argument 1 to "add_fignumber" of "HTML5Translator" has incompatible type "Element | None"; expected "Element" [arg-type]
+ sphinx/writers/html5.py: note: In member "depart_caption" of class "HTML5Translator":
+ sphinx/writers/html5.py:654:14: error: Item "None" of "Element | None" has no attribute "get" [union-attr]
+ sphinx/writers/html5.py:655:36: error: Item "None" of "Element | None" has no attribute "parent" [union-attr]
+ sphinx/writers/html5.py:655:36: error: Argument 1 to "add_permalink_ref" of "HTML5Translator" has incompatible type "Element | Any | None"; expected "Element" [arg-type]
+ sphinx/writers/html5.py: note: At top level:
+ sphinx/writers/html5.py:935: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/transforms/post_transforms/__init__.py: note: In member "run" of class "PropagateDescDomain":
+ sphinx/transforms/post_transforms/__init__.py:389:16: error: Item "None" of "Element | None" has no attribute "get" [union-attr]
+ sphinx/transforms/post_transforms/__init__.py:390:40: error: Value of type "Element | None" is not indexable [index]
+ sphinx/domains/index.py: note: In member "process_doc" of class "IndexDomain":
+ sphinx/domains/index.py:58:17: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/directives/admonitions.py:30: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/directives/__init__.py:218: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/directives/__init__.py:305: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/directives/__init__.py:333: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/ext/todo.py: note: In member "process" of class "TodoListProcessor":
+ sphinx/ext/todo.py:129:17: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/domains/rst.py: note: In member "_toc_entry_name" of class "ReSTMarkup":
+ sphinx/domains/rst.py:85:19: error: Item "None" of "Element | None" has no attribute "get" [union-attr]
+ sphinx/domains/javascript.py: note: In member "_toc_entry_name" of class "JSObject":
+ sphinx/domains/javascript.py:251:19: error: Item "None" of "Element | None" has no attribute "get" [union-attr]
+ sphinx/domains/std/__init__.py:296: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/domains/std/__init__.py:322: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/domains/std/__init__.py: note: In member "run" of class "Glossary":
+ sphinx/domains/std/__init__.py:467:38: error: List item 0 has incompatible type "tuple[str, str | None, int]"; expected "tuple[str, str, int]" [list-item]
+ sphinx/domains/std/__init__.py:482:47: error: Argument 1 to "append" of "list" has incompatible type "tuple[str, str | None, int]"; expected "tuple[str, str, int]" [arg-type]
+ sphinx/domains/python/_object.py: note: In member "_toc_entry_name" of class "PyObject":
+ sphinx/domains/python/_object.py:510:19: error: Item "None" of "Element | None" has no attribute "get" [union-attr]
+ sphinx/environment/adapters/toctree.py: note: In function "_entries_from_toctree":
+ sphinx/environment/adapters/toctree.py:294:23: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/environment/adapters/toctree.py:296:17: error: Item "None" of "Element | None" has no attribute "insert" [union-attr]
+ sphinx/environment/adapters/toctree.py:297:13: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/environment/adapters/toctree.py: note: In function "_toctree_add_classes":
+ sphinx/environment/adapters/toctree.py:475:38: error: Incompatible types in assignment (expression has type "Element | None", variable has type "Element") [assignment]
+ sphinx/environment/adapters/toctree.py:477:20: error: Item "None" of "Element | None" has no attribute "parent" [union-attr]
+ sphinx/environment/adapters/toctree.py:477:20: error: Item "None" of "Element | Any | None" has no attribute "get" [union-attr]
+ sphinx/environment/adapters/toctree.py:482:31: error: Incompatible types in assignment (expression has type "Element | None", variable has type "Node") [assignment]
+ sphinx/environment/__init__.py: note: In member "get_and_resolve_doctree" of class "BuildEnvironment":
+ sphinx/environment/__init__.py:713:17: error: Item "None" of "Element | None" has no attribute "replace" [union-attr]
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py: note: In member "add_content" of class "Documenter":
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py:495:37: error: Argument 2 to "add_line" of "Documenter" has incompatible type "str | None"; expected "str" [arg-type]
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py: note: In member "add_content" of class "ModuleDocumenter":
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py:942:37: error: Argument 2 to "add_line" of "Documenter" has incompatible type "str | None"; expected "str" [arg-type]
+ sphinx/writers/latex.py: note: In member "visit_title" of class "LaTeXTranslator":
+ sphinx/writers/latex.py:750:64: error: Argument 1 to "hypertarget_to" of "LaTeXTranslator" has incompatible type "Element | None"; expected "Element" [arg-type]
+ sphinx/writers/latex.py: note: In function "_visit_signature_line":
+ sphinx/writers/latex.py:823:24: error: Value of type "Element | None" is not indexable [index]
+ sphinx/writers/latex.py:823:33: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/writers/latex.py: note: In member "visit_desc_signature" of class "LaTeXTranslator":
+ sphinx/writers/latex.py:886:12: error: Value of type "Element | None" is not indexable [index]
+ sphinx/writers/latex.py: note: In member "visit_entry" of class "LaTeXTranslator":
+ sphinx/writers/latex.py:1391:24: error: Item "None" of "Element | None" has no attribute "parent" [union-attr]
+ sphinx/writers/latex.py: note: In function "visit_enumerated_list":
+ sphinx/writers/latex.py:1471:41: error: Argument 1 to "get_nested_level" has incompatible type "Element | None"; expected "Element" [arg-type]
+ sphinx/writers/latex.py:1473:41: error: Argument 1 to "get_nested_level" has incompatible type "Element | None"; expected "Element" [arg-type]
+ sphinx/writers/latex.py: note: In member "visit_paragraph" of class "LaTeXTranslator":
+ sphinx/writers/latex.py:1560:17: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/writers/latex.py: note: In member "visit_image" of class "LaTeXTranslator":
+ sphinx/writers/latex.py:1631:40: error: Argument 1 to "is_inline" of "LaTeXTranslator" has incompatible type "Element | None"; expected "Element" [arg-type]
+ sphinx/writers/latex.py: note: In member "visit_caption" of class "LaTeXTranslator":
+ sphinx/writers/latex.py:1772:29: error: Item "None" of "Element | None" has no attribute "tagname" [union-attr]
+ sphinx/writers/latex.py: note: In function "visit_target":
+ sphinx/writers/latex.py:1847:21: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/writers/latex.py:1848:41: error: Value of type "Element | None" is not indexable [index]
+ sphinx/writers/latex.py: note: At top level:
+ sphinx/writers/latex.py:2427: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/writers/latex.py:2459: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/writers/latex.py:2464: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/writers/manpage.py: note: In member "apply" of class "NestedInlineTransform":
+ sphinx/writers/manpage.py:61:23: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/writers/manpage.py:65:25: error: Item "None" of "Element | None" has no attribute "insert" [union-attr]
+ sphinx/writers/manpage.py:68:25: error: Item "None" of "Element | None" has no attribute "insert" [union-attr]
+ sphinx/writers/manpage.py:71:21: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/ext/viewcode.py: note: In member "remove_viewcode_anchors" of class "ViewcodeAnchorTransform":
+ sphinx/ext/viewcode.py:244:13: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/ext/autosectionlabel.py: note: In function "get_node_depth":
+ sphinx/ext/autosectionlabel.py:28:20: error: Incompatible types in assignment (expression has type "Element | None", variable has type "Node") [assignment]
+ sphinx/ext/autodoc/typehints.py: note: In function "_merge_typehints":
+ sphinx/ext/autodoc/typehints.py:54:53: error: Value of type "Element | None" is not indexable [index]
+ sphinx/environment/collectors/toctree.py: note: In function "process_doc":
+ sphinx/environment/collectors/toctree.py:137:36: error: Item "None" of "Element | None" has no attribute "get" [union-attr]
+ sphinx/environment/collectors/toctree.py:164:46: error: Item "None" of "Element | None" has no attribute "parent" [union-attr]
+ sphinx/directives/other.py: note: In member "run" of class "Only":
+ sphinx/directives/other.py:351:26: error: Incompatible types in assignment (expression has type "Element | None", variable has type "Element") [assignment]
+ sphinx/writers/texinfo.py: note: In member "init_settings" of class "TexinfoTranslator":
+ sphinx/writers/texinfo.py:237:22: error: Incompatible types in assignment (expression has type "str | None", variable has type "str") [assignment]
+ sphinx/writers/texinfo.py: note: In member "visit_target" of class "TexinfoTranslator":
+ sphinx/writers/texinfo.py:689:20: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/writers/texinfo.py:692:24: error: Value of type "Element | None" is not indexable [index]
+ sphinx/writers/texinfo.py:696:24: error: Item "None" of "Element | None" has no attribute "parent" [union-attr]
+ sphinx/writers/texinfo.py:696:24: error: Value of type "Element | Any | None" is not indexable [index]
+ sphinx/writers/texinfo.py:696:43: error: Item "None" of "Element | Any | None" has no attribute "index" [union-attr]
+ sphinx/writers/texinfo.py:696:68: error: Argument 1 to "index" of "Element" has incompatible type "Element | None"; expected "Node" [arg-type]
+ sphinx/writers/texinfo.py: note: In member "visit_desc_signature" of class "TexinfoTranslator":
+ sphinx/writers/texinfo.py:1417:19: error: Value of type "Element | None" is not indexable [index]
+ sphinx/writers/texinfo.py:1423:36: error: Value of type "Element | None" is not indexable [index]
+ sphinx/builders/_epub_base.py: note: In member "get_refnodes" of class "EpubBuilder":
+ sphinx/builders/_epub_base.py:204:23: error: Item "None" of "Element | None" has no attribute "attributes" [union-attr]
+ sphinx/builders/_epub_base.py: note: In member "_footnote_spot" of class "EpubBuilder":
+ sphinx/builders/_epub_base.py:345:20: error: Incompatible return value type (got "tuple[Element | None, int | Any]", expected "tuple[Element, int]") [return-value]
+ sphinx/builders/_epub_base.py:345:31: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/builders/_epub_base.py:348:24: error: Incompatible return value type (got "tuple[Element | None, int | Any]", expected "tuple[Element, int]") [return-value]
+ sphinx/builders/_epub_base.py:348:37: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/builders/_epub_base.py: note: In member "add_visible_links" of class "EpubBuilder":
+ sphinx/builders/_epub_base.py:368:23: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/builders/_epub_base.py:373:21: error: Item "None" of "Element | None" has no attribute "insert" [union-attr]
+ sphinx/builders/_epub_base.py:378:21: error: Item "None" of "Element | None" has no attribute "insert" [union-attr]
+ sphinx/builders/latex/transforms.py: note: In member "run" of class "SubstitutionDefinitionsRemover":
+ sphinx/builders/latex/transforms.py:55:13: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/builders/latex/transforms.py: note: In member "expand_show_urls" of class "ShowUrlsTransform":
+ sphinx/builders/latex/transforms.py:96:29: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/builders/latex/transforms.py:100:25: error: Item "None" of "Element | None" has no attribute "insert" [union-attr]
+ sphinx/builders/latex/transforms.py:101:25: error: Item "None" of "Element | None" has no attribute "insert" [union-attr]
+ sphinx/builders/latex/transforms.py:106:25: error: Item "None" of "Element | None" has no attribute "insert" [union-attr]
+ sphinx/builders/latex/transforms.py: note: In member "get_docname_for_node" of class "ShowUrlsTransform":
+ sphinx/builders/latex/transforms.py:115:24: error: Incompatible types in assignment (expression has type "Element | None", variable has type "Node") [assignment]
+ sphinx/builders/latex/transforms.py: note: In member "run" of class "LaTeXFootnoteTransform":
+ sphinx/builders/latex/transforms.py:368:13: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/builders/latex/transforms.py: note: In member "unrestrict" of class "LaTeXFootnoteVisitor":
+ sphinx/builders/latex/transforms.py:398:19: error: Item "None" of "Element | None" has no attribute "index" [union-attr]
+ sphinx/builders/latex/transforms.py:401:17: error: Item "None" of "Element | None" has no attribute "insert" [union-attr]
+ sphinx/builders/latex/transforms.py: note: In member "run" of class "BibliographyTransform":
+ sphinx/builders/latex/transforms.py:527:13: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/transforms/post_transforms/code.py: note: In member "apply" of class "HighlightLanguageTransform":
+ sphinx/transforms/post_transforms/code.py:47:13: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/transforms/i18n.py: note: In member "update_autofootnote_references" of class "_NodeUpdater":
+ sphinx/transforms/i18n.py:250:42: error: Argument 1 to "setdefault" of "MutableMapping" has incompatible type "str | None"; expected "str" [arg-type]
+ sphinx/transforms/i18n.py:253:42: error: Argument 1 to "get" of "dict" has incompatible type "str | None"; expected "str" [arg-type]
+ sphinx/transforms/i18n.py:255:17: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/transforms/i18n.py: note: In member "update_refnamed_footnote_references" of class "_NodeUpdater":
+ sphinx/transforms/i18n.py:324:68: error: Argument 1 to "append" of "list" has incompatible type "list[str]"; expected "str" [arg-type]
+ sphinx/transforms/i18n.py: note: In member "update_citation_references" of class "_NodeUpdater":
+ sphinx/transforms/i18n.py:345:68: error: Argument 1 to "append" of "list" has incompatible type "list[str]"; expected "str" [arg-type]
+ sphinx/transforms/i18n.py: note: In member "apply" of class "RemoveTranslatableInline":
+ sphinx/transforms/i18n.py:705:13: error: Item "None" of "Element | None" has no attribute "remove" [union-attr]
+ sphinx/transforms/i18n.py:706:13: error: Unsupported left operand type for + ("None") [operator]
+ sphinx/transforms/i18n.py:706:13: note: Left operand is of type "Element | None"
+ sphinx/transforms/i18n.py:706:13: error: Incompatible types in assignment (expression has type "list[Node] | Any", variable has type "Element | None") [assignment]
+ sphinx/ext/inheritance_diagram.py: note: In function "html_visit_inheritance_diagram":
+ sphinx/ext/inheritance_diagram.py:497:43: error: No overload variant of "__add__" of "str" matches argument type "None" [operator]
+ sphinx/ext/inheritance_diagram.py:497:43: note: Possible overload variants:
+ sphinx/ext/inheritance_diagram.py:497:43: note: def __add__(self, str, /) -> str
+ sphinx/ext/inheritance_diagram.py:497:43: note: Right operand is of type "str | None"
+ sphinx/ext/inheritance_diagram.py:499:43: error: No overload variant of "__add__" of "str" matches argument type "None" [operator]
+ sphinx/ext/inheritance_diagram.py:499:43: note: Possible overload variants:
+ sphinx/ext/inheritance_diagram.py:499:43: note: def __add__(self, str, /) -> str
+ sphinx/ext/inheritance_diagram.py:499:43: note: Right operand is of type "str | None"
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The docutils stubs are not very helpful in their current state. The stubs have:
Incomplete, entirely missing entries, and entries with missing annotations.Callables that make optional arguments required.Anywhere actual types, generics, orobjectnon-problematically express the typing.This PR attempts to fill in and fix all of the above. Some minor, additional testing was added as well. Monkeytype and RightTyper traces of docutils' test suite were used as a starting point, but not blindly trusted (they have many wrong, missing, and not-useful inferences). Types were cross-checked and whittled down against the 0.23 source and its documentation.
The main changes are:
LanguageModuleandRSTLanguageModuleprotocols match their non-underscore-prefixed upstream names and no longer have missing fields.LanguageModulealso no longer incorrectly annotates its fieldbibliographic_fieldsas a list instead of a dict.LanguageImporteris generic over the language module type and the call's result type. This allows no-fallback importers to do things like what the rST importer does (returnsRSTLanguageModule | None).Inputwas given a second type variable so that itsread()method's return type is now type-safe.DocTreeInput.read()now properly returnsdocument, rather than being left unannotated (how it currently is) or# type: ignored.optionsandcontentarguments are optional keyword arguments. The old Callable made them required.Valuesrather thanAny; created TypedDicts forfrontend.Option(and so also the option dicts insettings_spec), and state machine kwargs; splitting/"specialization" of TypedDicts for different writer parts.Literalkey overloads that return types for well-defined, common element attributes rather thanAny; per-writer overloads forpublish_parts().Directive.option_specbecause, in the baseDirectiveclass, its implementation is read-only. This matches actual runtime behavior, and it fixes variance issues. In subclasses whereoption_specis not set toNone, it is typed as a concretedictinstance because the docutils code and existing downstream code both use things not present onMappingorMutableMappinglike.copy()and|(__or__).@type_check_onlyis now used onvisit_*anddepart_*methods on theNodeVisitorbase class and on the difficult-to-type source overrides/aliases of "transition" functions inSpecializedBodyandSpecializedText. ForNodeVisitor, they really do not exist; for the methods inSpecializedBodyandSpecializedTextclasses, the methods are intended to be overridden in any subclass that uses them, and they will raise if called without overriding. So, it seemed like a decent way to model runtime behavior. Some type checkers will report an error if you try and access them on these classes directly, or on a subclass that did not override; i.e., it essentially treats them similarly to@abstractmethodwithout imposing the requirements ofABC. The removal of the allowlist regex entries for thevisit_*anddepart_*methods inNodeVisitorallowed stubtest to do additional checking that exposed two translator methods missing from the stubs (LaTeXTranslator.depart_theadandmanpage Translator.depart_target).# type: ignores went from 42 to 13.There are two potentially objectionable changes; I am happy to split these into separate PRs or even simply revert/remove them if there's a strong consensus against them.
Node.parentas being potentially None. The original stub left it off entirely with a comment that it being None is very rare. It's not "frequent", but, it is more common than the comment made it seem. I updated that comment with an explanation of which scenarios lead to a None value. Typeshed might preferElement | MaybeNone, but it is worth noting that my change and a very quick review revealed at least 3 latent bugs in Sphinx (discussed a bit more below). I also personally really dislikeMaybeNone-- when using strict settings with type checkers,MaybeNonemakes that hiddenAnyinfectious.@type_check_onlyonSpecializedBodyandSpecializedText, as explained above in point 9, is a bit unorthodox.The majority of reports from mypy_primer are from the
Nodefieldparent: Element | Nonechange, and most are in places where it cannot beNone; however, proper typing of this did expose at least 3 potential, latent bugs in some Sphinx utility functions. Sphinx also appears to handle this problem elsewhere in their code by wrapping it in atry/except AttributeErrorblock. So, pretending it is neverNonedoes not seem like a good choice here.Lastly, I left a local stand-in for Pygments in the
ODTwriter's formatter. When I attempted to add an optional dependency on types-Pygments,ts_utilshad aRecursionError, since types-Pygments also optionally depends upon types-docutils.ts_utils.metadata.get_recursive_requirementsapparently does not handle recursion from mutual dependency. Not ideal, but that is not really in scope.