diff --git a/test/test_sort_and_select.py b/test/test_sort_and_select.py index 8c1f1b12f3688..daa3996437498 100644 --- a/test/test_sort_and_select.py +++ b/test/test_sort_and_select.py @@ -50,7 +50,7 @@ def check_order(a, b): return ((b != b) | (a <= b)).all().item() else: - error( # noqa: F821 + raise ValueError( f'unknown order "{order}", must be "ascending" or "descending"' ) diff --git a/test/test_transformers.py b/test/test_transformers.py index eab1cb8a60504..af711a6fb67ea 100644 --- a/test/test_transformers.py +++ b/test/test_transformers.py @@ -324,7 +324,7 @@ def test_train_with_pad_and_catch_error(self, device): encoder(test, src_key_padding_mask=pad_mask.to(torch.uint8)) except AssertionError: continue - self.assertFalse(e, "Failed to catch unsupported uint8 type exception") # noqa: F821 + self.assertFalse(e, "Failed to catch unsupported uint8 type exception") test_train_bool = encoder(test, src_key_padding_mask=pad_mask) encoder.eval() @@ -335,7 +335,7 @@ def test_train_with_pad_and_catch_error(self, device): encoder(test, src_key_padding_mask=pad_mask.to(torch.int64)) except AssertionError as e: continue - self.assertFalse(e, "Failed to catch unsupported Long type exception") # noqa: F821 + self.assertFalse(e, "Failed to catch unsupported Long type exception") test_eval_bool = encoder(test, src_key_padding_mask=pad_mask) l1_bool = nn.L1Loss()(test_train_bool[:, 0:2, :], test_eval_bool[:, 0:2, :]).item() diff --git a/torch/testing/_internal/jit_utils.py b/torch/testing/_internal/jit_utils.py index 06a1c2bd5d4d7..299eb999676c9 100644 --- a/torch/testing/_internal/jit_utils.py +++ b/torch/testing/_internal/jit_utils.py @@ -505,7 +505,7 @@ def checkScript(self, script_outputs = scripted_fn(*recording_inputs) with self.capture_stdout(): opt_script_outputs = scripted_fn(*recording_inputs) - with self.capture_stdout() as _python_stdout: + with self.capture_stdout(): python_outputs = python_fn(*inputs) if not IS_WINDOWS: self.assertExpected(script_stdout[0], subname='stdout')