Skip to content

Commit b18f83a

Browse files
authored
🔧 mypy fix typing in pyramid.py (#938)
- Update for compatibility with `mypy>=1.16`.
1 parent 6b4a75a commit b18f83a

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

.github/workflows/mypy-type-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ jobs:
5050
tiatoolbox/models/__init__.py \
5151
tiatoolbox/models/models_abc.py \
5252
tiatoolbox/models/architecture/__init__.py \
53-
tiatoolbox/models/architecture/utils.py \
53+
tiatoolbox/models/architecture/utils.py

requirements/requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-r ../docs/requirements.txt
33
coverage>=7.0.0
44
docutils>=0.18.1
5-
mypy>=1.6.1
5+
mypy>=1.16
66
pip>=22.3
77
poetry-bumpversion>=0.3.1
88
pre-commit>=2.20.0

tiatoolbox/tools/pyramid.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import zipfile
1818
from io import BytesIO
1919
from pathlib import Path
20-
from typing import TYPE_CHECKING
20+
from typing import TYPE_CHECKING, Literal
2121

2222
import defusedxml
2323
import numpy as np
@@ -352,7 +352,9 @@ def save_tile(tile_path: Path, tile: Image.Image) -> None:
352352
)
353353

354354
else: # container == "tar":
355-
compression2mode = {
355+
compression2mode: dict[
356+
str | None, Literal["w", "w:gz", "w:bz2", "w:xz"]
357+
] = {
356358
None: "w",
357359
"gzip": "w:gz",
358360
"bz2": "w:bz2",
@@ -362,7 +364,9 @@ def save_tile(tile_path: Path, tile: Image.Image) -> None:
362364
msg = "Unsupported compression for tar."
363365
raise ValueError(msg)
364366

365-
tar_archive = tarfile.TarFile.open(path, mode=compression2mode[compression])
367+
tar_archive = tarfile.TarFile.open(
368+
str(path), mode=compression2mode[compression]
369+
)
366370

367371
def save_tile(tile_path: Path, tile: Image.Image) -> None:
368372
"""Write the tile to the output zip."""

0 commit comments

Comments
 (0)