Merge branch 'main' into imagetype

This commit is contained in:
Andrew Murray 2023-12-27 08:36:09 +11:00
commit dc78fd7de0
7 changed files with 18 additions and 10 deletions

View File

@ -1,5 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
from __future__ import annotations
# Copyright 2020 Google LLC # Copyright 2020 Google LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -13,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import annotations
import atheris import atheris

View File

@ -1,5 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
from __future__ import annotations
# Copyright 2020 Google LLC # Copyright 2020 Google LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -13,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import annotations
import atheris import atheris

View File

@ -233,7 +233,7 @@ htmlhelp_basename = "PillowPILForkdoc"
# -- Options for LaTeX output --------------------------------------------- # -- Options for LaTeX output ---------------------------------------------
latex_elements = { latex_elements: dict[str, str] = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper', # 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt'). # The font size ('10pt', '11pt' or '12pt').

View File

@ -5,7 +5,7 @@ from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype("Tests/fonts/NotoSans-Regular.ttf", 16) font = ImageFont.truetype("Tests/fonts/NotoSans-Regular.ttf", 16)
def test(anchor): def test(anchor: str) -> Image.Image:
im = Image.new("RGBA", (200, 100), "white") im = Image.new("RGBA", (200, 100), "white")
d = ImageDraw.Draw(im) d = ImageDraw.Draw(im)
d.line(((100, 0), (100, 100)), "gray") d.line(((100, 0), (100, 100)), "gray")

View File

@ -15,7 +15,7 @@ except AttributeError:
pass pass
def testimage(): def testimage() -> None:
""" """
PIL lets you create in-memory images with various pixel types: PIL lets you create in-memory images with various pixel types:

View File

@ -24,7 +24,7 @@ class ContainerIO:
file (for example a TAR file). file (for example a TAR file).
""" """
def __init__(self, file, offset, length): def __init__(self, file, offset, length) -> None:
""" """
Create file object. Create file object.

View File

@ -16,6 +16,7 @@
from __future__ import annotations from __future__ import annotations
import io import io
from types import TracebackType
from . import ContainerIO from . import ContainerIO
@ -23,7 +24,7 @@ from . import ContainerIO
class TarIO(ContainerIO.ContainerIO): class TarIO(ContainerIO.ContainerIO):
"""A file object that provides read access to a given member of a TAR file.""" """A file object that provides read access to a given member of a TAR file."""
def __init__(self, tarfile, file): def __init__(self, tarfile: str, file: str) -> None:
""" """
Create file object. Create file object.
@ -57,11 +58,16 @@ class TarIO(ContainerIO.ContainerIO):
super().__init__(self.fh, self.fh.tell(), size) super().__init__(self.fh, self.fh.tell(), size)
# Context manager support # Context manager support
def __enter__(self): def __enter__(self) -> TarIO:
return self return self
def __exit__(self, *args): def __exit__(
self,
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None:
self.close() self.close()
def close(self): def close(self) -> None:
self.fh.close() self.fh.close()