summaryrefslogtreecommitdiffstats
path: root/Doc/library/typing.rst
diff options
context:
space:
mode:
authorSebastian Rittau <srittau@rittau.biz>2019-04-12 22:33:40 (GMT)
committerGuido van Rossum <guido@python.org>2019-04-12 22:33:40 (GMT)
commit1e8295402bf5e81d327ed2b5eb88a6b6de449d63 (patch)
tree18aea74422bc75ab5861f7bbe7cd7fbce6bf7ccb /Doc/library/typing.rst
parent1e2ad6c275d2b09e76b7cbba7281d5a125a593c1 (diff)
downloadcpython-1e8295402bf5e81d327ed2b5eb88a6b6de449d63.zip
cpython-1e8295402bf5e81d327ed2b5eb88a6b6de449d63.tar.gz
cpython-1e8295402bf5e81d327ed2b5eb88a6b6de449d63.tar.bz2
bpo-35581: Document @typing.type_check_only (GH-11312)
Diffstat (limited to 'Doc/library/typing.rst')
-rw-r--r--Doc/library/typing.rst18
1 files changed, 18 insertions, 0 deletions
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index fad9dc6..ed5f547 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -951,6 +951,24 @@ The module defines the following classes, functions and decorators:
This wraps the decorator with something that wraps the decorated
function in :func:`no_type_check`.
+.. decorator:: type_check_only
+
+ Decorator to mark a class or function to be unavailable at runtime.
+
+ This decorator is itself not available at runtime. It is mainly
+ intended to mark classes that are defined in type stub files if
+ an implementation returns an instance of a private class::
+
+ @type_check_only
+ class Response: # private or not available at runtime
+ code: int
+ def get_header(self, name: str) -> str: ...
+
+ def fetch_response() -> Response: ...
+
+ Note that returning instances of private classes is not recommended.
+ It is usually preferable to make such classes public.
+
.. data:: Any
Special type indicating an unconstrained type.