-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
add docutils.nodes.General stub #10099
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
Conversation
This comment has been minimized.
This comment has been minimized.
this is an interesting one. a docutils edit: I found this helpful - https://stackoverflow.com/questions/926574/why-does-defining-getitem-on-a-class-make-it-iterable-in-python so having a |
As a workaround, we could lie and add an |
Agreed. I'm supportive of improving mypy here, but I don't know when or if that mypy PR will get merged. There's a number of other classes where we invent fake iter methods in typeshed, and it's an okay workaround: typeshed/tests/stubtest_allowlists/py3_common.txt Lines 606 to 613 in f42f665
|
f6d67b2
to
4aae24f
Compare
@AlexWaygood where am i going wrong? |
|
4aae24f
to
3b4e23b
Compare
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Diff from mypy_primer, showing the effect of this PR on open source code: sphinx (https://github.com/sphinx-doc/sphinx)
- sphinx/domains/std.py: note: In member "get_numfig_title" of class "StandardDomain":
- sphinx/domains/std.py:1027:32: error: "Element" has no attribute "__iter__" (not iterable) [attr-defined]
- sphinx/domains/std.py: note: In function "get_enumerable_node_type":
- sphinx/domains/std.py:1036:60: error: "Element" has no attribute "__iter__" (not iterable) [attr-defined]
- sphinx/domains/python.py: note: In function "filter_meta_fields":
- sphinx/domains/python.py:1117:17: error: "Element" has no attribute "__iter__" (not iterable) [attr-defined]
- sphinx/builders/_epub_base.py: note: In member "get_refnodes" of class "EpubBuilder":
- sphinx/builders/_epub_base.py:205:25: error: "Element" has no attribute "__iter__" (not iterable) [attr-defined]
- sphinx/writers/latex.py: note: In member "_visit_signature_line" of class "LaTeXTranslator":
- sphinx/writers/latex.py:703:22: error: "Element" has no attribute "__iter__" (not iterable) [attr-defined]
- sphinx/writers/latex.py: note: In member "visit_figure" of class "LaTeXTranslator":
- sphinx/writers/latex.py:1351:66: error: "Element" has no attribute "__iter__" (not iterable) [attr-defined]
- sphinx/writers/latex.py:1375:66: error: "Element" has no attribute "__iter__" (not iterable) [attr-defined]
- sphinx/ext/autodoc/typehints.py:58:35: error: "Element" has no attribute "__iter__" (not iterable) [attr-defined]
- sphinx/ext/autodoc/typehints.py: note: In function "insert_field_list":
- sphinx/ext/autodoc/typehints.py:81:24: error: "Element" has no attribute "__iter__" (not iterable) [attr-defined]
- sphinx/environment/collectors/toctree.py:67:32: error: Item "Element" of "Union[Element, Sequence[Element]]" has no attribute "__iter__" (not iterable) [union-attr]
- sphinx/writers/texinfo.py: note: In function "find_subsections":
- sphinx/writers/texinfo.py:86:18: error: "Element" has no attribute "__iter__" (not iterable) [attr-defined]
|
That's a good sign! |
this is a trivial change, but will remove type errors from sphinx extension examples where
docutils.nodes.General
is subclassed