Skip to content

Commit 7bda23e

Browse files
Skylion007pytorchmergebot
authored andcommitted
[BE]: Update ruff to 0.5.0 (#129744)
Update ruff to 0.5.0 so we can enable all the some of the new checks I've been wanting to add to the codebase. First just updating the code to comply with some rule changes and a couple minor API changes / deprecations. Pull Request resolved: #129744 Approved by: https://github.com/ezyang
1 parent 0a33761 commit 7bda23e

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

.lintrunner.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ init_command = [
17811781
'python3',
17821782
'tools/linter/adapters/pip_init.py',
17831783
'--dry-run={{DRYRUN}}',
1784-
'ruff==0.4.8',
1784+
'ruff==0.5.0',
17851785
]
17861786
is_formatter = true
17871787

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ select = [
151151
]
152152
"test/torch_np/numpy_tests/**" = [
153153
"F821",
154+
"NPY201",
154155
]
155156
"test/dynamo/test_bytecode_utils.py" = [
156157
"F821",

test/test_autograd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13210,7 +13210,7 @@ def fn(x):
1321013210

1321113211
# With early stopping (enabled by default)
1321213212
a = torch.tensor(1.0, requires_grad=True)
13213-
with SinCounterMode() as python_dispatch_counter:
13213+
with SinCounterMode() as python_dispatch_counter: # noqa: F811
1321413214
out = checkpoint(fn, a, use_reentrant=False)
1321513215
out.backward()
1321613216
self.assertEqual(counter[0], 2)

test/test_binary_ufuncs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3907,14 +3907,14 @@ def test_trapezoid(self, device):
39073907
def test_dx(sizes, dim, dx, device):
39083908
t = torch.randn(sizes, device=device)
39093909
actual = torch.trapezoid(t, dx=dx, dim=dim)
3910-
expected = np.trapz(t.cpu().numpy(), dx=dx, axis=dim)
3910+
expected = np.trapz(t.cpu().numpy(), dx=dx, axis=dim) # noqa: NPY201
39113911
self.assertEqual(expected.shape, actual.shape)
39123912
self.assertEqual(expected, actual, exact_dtype=False)
39133913

39143914
def test_x(sizes, dim, x, device):
39153915
t = torch.randn(sizes, device=device)
39163916
actual = torch.trapezoid(t, x=torch.tensor(x, device=device), dim=dim)
3917-
expected = np.trapz(t.cpu().numpy(), x=x, axis=dim)
3917+
expected = np.trapz(t.cpu().numpy(), x=x, axis=dim) # noqa: NPY201
39183918
self.assertEqual(expected.shape, actual.shape)
39193919
self.assertEqual(expected, actual.cpu(), exact_dtype=False)
39203920

tools/linter/adapters/ruff_linter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def check_files(
226226
sys.executable,
227227
"-m",
228228
"ruff",
229+
"check",
229230
"--exit-zero",
230231
"--quiet",
231232
"--output-format=json",
@@ -308,6 +309,7 @@ def check_file_for_fixes(
308309
sys.executable,
309310
"-m",
310311
"ruff",
312+
"check",
311313
"--fix-only",
312314
"--exit-zero",
313315
*([f"--config={config}"] if config else []),

0 commit comments

Comments
 (0)