fix: Python 3.7~3.8 bugs

This commit is contained in:
Shunsuke Shibayama 2023-09-13 11:09:30 +09:00
parent 75c1ac733c
commit aacdca31b8
6 changed files with 35 additions and 4 deletions

View file

@ -0,0 +1,6 @@
# in Python 3.7, `sum` takes no keyword arguments
def sum(iterable, start=0):
s = start
for i in iterable:
s += i
return s

View file

@ -14,6 +14,8 @@ def contains_operator(y, elem) -> bool:
return True
elif hasattr(y, "try_new") and is_ok(y.try_new(elem)):
return True
elif hasattr(y, "__origin__") and hasattr(y.__origin__, "type_check"):
return y.__origin__.type_check(elem, y)
# TODO: trait check
return False
# [1] in [Int]