Skip to content

Commit 67aa68f

Browse files
authored
[3.13] Bump Ruff to 0.6.7 (python#124384) (python#124389)
Bump Ruff to 0.6.7 (python#124384)
1 parent 6425443 commit 67aa68f

File tree

8 files changed

+11
-14
lines changed

8 files changed

+11
-14
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.3.4
3+
rev: v0.6.7
44
hooks:
55
- id: ruff
66
name: Run Ruff (lint) on Doc/

Doc/tools/extensions/c_annotations.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ def add_annotations(app: Sphinx, doctree: nodes.document) -> None:
124124
continue
125125
if not par[0].get("ids", None):
126126
continue
127-
name = par[0]["ids"][0]
128-
if name.startswith("c."):
129-
name = name[2:]
130-
127+
name = par[0]["ids"][0].removeprefix("c.")
131128
objtype = par["objtype"]
132129

133130
# Stable ABI annotation.

Lib/test/pickletester.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4041,7 +4041,9 @@ class MyIntWithNew2(MyIntWithNew):
40414041
class SlotList(MyList):
40424042
__slots__ = ["foo"]
40434043

4044-
class SimpleNewObj(int):
4044+
# Ruff "redefined while unused" false positive here due to `global` variables
4045+
# being assigned (and then restored) from within test methods earlier in the file
4046+
class SimpleNewObj(int): # noqa: F811
40454047
def __init__(self, *args, **kwargs):
40464048
# raise an error, to make sure this isn't called
40474049
raise TypeError("SimpleNewObj.__init__() didn't expect to get called")

Lib/test/test_bz2.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ def testReadlinesNoNewline(self):
476476
self.assertEqual(xlines, [b'Test'])
477477

478478
def testContextProtocol(self):
479-
f = None
480479
with BZ2File(self.filename, "wb") as f:
481480
f.write(b"xxx")
482481
f = BZ2File(self.filename, "rb")

Lib/test/test_contextlib.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,10 @@ class FileContextTestCase(unittest.TestCase):
444444
def testWithOpen(self):
445445
tfn = tempfile.mktemp()
446446
try:
447-
f = None
448447
with open(tfn, "w", encoding="utf-8") as f:
449448
self.assertFalse(f.closed)
450449
f.write("Booh\n")
451450
self.assertTrue(f.closed)
452-
f = None
453451
with self.assertRaises(ZeroDivisionError):
454452
with open(tfn, "r", encoding="utf-8") as f:
455453
self.assertFalse(f.closed)

Lib/test/test_io.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,11 +639,9 @@ def test_large_file_ops(self):
639639

640640
def test_with_open(self):
641641
for bufsize in (0, 100):
642-
f = None
643642
with self.open(os_helper.TESTFN, "wb", bufsize) as f:
644643
f.write(b"xxx")
645644
self.assertEqual(f.closed, True)
646-
f = None
647645
try:
648646
with self.open(os_helper.TESTFN, "wb", bufsize) as f:
649647
1/0

Lib/test/test_os.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3127,7 +3127,8 @@ class Win32NtTests(unittest.TestCase):
31273127
def test_getfinalpathname_handles(self):
31283128
nt = import_helper.import_module('nt')
31293129
ctypes = import_helper.import_module('ctypes')
3130-
import ctypes.wintypes
3130+
# Ruff false positive -- it thinks we're redefining `ctypes` here
3131+
import ctypes.wintypes # noqa: F811
31313132

31323133
kernel = ctypes.WinDLL('Kernel32.dll', use_last_error=True)
31333134
kernel.GetCurrentProcess.restype = ctypes.wintypes.HANDLE

Lib/test/test_with.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ def __exit__(self, *args):
171171
def shouldThrow():
172172
ct = EnterThrows()
173173
self.foo = None
174-
with ct as self.foo:
174+
# Ruff complains that we're redefining `self.foo` here,
175+
# but the whole point of the test is to check that `self.foo`
176+
# is *not* redefined (because `__enter__` raises)
177+
with ct as self.foo: # ruff: noqa: F811
175178
pass
176179
self.assertRaises(RuntimeError, shouldThrow)
177180
self.assertEqual(self.foo, None)
@@ -252,7 +255,6 @@ def testInlineGeneratorBoundSyntax(self):
252255
self.assertAfterWithGeneratorInvariantsNoError(foo)
253256

254257
def testInlineGeneratorBoundToExistingVariable(self):
255-
foo = None
256258
with mock_contextmanager_generator() as foo:
257259
self.assertInWithGeneratorInvariants(foo)
258260
self.assertAfterWithGeneratorInvariantsNoError(foo)

0 commit comments

Comments
 (0)