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

bpo-35581: Document @typing.type_check_only #11312

Merged
merged 2 commits into from
Apr 12, 2019

Conversation

srittau
Copy link
Contributor

@srittau srittau commented Dec 25, 2018

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

I have a couple of comments


Decorator to mark a class or function to be unavailable at runtime.

This decorator is itself not available at runtime. It is mainly
Copy link
Member

Choose a reason for hiding this comment

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

TBH, I am not sure we need to document something not actually available at runtime here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A bit of a meta ramble: One of the problems is that there is not central "typing documentation". Most things are described in PEP 484, the typing documentation and mypy's documentation and there is a significant overlap, but some things are only described in one of them. The typeshed CONTRIBUTING file has a bit more stuff, too. Although by now I'd describe myself as fairly experienced regarding typing, I am still always looking for the right document when I encounter a corner case or want to link someone the documentation.

In the long term we should probably have a comprehensive guide on https://docs.python.org/ and link to that from the other documentation. But until that is the case, I don't think PEP 484 should be the only place where this is documented. And while it is not available at runtime, @type_check_only is imported from typing, so its documentation is where I would look for it.


def fetch_response() -> Response: ...

Note that returning instances of private classes is not recommended.
Copy link
Member

Choose a reason for hiding this comment

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

Even if we decide that documenting this makes sense, providing an example that is not recommended is a bad idea. I would instead provide a more realistic example. IIUC a typical situation for this would be a private protocol for argument types. Protocols are not accepted yet, so maybe this should wait until they are?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my experience, returning instances of private classes is a pretty common occurence. There are multiple examples of it in the standard library, the IO classes as well as Pattern and Match being the most prominent.

@miss-islington
Copy link
Contributor

Thanks @srittau for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 12, 2019
(cherry picked from commit 1e82954)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
@bedevere-bot
Copy link

GH-12813 is a backport of this pull request to the 3.7 branch.

miss-islington added a commit that referenced this pull request Apr 12, 2019
(cherry picked from commit 1e82954)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants