Skip to content

improve type annotations in 'docutils.core' #11559

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

Closed
wants to merge 10 commits into from

Conversation

danieleades
Copy link
Contributor

No description provided.

This comment has been minimized.

parser: Parser | None = None,
writer: Writer | None = None,
source: Input[_S] | None = None,
source_class: type[Input[_S]] = io.FileInput,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some mypy errors about this. It's probably difficult to get this right without overloads.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, a few remarks below.

writer_name: str = "pseudoxml",
settings: Values | None = None,
settings_spec: SettingsSpec | None = None,
settings_overrides: Any | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably be typed. Docstring says:

settings_overrides: A dictionary containing application-specific settings defaults that override the defaults of other components. [...]

Without looking at the source, this this probably a dict, Mapping, or one of the protocols from _typeshed. It's okay to leave it as Incomplete now, though.

Applies to all the functions below as well.

argv: list[str] | None = None,
usage: str = default_usage,
description: str = default_description,
) -> Any: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a comment to this and the other return types below that this is either str or bytes.

@danieleades danieleades marked this pull request as draft March 14, 2024 14:50

This comment has been minimized.

Copy link
Contributor

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

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/builders/html/__init__.py:21: note: In module imported here:
+ sphinx/io.py:161:53: error: Missing type parameters for generic type "Publisher"  [type-arg]
+ sphinx/builders/__init__.py: note: In member "read_doc" of class "Builder":
+ sphinx/builders/__init__.py:491:9: error: Item "None" of "Optional[Values]" has no attribute "record_dependencies"  [union-attr]
+ sphinx/builders/__init__.py:508:37: error: Argument 2 to "write_doctree" of "Builder" has incompatible type "Optional[document]"; expected "document"  [arg-type]
+ sphinx/builders/__init__.py: note: At top level:
- sphinx/builders/html/__init__.py:439: error: Unused "type: ignore" comment  [unused-ignore]

cwltool (https://github.com/common-workflow-language/cwltool)
+ note: In module imported here,
+ note: ... from here,
+ note: ... from here,
+ cwltool/software_requirements.py:32: note: ... from here:

@JelleZijlstra
Copy link
Member

This has a huge merge conflict; do we still need this PR?

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.

3 participants