clarifying type annotations

This commit is contained in:
Eric Soroos 2017-11-13 09:33:33 +00:00
parent be22cc3165
commit af9c0a1cfd

View File

@ -544,8 +544,8 @@ class Image(object):
* :py:func:`~PIL.Image.new` * :py:func:`~PIL.Image.new`
* :py:func:`~PIL.Image.frombytes` * :py:func:`~PIL.Image.frombytes`
""" """
format = None format = None # type: Optional[Text]
format_description = None format_description = None # type: Optional[Text]
_close_exclusive_fp_after_loading = True _close_exclusive_fp_after_loading = True
def __init__(self): def __init__(self):
@ -559,7 +559,7 @@ class Image(object):
self.info = {} # type: Dict[Text, Any] self.info = {} # type: Dict[Text, Any]
self.category = NORMAL self.category = NORMAL
self.readonly = 0 # type: int self.readonly = 0 # type: int
self.pyaccess = None self.pyaccess = None # type: Optional[PyAccess.PyAccess]
@property @property
def width(self): def width(self):
@ -2623,7 +2623,7 @@ def _decompression_bomb_check(size):
def open(fp, mode="r"): def open(fp, mode="r"):
# type: (Union[Text, pathlib.Path, BinaryIO], Text) -> Image # type: (Union[Text, pathlib.Path, BinaryIO], Text) -> ImageFile.ImageFile
""" """
Opens and identifies the given image file. Opens and identifies the given image file.
@ -2668,7 +2668,7 @@ def open(fp, mode="r"):
preinit() preinit()
def _open_core(fp, filename, prefix): def _open_core(fp, filename, prefix):
# type: (BinaryIO, Text, Text) -> Optional[Image] # type: (BinaryIO, Text, Text) -> Optional[ImageFile.ImageFile]
for i in ID: for i in ID:
try: try:
factory, accept = OPEN[i] factory, accept = OPEN[i]