-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[docutils] Add missing stubs for transforms
dir
#14234
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
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
def visit_citation_reference(self, node: Unused) -> NoReturn: ... | ||
def visit_footnote_reference(self, node: Unused) -> NoReturn: ... | ||
def visit_image(self, node: nodes.image) -> NoReturn: ... |
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.
The sphinx primer hits show that this class can still be sub-classed and these methods overridden. Therefore I would suggest just using the standard annotations for the visit methods instead of Unused
and NoReturn
. In fact, I would suggest removing them here and adding them to NodeVisitor
, similar to what we do in ast.pyi
.
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.
done, and they were already added to NodeVisitor
Diff from mypy_primer, showing the effect of this PR on open source code: sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/transforms/__init__.py:95: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/transforms/__init__.py: note: In member "apply" of class "ExtraTranslatableNodes":
+ sphinx/transforms/__init__.py:284:13: error: Unsupported target for indexed assignment ("Node") [index]
+ sphinx/transforms/__init__.py: note: In member "apply" of class "SphinxSmartQuotes":
+ sphinx/transforms/__init__.py:373:9: error: Cannot assign to class variable "smartquotes_action" via instance [misc]
+ sphinx/transforms/__init__.py: note: At top level:
- sphinx/transforms/__init__.py:398:5: error: Return type "Iterator[tuple[str, str]]" of "get_tokens" incompatible with return type "Generator[tuple[str, str], None, None]" in supertype "SmartQuotes" [override]
+ sphinx/transforms/__init__.py:398:5: error: Return type "Iterator[tuple[str, str]]" of "get_tokens" incompatible with return type "Generator[tuple[Literal['literal', 'plain'], str], None, None]" in supertype "SmartQuotes" [override]
+ sphinx/transforms/__init__.py:398:26: error: Argument 1 of "get_tokens" is incompatible with supertype "SmartQuotes"; supertype defines the argument type as "Iterable[Node]" [override]
+ sphinx/transforms/__init__.py:398:26: note: This violates the Liskov substitution principle
+ sphinx/transforms/__init__.py:398:26: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
+ sphinx/builders/latex/transforms.py:531: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/transforms/i18n.py: note: In member "apply" of class "PreserveTranslatableMessages":
+ sphinx/transforms/i18n.py:112:43: error: Only concrete class can be given where "type[translatable]" is expected [type-abstract]
+ sphinx/builders/linkcheck.py: note: In member "run" of class "HyperlinkCollector":
+ sphinx/builders/linkcheck.py:216:37: error: Argument 1 to "find_uri" of "HyperlinkCollector" has incompatible type "Node"; expected "Element" [arg-type]
+ sphinx/builders/linkcheck.py:217:36: error: Argument 2 to "_add_uri" of "HyperlinkCollector" has incompatible type "Node"; expected "Element" [arg-type]
|
No description provided.