Skip to content

Commit

Permalink
workaround typing.Deque import error for Python 3.5 (apache#4254)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuochenKIDD authored and Xingyu Zhou committed Nov 13, 2019
1 parent 3a534bd commit 64c53f3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion python/tvm/relay/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,21 @@

import sys
from ast import literal_eval
from typing import Any, Deque, Dict, List, Optional, TypeVar, Tuple, Union
from collections import deque

try:
# no typing.Deque in Python 3.5
# https://bugs.python.org/issue29011
from typing import Any, Dict, List, Optional, TypeVar, Tuple, Union, MutableSequence, T, Deque
except ImportError:
class Deque(deque, MutableSequence[T], extra=deque):

def __new__(cls, *args, **kwds):
if _geqv(cls, Deque):
raise TypeError("Type Deque cannot be instantiated; "
"use deque() instead")
return deque.__new__(cls, *args, **kwds)

import tvm

from . import module
Expand Down

0 comments on commit 64c53f3

Please sign in to comment.