Skip to content
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

Add docutils definitions and (incomplete) modules #5192

Merged
merged 11 commits into from
Apr 16, 2021

Conversation

srittau
Copy link
Collaborator

@srittau srittau commented Apr 8, 2021

No description provided.

@srittau
Copy link
Collaborator Author

srittau commented Apr 8, 2021

python/mypy#10242, cc @rchen152: Could you have a look at the pytype errors? I can't make sense of them. I suspect this is also related to using tuple[X, ...], but I'm not sure.

@rchen152
Copy link
Collaborator

rchen152 commented Apr 9, 2021

The pytype test failures are caused by pytype assuming that some imports are modules when they're actually classes. I filed google/pytype#882. You should be able to work around this by modifying the imports that pytype is unhappy with like this:

stubs/docutils/docutils/frontend.pyi
------------------------------------
-from . import SettingsSpec
+from docutils import SettingsSpec
 
stubs/docutils/docutils/io.pyi
------------------------------
-from . import TransformSpec
+from docutils import TransformSpec
 
 stubs/docutils/docutils/parsers/__init__.pyi
---------------------------------------------
-from .. import Component
+from docutils import Component

stubs/docutils/docutils/parsers/rst/__init__.pyi
--------------------------------------------------
-from ... import parsers
+from docutils import parsers

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks! Just two comments

encoding: Optional[str] = ...,
error_handler: str = ...,
autoclose: bool = ...,
mode: Literal["r", "rb"] = ...,
Copy link
Member

Choose a reason for hiding this comment

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

This is the default but not the only possibility; it also allows rU in Python 2 at least.

def close(self) -> None: ...

class FileOutput(Output):
mode: ClassVar[Literal["w", "wb"]]
Copy link
Member

Choose a reason for hiding this comment

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

This can also be wider; I guess we can use the aliases from _typeshed

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

1 similar comment
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit 4d734e3 into python:master Apr 16, 2021
@srittau srittau deleted the docutils branch April 16, 2021 19:16
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