-
-
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
[docutils] Impove main stubs #14107
Conversation
This comment has been minimized.
This comment has been minimized.
Required to avoid adding new ignores to Sphinx with the latest types-docutils. See sphinx-doc/sphinx#13564. Copied form @donBarbos's WIP at python#14107.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/docfields.py: note: In member "_transform_step_1" of class "DocFieldTransformer":
+ sphinx/util/docfields.py:461:41: error: Incompatible types in assignment (expression has type "document | Any | None", variable has type "document") [assignment]
+ sphinx/util/docutils.py: note: In member "write" of class "SphinxFileOutput":
+ sphinx/util/docutils.py:469:16: error: Call to untyped function "write" in typed context [no-untyped-call]
+ sphinx/util/docutils.py: note: At top level:
+ sphinx/util/docutils.py:914: error: Unused "type: ignore" comment [unused-ignore]
+ sphinx/util/docutils.py: note: In function "_get_settings":
+ sphinx/util/docutils.py:914:12: error: Call to untyped function "get_default_values" in typed context [no-untyped-call]
+ sphinx/util/docutils.py:914:12: note: Error code "no-untyped-call" not covered by "type: ignore" comment
+ sphinx/ext/inheritance_diagram.py: note: In member "run" of class "InheritanceDiagram":
+ sphinx/ext/inheritance_diagram.py:432:21: error: Item "None" of "document | None" has no attribute "reporter" [union-attr]
|
def publish_parts( | ||
source, | ||
source_path=None, | ||
source_path: FileInput | StringInput | None = None, |
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
and destination_path
are wrong. I think this is a misunderstanding with the docstring of source_path
in publish_programmatically()
: while that one lists FileInput
and StringInput
, it does so to say which types are expected if source_class
is one of these two types. It does not say that source_path
is one of these two types. set_source
is passed on to Publisher.set_source()
, which has type source_path: StrPath | None
. So the correct type should be StrPath | None
, not FileInput | StringInput | None
.
The same is true for destination_path
, and the parameters of the same name for all other publish_*
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 the open
builtin function which takes FileDescriptorOrPath
, 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.
No description provided.