Skip to content

Commit 6cf7408

Browse files
authored
Merge pull request #373 from bgilbert/pre-commit
pre-commit: update Ruff
2 parents 0e2fb7d + d2f8a7a commit 6cf7408

8 files changed

Lines changed: 24 additions & 17 deletions

File tree

.github/workflows/python.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ jobs:
8585
run: |
8686
python -m pip install --upgrade pip
8787
pip install auditwheel build jinja2 pytest
88+
if [ "${{ matrix.python-version }}" = 3.13t ]; then
89+
# newer versions drop 3.13t wheels
90+
pip install pillow==12.2.0
91+
fi
8892
- name: Install OpenSlide (system)
8993
if: matrix.openslide == 'system'
9094
run: |
@@ -178,6 +182,10 @@ jobs:
178182
run: |
179183
python -m pip install --upgrade pip
180184
pip install build flask pytest
185+
if [ "${{ matrix.python-version }}" = 3.13t ]; then
186+
# newer versions drop 3.13t wheels
187+
pip install pillow==12.2.0
188+
fi
181189
- name: Install OpenSlide (zip)
182190
if: matrix.openslide == 'zip'
183191
env:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
- id: trailing-whitespace
2727

2828
- repo: https://github.com/astral-sh/ruff-pre-commit
29-
rev: v0.15.20
29+
rev: v0.16.1
3030
hooks:
3131
- id: ruff-check
3232
types_or: [python, pyi, pyproject]

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
# |version| and |release|, also used in various other places throughout the
5252
# built documents.
5353
#
54-
import _version # noqa: E402 module-level-import-not-at-top-of-file
54+
import _version
5555

5656
# The short X.Y version.
5757
version = _version.__version__

openslide/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ def set_cache(self, cache: OpenSlideCache) -> None: # noqa: B027
164164
This class does not support caching, so this method does nothing.
165165
166166
cache: an OpenSlideCache object."""
167-
pass
168167

169168
def get_thumbnail(self, size: tuple[int, int]) -> Image.Image:
170169
"""Return a PIL.Image containing an RGB thumbnail of the image.

openslide/lowlevel.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,16 @@ def __call__(self, *_args: Any) -> Any:
310310

311311

312312
_P = ParamSpec('_P')
313-
_T = TypeVar('_T', covariant=True)
313+
_T_co = TypeVar('_T_co', covariant=True)
314314

315315

316-
class _Func(Protocol[_P, _T]):
316+
class _Func(Protocol[_P, _T_co]):
317317
available: bool
318318

319-
def __call__(self, *args: _P.args) -> _T: ... # type: ignore[valid-type]
319+
def __call__(self, *args: _P.args) -> _T_co: ... # type: ignore[valid-type]
320320

321321

322-
class _CTypesFunc(_Func[_P, _T]):
322+
class _CTypesFunc(_Func[_P, _T_co]):
323323
restype: type | None
324324
argtypes: list[type]
325325
errcheck: _ErrCheck
@@ -337,9 +337,9 @@ def _func(
337337
argtypes: list[type],
338338
errcheck: _ErrCheck = _check_error,
339339
minimum_version: str | None = None,
340-
) -> _Func[_P, _T]:
340+
) -> _Func[_P, _T_co]:
341341
try:
342-
func: _CTypesFunc[_P, _T] = getattr(_lib, name)
342+
func: _CTypesFunc[_P, _T_co] = getattr(_lib, name)
343343
except AttributeError:
344344
if minimum_version is None:
345345
raise
@@ -355,9 +355,9 @@ def _func(
355355

356356
def _wraps_funcs(
357357
wrapped: list[_Func[..., Any]],
358-
) -> Callable[[Callable[_P, _T]], _Func[_P, _T]]:
359-
def decorator(fn: Callable[_P, _T]) -> _Func[_P, _T]:
360-
f = cast('_Func[_P, _T]', fn)
358+
) -> Callable[[Callable[_P, _T_co]], _Func[_P, _T_co]]:
359+
def decorator(fn: Callable[_P, _T_co]) -> _Func[_P, _T_co]:
360+
f = cast('_Func[_P, _T_co]', fn)
361361
f.available = True
362362
for w in wrapped:
363363
f.available = f.available and w.available

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ quote-style = "single"
7878
extend-select = ["B", "C4", "FLY", "I", "RUF", "UP"]
7979
# ambiguous-variable-name
8080
ignore = ["E741"]
81+
typing-extensions = false
8182

8283
[tool.ruff.lint.isort]
8384
force-sort-within-sections = true

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Load version string
88
with open(Path(__file__).parent / 'openslide/_version.py') as _fh:
9-
exec(_fh.read()) # instantiates __version__
9+
exec(_fh.read()) # instantiates __version__ # noqa: S102
1010

1111
# use the Limited API on Python 3.11+ on GIL builds; build release-specific
1212
# wheels on older or free-threaded Python

tests/test_imageslide.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ def test_open(self) -> None:
3939

4040
def test_open_image(self) -> None:
4141
# passing PIL.Image to ImageSlide
42-
with Image.open(file_path('boxes.png')) as img:
43-
with ImageSlide(img) as osr:
44-
self.assertEqual(osr.dimensions, (300, 250))
45-
self.assertEqual(repr(osr), f'ImageSlide({img!r})')
42+
with Image.open(file_path('boxes.png')) as img, ImageSlide(img) as osr:
43+
self.assertEqual(osr.dimensions, (300, 250))
44+
self.assertEqual(repr(osr), f'ImageSlide({img!r})')
4645

4746
@unittest.skipUnless(
4847
sys.getfilesystemencoding() == 'utf-8',

0 commit comments

Comments
 (0)