From ab40a28c1cee4ea06e8ff192bf2a5a61b12cd741 Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Sun, 20 Aug 2017 19:56:16 -0700 Subject: [PATCH] Type annotations: Switch open/save BytesIO->BinaryIO. --- src/PIL/Image.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 858b585a1..6596575de 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -25,12 +25,11 @@ # if False: - from typing import Any, Text, Optional, Tuple, List, Sequence, Union, Callable, Dict + from typing import Any, Text, Optional, Tuple, List, Sequence, Union, Callable, Dict, BinaryIO from PIL.aliases import * # Just required for typing, or gradual module inclusion while adding annotation? - from io import BytesIO import pathlib # from . import ImagingPalette ## This will need a stub? from . import ImagePalette @@ -1934,7 +1933,7 @@ class Image(object): return self.transform((w, h), AFFINE, matrix, resample) def save(self, fp, format=None, **params): - # type: (Union[Text, pathlib.Path, BytesIO], Optional[Text], **Any) -> None + # type: (Union[Text, pathlib.Path, BinaryIO], Optional[Text], **Any) -> None """ Saves this image under the given filename. If no format is specified, the format to use is determined from the filename @@ -2615,7 +2614,7 @@ def _decompression_bomb_check(size): def open(fp, mode="r"): - # type: (Union[Text, pathlib.Path, BytesIO], Text) -> Image + # type: (Union[Text, pathlib.Path, BinaryIO], Text) -> Image """ Opens and identifies the given image file.