From 65bb8034a81fed99ca01c07fad25c70db40270a7 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 25 Dec 2018 13:54:45 +0100 Subject: [PATCH 1/2] Document @typing.type_check_only --- Doc/library/typing.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index aa5e4d287ae79f..ebd199c73ae20b 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -932,6 +932,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. From 83afb0178a8c167a8c72607e153461a3141c4132 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" Date: Tue, 25 Dec 2018 12:56:58 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Documentation/2018-12-25-12-56-57.bpo-35581.aA7r6T.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2018-12-25-12-56-57.bpo-35581.aA7r6T.rst diff --git a/Misc/NEWS.d/next/Documentation/2018-12-25-12-56-57.bpo-35581.aA7r6T.rst b/Misc/NEWS.d/next/Documentation/2018-12-25-12-56-57.bpo-35581.aA7r6T.rst new file mode 100644 index 00000000000000..2fad3003e3b689 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2018-12-25-12-56-57.bpo-35581.aA7r6T.rst @@ -0,0 +1 @@ +@typing.type_check_only now allows type stubs to mark functions and classes not available during runtime. \ No newline at end of file