mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-10-27 22:21:33 +03:00
Added type hints
This commit is contained in:
parent
76f04b46c5
commit
4b90888a7d
|
|
@ -33,7 +33,7 @@ def test_multiple_load_operations() -> None:
|
|||
assert_image_equal_tofile(im, "Tests/images/gbr.png")
|
||||
|
||||
|
||||
def create_gbr_image(info: dict[str, int] = {}, magic_number=b"") -> BytesIO:
|
||||
def create_gbr_image(info: dict[str, int] = {}, magic_number: bytes = b"") -> BytesIO:
|
||||
return BytesIO(
|
||||
b"".join(
|
||||
_binary.o32be(i)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ TEST_FILE = "Tests/images/iptc.jpg"
|
|||
|
||||
|
||||
def create_iptc_image(info: dict[str, int] = {}) -> BytesIO:
|
||||
def field(tag, value):
|
||||
def field(tag: tuple[int, int], value: bytes) -> bytes:
|
||||
return bytes((0x1C,) + tag + (0, len(value))) + value
|
||||
|
||||
data = field((3, 60), bytes((info.get("layers", 1), info.get("component", 0))))
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class Text:
|
|||
else:
|
||||
return "L"
|
||||
|
||||
def get_length(self):
|
||||
def get_length(self) -> float:
|
||||
"""
|
||||
Returns length (in pixels with 1/64 precision) of text.
|
||||
|
||||
|
|
@ -130,8 +130,7 @@ class Text:
|
|||
|
||||
:return: Either width for horizontal text, or height for vertical text.
|
||||
"""
|
||||
split_character = "\n" if isinstance(self.text, str) else b"\n"
|
||||
if split_character in self.text:
|
||||
if "\n" in self.text if isinstance(self.text, str) else b"\n" in self.text:
|
||||
msg = "can't measure length of multiline text"
|
||||
raise ValueError(msg)
|
||||
return self.font.getlength(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user