Migrate to py3 style type annotation: sphinx.util.png

This commit is contained in:
Takeshi KOMIYA 2019-06-03 22:06:44 +09:00
parent b5276b3965
commit 5115fb0172

View File

@ -20,8 +20,7 @@ DEPTH_CHUNK_START = b'tEXtDepth\x00'
IEND_CHUNK = b'\x00\x00\x00\x00IEND\xAE\x42\x60\x82' IEND_CHUNK = b'\x00\x00\x00\x00IEND\xAE\x42\x60\x82'
def read_png_depth(filename): def read_png_depth(filename: str) -> int:
# type: (str) -> int
"""Read the special tEXt chunk indicating the depth from a PNG file.""" """Read the special tEXt chunk indicating the depth from a PNG file."""
with open(filename, 'rb') as f: with open(filename, 'rb') as f:
f.seek(- (LEN_IEND + LEN_DEPTH), 2) f.seek(- (LEN_IEND + LEN_DEPTH), 2)
@ -33,8 +32,7 @@ def read_png_depth(filename):
return struct.unpack('!i', depthchunk[14:18])[0] return struct.unpack('!i', depthchunk[14:18])[0]
def write_png_depth(filename, depth): def write_png_depth(filename: str, depth: int) -> None:
# type: (str, int) -> None
"""Write the special tEXt chunk indicating the depth to a PNG file. """Write the special tEXt chunk indicating the depth to a PNG file.
The chunk is placed immediately before the special IEND chunk. The chunk is placed immediately before the special IEND chunk.