summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2024-09-23 22:19:35 (GMT)
committerGitHub <noreply@github.com>2024-09-23 22:19:35 (GMT)
commit8a2baedc4bcb606da937e4e066b4b3a18961cace (patch)
tree06e45d632655099faa09aa5719d51b595d86513b /Lib
parent0060486862bfa8e6583beb627be154daaaaa9e2a (diff)
downloadcpython-8a2baedc4bcb606da937e4e066b4b3a18961cace.zip
cpython-8a2baedc4bcb606da937e4e066b4b3a18961cace.tar.gz
cpython-8a2baedc4bcb606da937e4e066b4b3a18961cace.tar.bz2
Bump Ruff to 0.6.7 (#124384)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/pickletester.py4
-rw-r--r--Lib/test/test_bz2.py1
-rw-r--r--Lib/test/test_contextlib.py2
-rw-r--r--Lib/test/test_io.py2
-rw-r--r--Lib/test/test_os.py3
-rw-r--r--Lib/test/test_with.py6
6 files changed, 9 insertions, 9 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 334d4df..1722cc8 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -4345,7 +4345,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 e4d1381..7d786be 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -476,7 +476,6 @@ class BZ2FileTest(BaseTest):
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 36c3abc..cf65195 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -444,12 +444,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 1ca3eda..aa1b826 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -639,11 +639,9 @@ class IOTest(unittest.TestCase):
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 9fa4e40..307f0f1 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -3177,7 +3177,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 e8c4ddf..839cdec 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -171,7 +171,10 @@ class FailureTestCase(unittest.TestCase):
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 @@ class NonexceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
self.assertAfterWithGeneratorInvariantsNoError(foo)
def testInlineGeneratorBoundToExistingVariable(self):
- foo = None
with mock_contextmanager_generator() as foo:
self.assertInWithGeneratorInvariants(foo)
self.assertAfterWithGeneratorInvariantsNoError(foo)