-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[docutils] Impove main stubs #14107
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
Merged
Merged
[docutils] Impove main stubs #14107
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
25ae6d3
draft: impove `docutils`
donBarbos 650cef0
fix more
donBarbos 0f2bceb
Add more writers
donBarbos 9bd977a
Update parsers
donBarbos 3aaedb2
Update readers
donBarbos c9becf4
Improve utils
donBarbos c4cd6c1
Merge branch 'main' into improve-docutils
donBarbos d611093
Draft: reset to preves commit
donBarbos d08322d
Merge remote-tracking branch 'origin/main' into improve-docutils
donBarbos 34a8211
Revert adding my files
donBarbos afab428
Merge branch 'main' into improve-docutils
donBarbos d45624d
Correct core changes
donBarbos cb7a2dd
Remove new dirs for writers
donBarbos ace1914
Remove `transforms` changes
donBarbos 50b9f51
Revert few changes
donBarbos a6a1fce
Update
donBarbos 9b6e8ac
Merge branch 'main' into improve-docutils
srittau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,46 @@ | ||
def __getattr__(name: str): ... # incomplete module | ||
from _typeshed import Incomplete | ||
from typing import Literal, overload | ||
from typing_extensions import TypeAlias | ||
|
||
from docutils.core import Publisher | ||
from docutils.io import FileInput, StringInput | ||
from docutils.nodes import document | ||
from docutils.writers import _WriterParts | ||
|
||
_HTMLHeaderLevel: TypeAlias = Literal[1, 2, 3, 4, 5, 6] | ||
|
||
def html_parts( | ||
input_string: str, | ||
source_path=None, | ||
destination_path=None, | ||
input_encoding: str = "unicode", | ||
doctitle: bool = True, | ||
initial_header_level: _HTMLHeaderLevel = 1, | ||
) -> _WriterParts: ... | ||
@overload | ||
def html_body( | ||
input_string: str, | ||
source_path=None, | ||
destination_path=None, | ||
input_encoding: str = "unicode", | ||
output_encoding: Literal["unicode"] = "unicode", | ||
doctitle: bool = True, | ||
initial_header_level: _HTMLHeaderLevel = 1, | ||
) -> str: ... | ||
@overload | ||
def html_body( | ||
input_string: str, | ||
source_path=None, | ||
destination_path=None, | ||
input_encoding: str = "unicode", | ||
output_encoding: str = "unicode", | ||
doctitle: bool = True, | ||
initial_header_level: _HTMLHeaderLevel = 1, | ||
) -> str | bytes: ... | ||
def internals( | ||
input_string, | ||
source_path: FileInput | StringInput | None = None, | ||
destination_path: FileInput | StringInput | None = None, | ||
input_encoding: str = "unicode", | ||
settings_overrides: dict[str, Incomplete] | None = None, | ||
) -> tuple[document | None, Publisher]: ... |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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 types for
source_path
anddestination_path
are wrong. I think this is a misunderstanding with the docstring ofsource_path
inpublish_programmatically()
: while that one listsFileInput
andStringInput
, it does so to say which types are expected ifsource_class
is one of these two types. It does not say thatsource_path
is one of these two types.set_source
is passed on toPublisher.set_source()
, which has typesource_path: StrPath | None
. So the correct type should beStrPath | None
, notFileInput | StringInput | None
.The same is true for
destination_path
, and the parameters of the same name for all otherpublish_*
functions.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.
big thanks to you, I noticed that
source_path
is passed to theopen
builtin function which takesFileDescriptorOrPath
, so maybe that would be a more appropriate type?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.
I would stick to the types that docutils itself (indirectly, through
Publisher.set_source()
/Publisher.set_destination()
) specifies.