Skip to content

Commit

Permalink
fix: Add typing workaround for Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
rumpelsepp committed Jan 16, 2025
1 parent f051fe8 commit 293af7f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/gallia/cli/cursed_hr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from enum import IntEnum, unique
from math import ceil
from pathlib import Path
from typing import Any, BinaryIO
from typing import TYPE_CHECKING, Any, BinaryIO

import platformdirs
import zstandard as zstd
Expand Down Expand Up @@ -86,6 +86,14 @@ class PriorityZone:
priority: PenlogPriority


# NOTE: Workaround for compatibility with Python 3.11 and older, see:
# https://github.com/python/mypy/issues/13942
if TYPE_CHECKING:
IntArray = array[int]
else:
IntArray = array


class EntryCache:
"""
A simple two level cache that stores the latest accessed penlog entries.
Expand All @@ -97,7 +105,7 @@ class EntryCache:
def __init__(
self,
file: BinaryIO | mmap.mmap,
entry_positions: array[int],
entry_positions: IntArray,
cache_size: int = 20_000,
):
self.file = file
Expand Down

0 comments on commit 293af7f

Please sign in to comment.