77import sys
88from io import BytesIO
99from pathlib import Path
10- from typing import BinaryIO
10+ from typing import Any , BinaryIO
1111
1212import pytest
1313from packaging .version import parse as parse_version
@@ -44,7 +44,7 @@ def test_sanity() -> None:
4444 pytest .param (ImageFont .Layout .RAQM , marks = skip_unless_feature ("raqm" )),
4545 ],
4646)
47- def layout_engine (request ) :
47+ def layout_engine (request : pytest . FixtureRequest ) -> ImageFont . Layout :
4848 return request .param
4949
5050
@@ -535,21 +535,23 @@ def test_unicode_extended(layout_engine: ImageFont.Layout) -> None:
535535 (("linux" , "/usr/local/share/fonts" ), ("darwin" , "/System/Library/Fonts" )),
536536)
537537@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 :
539541 def _test_fake_loading_font (path_to_fake : str , fontname : str ) -> None :
540542 # Make a copy of FreeTypeFont so we can patch the original
541543 free_type_font = copy .deepcopy (ImageFont .FreeTypeFont )
542544 with monkeypatch .context () as m :
543545 m .setattr (ImageFont , "_FreeTypeFont" , free_type_font , raising = False )
544546
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+ ):
546550 if filepath == path_to_fake :
547551 return ImageFont ._FreeTypeFont (
548- FONT_PATH , size , index , encoding , * args , ** kwargs
552+ FONT_PATH , size , index , encoding , * args
549553 )
550- return ImageFont ._FreeTypeFont (
551- filepath , size , index , encoding , * args , ** kwargs
552- )
554+ return ImageFont ._FreeTypeFont (filepath , size , index , encoding , * args )
553555
554556 m .setattr (ImageFont , "FreeTypeFont" , loadable_font )
555557 font = ImageFont .truetype (fontname )
@@ -563,7 +565,7 @@ def loadable_font(filepath, size, index, encoding, *args, **kwargs):
563565 if platform == "linux" :
564566 monkeypatch .setenv ("XDG_DATA_DIRS" , "/usr/share/:/usr/local/share/" )
565567
566- def fake_walker (path ) :
568+ def fake_walker (path : str ) -> list [ tuple [ str , list [ str ], list [ str ]]] :
567569 if path == font_directory :
568570 return [
569571 (
@@ -1101,7 +1103,7 @@ def test_oom(test_file: str) -> None:
11011103 font .getmask ("Test Text" )
11021104
11031105
1104- def test_raqm_missing_warning (monkeypatch ) -> None :
1106+ def test_raqm_missing_warning (monkeypatch : pytest . MonkeyPatch ) -> None :
11051107 monkeypatch .setattr (ImageFont .core , "HAVE_RAQM" , False )
11061108 with pytest .warns (UserWarning ) as record :
11071109 font = ImageFont .truetype (
0 commit comments