Skip to content

Commit 0ca94f0

Browse files
committed
Apply BDF fixes. Refactor more types to os.PathLike.
1 parent 3a261ca commit 0ca94f0

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Added
1313

1414
Fixed
1515
- Functions accepting `Path`-like parameters now accept the more correct `os.PathLike` type.
16+
- BDF files with blank lines no longer fail to load with an "Unknown keyword" error.
1617

1718
13.2.0 - 2021-12-24
1819
-------------------

tcod/tileset.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import itertools
1616
import os
17-
from pathlib import Path
17+
from os import PathLike
1818
from typing import Any, Iterable, Optional, Tuple, Union
1919

2020
import numpy as np
@@ -250,7 +250,7 @@ def set_default(tileset: Tileset) -> None:
250250
lib.TCOD_set_default_tileset(tileset._tileset_p)
251251

252252

253-
def load_truetype_font(path: Union[str, Path], tile_width: int, tile_height: int) -> Tileset:
253+
def load_truetype_font(path: Union[str, PathLike[str]], tile_width: int, tile_height: int) -> Tileset:
254254
"""Return a new Tileset from a `.ttf` or `.otf` file.
255255
256256
Same as :any:`set_truetype_font`, but returns a :any:`Tileset` instead.
@@ -267,7 +267,7 @@ def load_truetype_font(path: Union[str, Path], tile_width: int, tile_height: int
267267

268268

269269
@deprecate("Accessing the default tileset is deprecated.")
270-
def set_truetype_font(path: Union[str, Path], tile_width: int, tile_height: int) -> None:
270+
def set_truetype_font(path: Union[str, PathLike[str]], tile_width: int, tile_height: int) -> None:
271271
"""Set the default tileset from a `.ttf` or `.otf` file.
272272
273273
`path` is the file path for the font file.
@@ -293,7 +293,7 @@ def set_truetype_font(path: Union[str, Path], tile_width: int, tile_height: int)
293293
raise RuntimeError(ffi.string(lib.TCOD_get_error()))
294294

295295

296-
def load_bdf(path: Union[str, Path]) -> Tileset:
296+
def load_bdf(path: Union[str, PathLike[str]]) -> Tileset:
297297
"""Return a new Tileset from a `.bdf` file.
298298
299299
For the best results the font should be monospace, cell-based, and
@@ -314,7 +314,9 @@ def load_bdf(path: Union[str, Path]) -> Tileset:
314314
return Tileset._claim(cdata)
315315

316316

317-
def load_tilesheet(path: Union[str, Path], columns: int, rows: int, charmap: Optional[Iterable[int]]) -> Tileset:
317+
def load_tilesheet(
318+
path: Union[str, PathLike[str]], columns: int, rows: int, charmap: Optional[Iterable[int]]
319+
) -> Tileset:
318320
"""Return a new Tileset from a simple tilesheet image.
319321
320322
`path` is the file path to a PNG file with the tileset.

0 commit comments

Comments
 (0)