Python 3.9.0 (default, Dec 8 2022, 15:50:08)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mart
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/weilinxu/coder/MART/mart/__init__.py", line 3, in <module>
from mart import attack as attack
File "/home/weilinxu/coder/MART/mart/attack/__init__.py", line 1, in <module>
from .adversary import *
File "/home/weilinxu/coder/MART/mart/attack/adversary.py", line 15, in <module>
from .objective import Objective
File "/home/weilinxu/coder/MART/mart/attack/objective/__init__.py", line 2, in <module>
from .classification import *
File "/home/weilinxu/coder/MART/mart/attack/objective/classification.py", line 25, in <module>
class RandomTarget(Objective):
File "/home/weilinxu/coder/MART/mart/attack/objective/classification.py", line 26, in RandomTarget
def __init__(self, nb_classes: int, gain_fn: Callable[torch.Tensor, torch.Tensor]) -> None:
File "/home/weilinxu/.pyenv/versions/3.9.0/lib/python3.9/typing.py", line 826, in __getitem__
raise TypeError(f"Callable[args, result]: args must be a list."
TypeError: Callable[args, result]: args must be a list. Got <class 'torch.Tensor'>
>>>
The type annotation has a syntax error. @lumurillo
I think it should be Callable[[torch.Tensor, torch.Tensor], torch.Tensor].
The type annotation has a syntax error. @lumurillo
I think it should be
Callable[[torch.Tensor, torch.Tensor], torch.Tensor]
.Why wasn't it captured by the tests?