Browse Source

LibGfx: Unbreak building with Python 3.9

Unbreaks building with macOS 13 system python, and is less code too.
No behavior change.
Nico Weber 1 year ago
parent
commit
b2302ed23f
1 changed files with 7 additions and 9 deletions
  1. 7 9
      Userland/Libraries/LibGfx/TIFFGenerator.py

+ 7 - 9
Userland/Libraries/LibGfx/TIFFGenerator.py

@@ -9,7 +9,7 @@ import re
 from enum import Enum
 from collections import namedtuple
 from pathlib import Path
-from typing import List, Type
+from typing import List, Optional, Type
 
 
 class TIFFType(Enum):
@@ -73,7 +73,7 @@ LICENSE = R"""/*
  */"""
 
 
-def export_enum_to_cpp(e: Type[Enum], special_name: str | None = None) -> str:
+def export_enum_to_cpp(e: Type[Enum], special_name: Optional[str] = None) -> str:
     output = f'enum class {special_name if special_name else e.__name__} {{\n'
 
     for entry in e:
@@ -94,13 +94,11 @@ def tiff_type_to_cpp(t: TIFFType, without_promotion: bool = False) -> str:
     # Note that the Value<> type doesn't include u16 for this reason
     if not without_promotion:
         t = promote_type(t)
-    match t:
-        case TIFFType.UnsignedShort:
-            return 'u16'
-        case TIFFType.UnsignedLong:
-            return 'u32'
-        case _:
-            raise RuntimeError(f'Type "{t}" not recognized, please update tiff_type_to_read_only_cpp()')
+    if t == TIFFType.UnsignedShort:
+        return 'u16'
+    if t == TIFFType.UnsignedLong:
+        return 'u32'
+    raise RuntimeError(f'Type "{t}" not recognized, please update tiff_type_to_read_only_cpp()')
 
 
 def export_promoter() -> str: