[Typing] Fix Sequence type GenericAlias only available after Python 3.9. (#4092)

This commit is contained in:
SangBin Cho
2024-04-16 06:47:31 +09:00
committed by GitHub
parent 4695397dcf
commit 37e84a403d
4 changed files with 9 additions and 7 deletions

View File

@@ -6,11 +6,12 @@ import socket
import subprocess
import uuid
import warnings
from collections import OrderedDict, defaultdict
from collections import defaultdict
from functools import lru_cache, partial
from platform import uname
from typing import (Any, AsyncIterator, Awaitable, Callable, Dict, Generic,
Hashable, List, Optional, Tuple, TypeVar, Union)
Hashable, List, Optional, OrderedDict, Tuple, TypeVar,
Union)
import psutil
import torch
@@ -51,7 +52,7 @@ class Counter:
class LRUCache(Generic[T]):
def __init__(self, capacity: int):
self.cache = OrderedDict[Hashable, T]()
self.cache: OrderedDict[Hashable, T] = OrderedDict()
self.capacity = capacity
def __contains__(self, key: Hashable) -> bool: