Skip to content

[docutils] Improve types in docutils.io - #16260

Open
ekanshul wants to merge 2 commits into
python:mainfrom
ekanshul:docutils-io-types
Open

[docutils] Improve types in docutils.io#16260
ekanshul wants to merge 2 commits into
python:mainfrom
ekanshul:docutils-io-types

Conversation

@ekanshul

Copy link
Copy Markdown
Contributor

Several attributes and parameters of the docutils.io input/output classes were Incomplete or unannotated although docutils annotates them inline. This types the encoding, error_handler, destination_path and autoclose attributes of Output/FileOutput, the ErrorOutput attributes, the path/encoding/mode parameters of the FileInput and FileOutput constructors, and the read()/write() methods of StringInput, StringOutput and FileOutput, following the annotations in docutils 0.23.

Agent used: Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/docutils.py: note: In member "write" of class "SphinxFileOutput":
+ sphinx/util/docutils.py:457:21: error: Argument 1 of "write" is incompatible with supertype "docutils.io.FileOutput"; supertype defines the argument type as "str | bytes"  [override]
+ sphinx/util/docutils.py:457:21: note: This violates the Liskov substitution principle
+ sphinx/util/docutils.py:457:21: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
+ sphinx/util/docutils.py: note: At top level:
+ sphinx/util/docutils.py:473: error: Unused "type: ignore" comment  [unused-ignore]
+ sphinx/util/docutils.py: note: In member "write" of class "SphinxFileOutput":
+ sphinx/util/docutils.py:473:16: error: Incompatible return value type (got "str | bytes", expected "str")  [return-value]
+ sphinx/util/docutils.py:473:16: note: Error code "return-value" not covered by "type: ignore[no-untyped-call]" comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants