Skip to content

Commit 14f4549

Browse files
committed
Use the more correct os.PathLike type hint.
1 parent 033c862 commit 14f4549

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ v2.0.0
88

99
Unreleased
1010
------------------
11+
Fixed
12+
- Functions accepting `Path`-like parameters now accept the more correct `os.PathLike` type.
1113

1214
13.2.0 - 2021-12-24
1315
-------------------

tcod/console.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import os
99
import warnings
10-
from pathlib import Path
10+
from os import PathLike
1111
from typing import Any, Iterable, Optional, Sequence, Tuple, Union
1212

1313
import numpy as np
@@ -1267,7 +1267,7 @@ def recommended_size() -> Tuple[int, int]:
12671267
return w, h
12681268

12691269

1270-
def load_xp(path: Union[str, Path], order: Literal["C", "F"] = "C") -> Tuple[Console, ...]:
1270+
def load_xp(path: Union[str, PathLike[str]], order: Literal["C", "F"] = "C") -> Tuple[Console, ...]:
12711271
"""Load a REXPaint file as a tuple of consoles.
12721272
12731273
`path` is the name of the REXPaint file to load.
@@ -1309,7 +1309,7 @@ def load_xp(path: Union[str, Path], order: Literal["C", "F"] = "C") -> Tuple[Con
13091309

13101310

13111311
def save_xp(
1312-
path: Union[str, Path],
1312+
path: Union[str, PathLike[str]],
13131313
consoles: Iterable[Console],
13141314
compress_level: int = 9,
13151315
) -> None:

tcod/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
from __future__ import annotations
99

10-
from pathlib import Path
10+
from os import PathLike
1111
from typing import Any, Dict, Tuple, Union
1212

1313
import numpy as np
@@ -336,7 +336,7 @@ def _get_format_name(format: int) -> str:
336336
" It's recommended to load images with a more complete image library such as python-Pillow or python-imageio.",
337337
category=PendingDeprecationWarning,
338338
)
339-
def load(filename: Union[str, Path]) -> NDArray[np.uint8]:
339+
def load(filename: Union[str, PathLike[str]]) -> NDArray[np.uint8]:
340340
"""Load a PNG file as an RGBA array.
341341
342342
`filename` is the name of the file to load.

0 commit comments

Comments
 (0)