Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tests/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
if TYPE_CHECKING:
from collections.abc import Callable

from pytest_benchmark.fixture import ( # type: ignore[import-not-found]
from pytest_benchmark.fixture import ( # type: ignore[unused-ignore, import-not-found]
BenchmarkFixture,
)

Expand Down
4 changes: 2 additions & 2 deletions Tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

gil_enabled_at_start = True
if FREE_THREADED_BUILD:
gil_enabled_at_start = sys._is_gil_enabled() # type: ignore[attr-defined]
gil_enabled_at_start = sys._is_gil_enabled() # type: ignore[attr-defined,unused-ignore]


def pytest_report_header(config: pytest.Config) -> str:
Expand All @@ -28,7 +28,7 @@ def pytest_terminal_summary(terminalreporter: pytest.TerminalReporter) -> None:
if (
FREE_THREADED_BUILD
and not gil_enabled_at_start
and sys._is_gil_enabled() # type: ignore[attr-defined]
and sys._is_gil_enabled() # type: ignore[attr-defined,unused-ignore]
):
tr = terminalreporter
tr.ensure_newline()
Expand Down
13 changes: 1 addition & 12 deletions Tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import warnings
from pathlib import Path
from types import ModuleType
from typing import IO, Any
from typing import IO

import pytest

Expand Down Expand Up @@ -197,17 +197,6 @@ def test_fp_name(self, tmp_path: Path) -> None:
class FP(io.BytesIO):
name: Path

if sys.version_info >= (3, 12):
from collections.abc import Buffer

def write(self, data: Buffer) -> int:
return len(data)

else:

def write(self, data: Any) -> int:
return len(data)

fp = FP()
fp.name = temp_file

Expand Down
12 changes: 5 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,14 @@ lint.isort.required-imports = [
max_supported_python = "3.15"

[tool.mypy]
follow_imports = "silent"
python_version = "3.11"
disallow_any_generics = true
disallow_untyped_defs = true
warn_redundant_casts = true
warn_unused_ignores = true
disallow_subclassing_any = false
disallow_untyped_calls = false
warn_return_any = false
warn_unreachable = true
enable_error_code = "ignore-without-code"
extra_checks = true
strict = true
pretty = true
no_implicit_reexport = false

[tool.pytest]
addopts = [ "-ra", "--color=auto" ]
Expand Down
4 changes: 3 additions & 1 deletion src/PIL/EpsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ def _open(self) -> None:
imagedata_size: tuple[int, int] | None = None

byte_arr = bytearray(255)
bytes_mv = memoryview(byte_arr)
# the extra `bytes` annotation here works around several false positive
# `comparison-overlap` mypy errors
bytes_mv: bytes | memoryview = memoryview(byte_arr)
bytes_read = 0
reading_header_comments = True
reading_trailer_comments = False
Expand Down
5 changes: 3 additions & 2 deletions src/PIL/GifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,8 +1195,9 @@ class Collector(BytesIO):
data = []

def write(self, data: Buffer) -> int:
self.data.append(data)
return len(data)
data_bytes = bytes(data)
self.data.append(data_bytes)
return len(data_bytes)

im.load() # make sure raster data is available

Expand Down
2 changes: 1 addition & 1 deletion src/PIL/ImageGrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def grab(
scale = 1 if scale_down else 2
im_cropped = im.resize(
((right - left) * scale, (bottom - top) * scale),
box=tuple(coord * 2 for coord in bbox),
box=(left * 2, top * 2, right * 2, bottom * 2),
)
else:
im_cropped = im.crop(bbox)
Expand Down
Loading