Open kylemart opened 7 years ago
I have same question like this.The version is python3.6.3.
from typing import Iterable
from overloading import overload
@overload
def biggest(items: Iterable[int]):
return max(items)
@overload
def biggest(items: Iterable[str]):
return max(items, key=len)
print(biggest(['a', 'abc', 'bc']))
Then i got:
Traceback (most recent call last):
File "C:/Users/Ryan/Desktop/thouger/code_python/test.py", line 10, in <module>
def biggest(items: int):
File "C:\Users\Ryan\Desktop\thouger\Anaconda3\lib\site-packages\overloading.py", line 63, in overload
return register(__registry[fname], func)
File "C:\Users\Ryan\Desktop\thouger\Anaconda3\lib\site-packages\overloading.py", line 211, in register
.format(dp.__name__, str.join(', ', (_repr(t) for t in dup_sig))))
overloading.OverloadingError: Failed to overload function 'biggest': non-unique signature (<class 'int'>).
When i put:
from collections import Iterable
from overloading import overload
@overload
def biggest(items: Iterable[int]):
return max(items)
@overload
def biggest(items: Iterable[str]):
return max(items, key=len)
print(biggest(['a', 'abc', 'bc']))
I got:
Traceback (most recent call last):
File "C:/Users/Ryan/Desktop/thouger/code_python/test.py", line 6, in <module>
def biggest(items: Iterable[int]):
TypeError: 'ABCMeta' object is not subscriptable
I think it is useless in python 3.6 and above.
Same problem here, python 3.6.
Is there a fix?
EDIT: Just realized your test suite doesn't cover Python 3.6.X.
I don't have this issue when using Python 3.4.3, but when using Python 3.6.3 I receive OverloadErrors when providing overrides for class instance methods.
Here's a case that gives me an error in the newer version of Python:
What's going on?