Skip to content

Commit a13caf3

Browse files
committed
Remove LRUCache typing and prevent negative size
1 parent 128315f commit a13caf3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pyiceberg/manifest.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import math
2020
import threading
2121
from abc import ABC, abstractmethod
22-
from collections.abc import Iterator
22+
from collections.abc import Iterator, MutableMapping
2323
from copy import copy
2424
from enum import Enum
2525
from types import TracebackType
@@ -898,14 +898,12 @@ def __hash__(self) -> int:
898898
_DEFAULT_MANIFEST_CACHE_SIZE = 128
899899
_configured_manifest_cache_size = Config().get_int("manifest-cache-size")
900900
_manifest_cache_size = (
901-
_configured_manifest_cache_size if _configured_manifest_cache_size is not None else _DEFAULT_MANIFEST_CACHE_SIZE
901+
max(_configured_manifest_cache_size, 0) if _configured_manifest_cache_size is not None else _DEFAULT_MANIFEST_CACHE_SIZE
902902
)
903903

904-
# Lock for thread-safe cache access.
904+
# Lock for thread-safe cache access
905905
_manifest_cache_lock = threading.RLock()
906-
_manifest_cache: LRUCache[str, ManifestFile] | dict[str, ManifestFile] = (
907-
LRUCache(maxsize=_manifest_cache_size) if _manifest_cache_size > 0 else {}
908-
)
906+
_manifest_cache: MutableMapping[str, ManifestFile] = LRUCache(maxsize=_manifest_cache_size) if _manifest_cache_size > 0 else {}
909907

910908

911909
def clear_manifest_cache() -> None:

0 commit comments

Comments
 (0)