7
7
import sys
8
8
from io import BytesIO
9
9
from pathlib import Path
10
- from typing import BinaryIO
10
+ from typing import Any , BinaryIO
11
11
12
12
import pytest
13
13
from packaging .version import parse as parse_version
@@ -44,7 +44,7 @@ def test_sanity() -> None:
44
44
pytest .param (ImageFont .Layout .RAQM , marks = skip_unless_feature ("raqm" )),
45
45
],
46
46
)
47
- def layout_engine (request ) :
47
+ def layout_engine (request : pytest . FixtureRequest ) -> ImageFont . Layout :
48
48
return request .param
49
49
50
50
@@ -535,21 +535,23 @@ def test_unicode_extended(layout_engine: ImageFont.Layout) -> None:
535
535
(("linux" , "/usr/local/share/fonts" ), ("darwin" , "/System/Library/Fonts" )),
536
536
)
537
537
@pytest .mark .skipif (is_win32 (), reason = "requires Unix or macOS" )
538
- def test_find_font (monkeypatch , platform , font_directory ) -> None :
538
+ def test_find_font (
539
+ monkeypatch : pytest .MonkeyPatch , platform : str , font_directory : str
540
+ ) -> None :
539
541
def _test_fake_loading_font (path_to_fake : str , fontname : str ) -> None :
540
542
# Make a copy of FreeTypeFont so we can patch the original
541
543
free_type_font = copy .deepcopy (ImageFont .FreeTypeFont )
542
544
with monkeypatch .context () as m :
543
545
m .setattr (ImageFont , "_FreeTypeFont" , free_type_font , raising = False )
544
546
545
- def loadable_font (filepath , size , index , encoding , * args , ** kwargs ):
547
+ def loadable_font (
548
+ filepath : str , size : int , index : int , encoding : str , * args : Any
549
+ ):
546
550
if filepath == path_to_fake :
547
551
return ImageFont ._FreeTypeFont (
548
- FONT_PATH , size , index , encoding , * args , ** kwargs
552
+ FONT_PATH , size , index , encoding , * args
549
553
)
550
- return ImageFont ._FreeTypeFont (
551
- filepath , size , index , encoding , * args , ** kwargs
552
- )
554
+ return ImageFont ._FreeTypeFont (filepath , size , index , encoding , * args )
553
555
554
556
m .setattr (ImageFont , "FreeTypeFont" , loadable_font )
555
557
font = ImageFont .truetype (fontname )
@@ -563,7 +565,7 @@ def loadable_font(filepath, size, index, encoding, *args, **kwargs):
563
565
if platform == "linux" :
564
566
monkeypatch .setenv ("XDG_DATA_DIRS" , "/usr/share/:/usr/local/share/" )
565
567
566
- def fake_walker (path ) :
568
+ def fake_walker (path : str ) -> list [ tuple [ str , list [ str ], list [ str ]]] :
567
569
if path == font_directory :
568
570
return [
569
571
(
@@ -1101,7 +1103,7 @@ def test_oom(test_file: str) -> None:
1101
1103
font .getmask ("Test Text" )
1102
1104
1103
1105
1104
- def test_raqm_missing_warning (monkeypatch ) -> None :
1106
+ def test_raqm_missing_warning (monkeypatch : pytest . MonkeyPatch ) -> None :
1105
1107
monkeypatch .setattr (ImageFont .core , "HAVE_RAQM" , False )
1106
1108
with pytest .warns (UserWarning ) as record :
1107
1109
font = ImageFont .truetype (
0 commit comments