Skip to content

Commit a698532

Browse files
committed
fix mypy typings
Signed-off-by: Farhan Ahmed <[email protected]>
1 parent 658a22d commit a698532

File tree

7 files changed

+23
-25
lines changed

7 files changed

+23
-25
lines changed

art/defences/preprocessor/preprocessor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def apply_predict(self) -> bool:
8080
return self._apply_predict
8181

8282
@abc.abstractmethod
83-
def __call__(self, x: np.ndarray, y: Optional[np.ndarray] = None) -> Tuple[np.ndarray, Optional[np.ndarray]]:
83+
def __call__(self, x: np.ndarray, y: Optional[Any] = None) -> Tuple[np.ndarray, Optional[Any]]:
8484
"""
8585
Perform data preprocessing and return preprocessed data as tuple.
8686
@@ -250,7 +250,7 @@ class PreprocessorTensorFlowV2(Preprocessor):
250250
"""
251251

252252
@abc.abstractmethod
253-
def forward(self, x: "tf.Tensor", y: Optional["tf.Tensor"] = None) -> Tuple["tf.Tensor", Optional["tf.Tensor"]]:
253+
def forward(self, x: "tf.Tensor", y: Optional[Any] = None) -> Tuple["tf.Tensor", Optional[Any]]:
254254
"""
255255
Perform data preprocessing in TensorFlow v2 and return preprocessed data as tuple.
256256

art/preprocessing/image/image_resize/numpy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ def __init__(
7878
self.verbose = verbose
7979
self._check_params()
8080

81-
def __call__( # type: ignore
82-
self, x: Union[np.ndarray, List[np.ndarray]], y: Optional[Union[np.ndarray, List[Dict[str, np.ndarray]]]] = None
81+
def __call__(
82+
self, x: np.ndarray, y: Optional[Union[np.ndarray, List[Dict[str, np.ndarray]]]] = None
8383
) -> Tuple[np.ndarray, Optional[Union[np.ndarray, List[Dict[str, np.ndarray]]]]]:
8484
"""
8585
Resize `x` and adjust bounding boxes for labels `y` accordingly.
8686
87-
:param x: Input samples.
87+
:param x: Input samples. A list of samples is also supported.
8888
:param y: Label of the samples `x`.
8989
:return: Transformed samples and labels.
9090
"""

art/preprocessing/image/image_resize/pytorch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ def __init__(
7979
self.verbose = verbose
8080
self._check_params()
8181

82-
def forward( # type: ignore
82+
def forward(
8383
self,
84-
x: Union["torch.Tensor", List["torch.Tensor"]],
84+
x: "torch.Tensor",
8585
y: Optional[Union["torch.Tensor", List[Dict[str, "torch.Tensor"]]]] = None,
8686
) -> Tuple["torch.Tensor", Optional[Union["torch.Tensor", List[Dict[str, "torch.Tensor"]]]]]:
8787
"""
8888
Resize `x` and adjust bounding boxes for labels `y` accordingly.
8989
90-
:param x: Input samples.
90+
:param x: Input samples. A list of samples is also supported.
9191
:param y: Label of the samples `x`.
9292
:return: Transformed samples and labels.
9393
"""

art/preprocessing/image/image_resize/tensorflow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ def __init__(
7878
self.verbose = verbose
7979
self._check_params()
8080

81-
def forward( # type: ignore
81+
def forward(
8282
self,
83-
x: Union["tf.Tensor", List["tf.Tensor"]],
83+
x: "tf.Tensor",
8484
y: Optional[Union["tf.Tensor", List[Dict[str, "tf.Tensor"]]]] = None,
8585
) -> Tuple["tf.Tensor", Optional[Union["tf.Tensor", List[Dict[str, "tf.Tensor"]]]]]:
8686
"""
8787
Resize `x` and adjust bounding boxes for labels `y` accordingly.
8888
89-
:param x: Input samples.
89+
:param x: Input samples. A list of samples is also supported.
9090
:param y: Label of the samples `x`.
9191
:return: Transformed samples and labels.
9292
"""

art/preprocessing/image/image_square_pad/numpy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ def __init__(
7777
self.verbose = verbose
7878
self._check_params()
7979

80-
def __call__( # type: ignore
81-
self, x: Union[np.ndarray, List[np.ndarray]], y: Optional[Union[np.ndarray, List[Dict[str, np.ndarray]]]] = None
82-
) -> Tuple[Union[np.ndarray, List[np.ndarray]], Optional[Union[np.ndarray, List[Dict[str, np.ndarray]]]]]:
80+
def __call__(
81+
self, x: np.ndarray, y: Optional[Union[np.ndarray, List[Dict[str, np.ndarray]]]] = None
82+
) -> Tuple[np.ndarray, Optional[Union[np.ndarray, List[Dict[str, np.ndarray]]]]]:
8383
"""
8484
Square pad `x` and adjust bounding boxes for labels `y` accordingly.
8585
86-
:param x: Input samples.
86+
:param x: Input samples. A list of samples is also supported.
8787
:param y: Label of the samples `x`.
8888
:return: Transformed samples and labels.
8989
"""

art/preprocessing/image/image_square_pad/pytorch.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,15 @@ def __init__(
7979
self.verbose = verbose
8080
self._check_params()
8181

82-
def forward( # type: ignore
82+
def forward(
8383
self,
84-
x: Union["torch.Tensor", List["torch.Tensor"]],
84+
x: "torch.Tensor",
8585
y: Optional[Union["torch.Tensor", List[Dict[str, "torch.Tensor"]]]] = None,
86-
) -> Tuple[
87-
Union["torch.Tensor", List["torch.Tensor"]], Optional[Union["torch.Tensor", List[Dict[str, "torch.Tensor"]]]]
88-
]:
86+
) -> Tuple["torch.Tensor", Optional[Union["torch.Tensor", List[Dict[str, "torch.Tensor"]]]]]:
8987
"""
9088
Square pad `x` and adjust bounding boxes for labels `y` accordingly.
9189
92-
:param x: Input samples.
90+
:param x: Input samples. A list of samples is also supported.
9391
:param y: Label of the samples `x`.
9492
:return: Transformed samples and labels.
9593
"""

art/preprocessing/image/image_square_pad/tensorflow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ def __init__(
7777
self.verbose = verbose
7878
self._check_params()
7979

80-
def forward( # type: ignore
80+
def forward(
8181
self,
82-
x: Union["tf.Tensor", List["tf.Tensor"]],
82+
x: "tf.Tensor",
8383
y: Optional[Union["tf.Tensor", List[Dict[str, "tf.Tensor"]]]] = None,
84-
) -> Tuple[Union["tf.Tensor", List["tf.Tensor"]], Optional[Union["tf.Tensor", List[Dict[str, "tf.Tensor"]]]]]:
84+
) -> Tuple["tf.Tensor", Optional[Union["tf.Tensor", List[Dict[str, "tf.Tensor"]]]]]:
8585
"""
8686
Square pad `x` and adjust bounding boxes for labels `y` accordingly.
8787
88-
:param x: Input samples.
88+
:param x: Input samples. A list of samples is also supported.
8989
:param y: Label of the samples `x`.
9090
:return: Transformed samples and labels.
9191
"""

0 commit comments

Comments
 (0)