https://github.com/python/cpython/commit/4b221bf8785064cc95f2b44ab19b3d249097001f
commit: 4b221bf8785064cc95f2b44ab19b3d249097001f
branch: 3.12
author: Alex Waygood <[email protected]>
committer: AlexWaygood <[email protected]>
date: 2024-09-23T23:09:27Z
summary:

[3.12] Bump Ruff to 0.6.7 (#124384) (#124391)

files:
M .pre-commit-config.yaml
M Doc/tools/extensions/c_annotations.py
M Lib/test/pickletester.py
M Lib/test/test_bz2.py
M Lib/test/test_contextlib.py
M Lib/test/test_io.py
M Lib/test/test_os.py
M Lib/test/test_with.py

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c64ca3186775f2..0bc0ebf43fed43 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
 repos:
   - repo: https://github.com/astral-sh/ruff-pre-commit
-    rev: v0.3.4
+    rev: v0.6.7
     hooks:
       - id: ruff
         name: Run Ruff (lint) on Doc/
diff --git a/Doc/tools/extensions/c_annotations.py 
b/Doc/tools/extensions/c_annotations.py
index a65cf71e4affe3..50065d34a2c27a 100644
--- a/Doc/tools/extensions/c_annotations.py
+++ b/Doc/tools/extensions/c_annotations.py
@@ -124,10 +124,7 @@ def add_annotations(app: Sphinx, doctree: nodes.document) 
-> None:
             continue
         if not par[0].get("ids", None):
             continue
-        name = par[0]["ids"][0]
-        if name.startswith("c."):
-            name = name[2:]
-
+        name = par[0]["ids"][0].removeprefix("c.")
         objtype = par["objtype"]
 
         # Stable ABI annotation.
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 9dd4d87cd00a02..b0968afcf683f3 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -4041,7 +4041,9 @@ class MyIntWithNew2(MyIntWithNew):
 class SlotList(MyList):
     __slots__ = ["foo"]
 
-class SimpleNewObj(int):
+# Ruff "redefined while unused" false positive here due to `global` variables
+# being assigned (and then restored) from within test methods earlier in the 
file
+class SimpleNewObj(int):  # noqa: F811
     def __init__(self, *args, **kwargs):
         # raise an error, to make sure this isn't called
         raise TypeError("SimpleNewObj.__init__() didn't expect to get called")
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index 772f0eacce28f5..cb730a1a46e25a 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -476,7 +476,6 @@ def testReadlinesNoNewline(self):
         self.assertEqual(xlines, [b'Test'])
 
     def testContextProtocol(self):
-        f = None
         with BZ2File(self.filename, "wb") as f:
             f.write(b"xxx")
         f = BZ2File(self.filename, "rb")
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index a50a4ed7ee4912..b03ce497faac3a 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -434,12 +434,10 @@ class FileContextTestCase(unittest.TestCase):
     def testWithOpen(self):
         tfn = tempfile.mktemp()
         try:
-            f = None
             with open(tfn, "w", encoding="utf-8") as f:
                 self.assertFalse(f.closed)
                 f.write("Booh\n")
             self.assertTrue(f.closed)
-            f = None
             with self.assertRaises(ZeroDivisionError):
                 with open(tfn, "r", encoding="utf-8") as f:
                     self.assertFalse(f.closed)
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 8b68653779e733..adabf6d6ed7aca 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -645,11 +645,9 @@ def test_large_file_ops(self):
 
     def test_with_open(self):
         for bufsize in (0, 100):
-            f = None
             with self.open(os_helper.TESTFN, "wb", bufsize) as f:
                 f.write(b"xxx")
             self.assertEqual(f.closed, True)
-            f = None
             try:
                 with self.open(os_helper.TESTFN, "wb", bufsize) as f:
                     1/0
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 7a04e5ad500153..8277ec9b608e84 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -3096,7 +3096,8 @@ class Win32NtTests(unittest.TestCase):
     def test_getfinalpathname_handles(self):
         nt = import_helper.import_module('nt')
         ctypes = import_helper.import_module('ctypes')
-        import ctypes.wintypes
+        # Ruff false positive -- it thinks we're redefining `ctypes` here
+        import ctypes.wintypes  # noqa: F811
 
         kernel = ctypes.WinDLL('Kernel32.dll', use_last_error=True)
         kernel.GetCurrentProcess.restype = ctypes.wintypes.HANDLE
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index e8c4ddf979e2ee..839cdec68d573e 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -171,7 +171,10 @@ def __exit__(self, *args):
         def shouldThrow():
             ct = EnterThrows()
             self.foo = None
-            with ct as self.foo:
+            # Ruff complains that we're redefining `self.foo` here,
+            # but the whole point of the test is to check that `self.foo`
+            # is *not* redefined (because `__enter__` raises)
+            with ct as self.foo:  # ruff: noqa: F811
                 pass
         self.assertRaises(RuntimeError, shouldThrow)
         self.assertEqual(self.foo, None)
@@ -252,7 +255,6 @@ def testInlineGeneratorBoundSyntax(self):
         self.assertAfterWithGeneratorInvariantsNoError(foo)
 
     def testInlineGeneratorBoundToExistingVariable(self):
-        foo = None
         with mock_contextmanager_generator() as foo:
             self.assertInWithGeneratorInvariants(foo)
         self.assertAfterWithGeneratorInvariantsNoError(foo)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to