From d6a69555b6757a571e8b85c35a44a44df77ea3a9 Mon Sep 17 00:00:00 2001 From: flying-sheep Date: Sat, 17 Jan 2015 13:49:44 +0100 Subject: [PATCH 1/2] Replaced comments with string literals fixes #35 --- pep-0484.txt | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pep-0484.txt b/pep-0484.txt index f2825fb0..6e7acf31 100644 --- a/pep-0484.txt +++ b/pep-0484.txt @@ -260,9 +260,9 @@ hinting, use the following: * a ``@no_type_checks`` decorator on classes and functions -* a ``# type: ignore`` comment on arbitrary lines +* a ``'''type: ignore'''`` string literal on arbitrary lines -.. FIXME: should we have a module-wide comment as well? +.. FIXME: should we have a module-wide string literals as well? Type Hints on Local and Global Variables @@ -272,14 +272,16 @@ No first-class syntax support for explicitly marking variables as being of a specific type is added by this PEP. To help with type inference in complex cases, a comment of the following format may be used:: - x = [] # type: List[Employee] + '''type: List[Employee]''' + x = [] In the case where type information for a local variable is needed before if was declared, an ``Undefined`` placeholder might be used:: from typing import Undefined - - x = Undefined # type: List[Employee] + + '''type: List[Employee]''' + x = Undefined y = Undefined(int) If type hinting proves useful in general, a syntax for typing variables @@ -327,9 +329,12 @@ generics and union types: * TypeVar, used as ``X = TypeVar('X', Type1, Type2, Type3)`` or simply ``Y = TypeVar('Y')`` -* Undefined, used as ``local_variable = Undefined # type: List[int]`` or - ``local_variable = Undefined(List[int])`` (the latter being slower - during runtime) +* Undefined, used as ``local_variable = Undefined(List[int])`` or:: + + '''type: List[int]''' + local_variable = Undefined + + (the former being slower during runtime) * Callable, used as ``Callable[[Arg1Type, Arg2Type], ReturnType]`` From baf9ec346e3213d0672a4c4e97ecbe089196739b Mon Sep 17 00:00:00 2001 From: flying-sheep Date: Sat, 17 Jan 2015 14:49:53 +0100 Subject: [PATCH 2/2] =?UTF-8?q?missed=20one=20instance=20of=20=E2=80=9Ccom?= =?UTF-8?q?ment=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pep-0484.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pep-0484.txt b/pep-0484.txt index 6e7acf31..ff52ef1b 100644 --- a/pep-0484.txt +++ b/pep-0484.txt @@ -270,7 +270,7 @@ Type Hints on Local and Global Variables No first-class syntax support for explicitly marking variables as being of a specific type is added by this PEP. To help with type inference in -complex cases, a comment of the following format may be used:: +complex cases, a string literal of the following format may be used:: '''type: List[Employee]''' x = []