From 5ee809495c24574e278b7a85918edab4244dfad0 Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Tue, 22 Aug 2017 12:43:13 -0700 Subject: [PATCH] Type annotations: Image.py: Initial annotation for expression analyzer. --- src/PIL/Image.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 9fe356dad..773b3270c 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -489,21 +489,26 @@ def _getencoder(mode, encoder_name, args, extra=()): # Simple expression analyzer def coerce_e(value): + # type: (Any) -> _E ## FIXME TYPING: As detailed as possible? return value if isinstance(value, _E) else _E(value) class _E(object): def __init__(self, data): + # type: (Any) -> None ## FIXME TYPING: As detailed as possible? self.data = data def __add__(self, other): + # type: (Any) -> _E ## FIXME TYPING: As detailed as possible? return _E((self.data, "__add__", coerce_e(other).data)) def __mul__(self, other): + # type: (Any) -> _E ## FIXME TYPING: As detailed as possible? return _E((self.data, "__mul__", coerce_e(other).data)) def _getscaleoffset(expr): + # type: (Any) -> Tuple[Any, Any] ## FIXME TYPING: Can be improved? stub = ["stub"] data = expr(_E(stub)).data try: