mirror of https://github.com/python/cpython
Bump Ruff to 0.6.7 (#124384)
This commit is contained in:
parent
0060486862
commit
8a2baedc4b
|
@ -1,6 +1,6 @@
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.4.10
|
rev: v0.6.7
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
name: Run Ruff (lint) on Doc/
|
name: Run Ruff (lint) on Doc/
|
||||||
|
|
|
@ -124,10 +124,7 @@ def add_annotations(app: Sphinx, doctree: nodes.document) -> None:
|
||||||
continue
|
continue
|
||||||
if not par[0].get("ids", None):
|
if not par[0].get("ids", None):
|
||||||
continue
|
continue
|
||||||
name = par[0]["ids"][0]
|
name = par[0]["ids"][0].removeprefix("c.")
|
||||||
if name.startswith("c."):
|
|
||||||
name = name[2:]
|
|
||||||
|
|
||||||
objtype = par["objtype"]
|
objtype = par["objtype"]
|
||||||
|
|
||||||
# Stable ABI annotation.
|
# Stable ABI annotation.
|
||||||
|
|
|
@ -4345,7 +4345,9 @@ class MyIntWithNew2(MyIntWithNew):
|
||||||
class SlotList(MyList):
|
class SlotList(MyList):
|
||||||
__slots__ = ["foo"]
|
__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):
|
def __init__(self, *args, **kwargs):
|
||||||
# raise an error, to make sure this isn't called
|
# raise an error, to make sure this isn't called
|
||||||
raise TypeError("SimpleNewObj.__init__() didn't expect to get called")
|
raise TypeError("SimpleNewObj.__init__() didn't expect to get called")
|
||||||
|
|
|
@ -476,7 +476,6 @@ class BZ2FileTest(BaseTest):
|
||||||
self.assertEqual(xlines, [b'Test'])
|
self.assertEqual(xlines, [b'Test'])
|
||||||
|
|
||||||
def testContextProtocol(self):
|
def testContextProtocol(self):
|
||||||
f = None
|
|
||||||
with BZ2File(self.filename, "wb") as f:
|
with BZ2File(self.filename, "wb") as f:
|
||||||
f.write(b"xxx")
|
f.write(b"xxx")
|
||||||
f = BZ2File(self.filename, "rb")
|
f = BZ2File(self.filename, "rb")
|
||||||
|
|
|
@ -444,12 +444,10 @@ class FileContextTestCase(unittest.TestCase):
|
||||||
def testWithOpen(self):
|
def testWithOpen(self):
|
||||||
tfn = tempfile.mktemp()
|
tfn = tempfile.mktemp()
|
||||||
try:
|
try:
|
||||||
f = None
|
|
||||||
with open(tfn, "w", encoding="utf-8") as f:
|
with open(tfn, "w", encoding="utf-8") as f:
|
||||||
self.assertFalse(f.closed)
|
self.assertFalse(f.closed)
|
||||||
f.write("Booh\n")
|
f.write("Booh\n")
|
||||||
self.assertTrue(f.closed)
|
self.assertTrue(f.closed)
|
||||||
f = None
|
|
||||||
with self.assertRaises(ZeroDivisionError):
|
with self.assertRaises(ZeroDivisionError):
|
||||||
with open(tfn, "r", encoding="utf-8") as f:
|
with open(tfn, "r", encoding="utf-8") as f:
|
||||||
self.assertFalse(f.closed)
|
self.assertFalse(f.closed)
|
||||||
|
|
|
@ -639,11 +639,9 @@ class IOTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_with_open(self):
|
def test_with_open(self):
|
||||||
for bufsize in (0, 100):
|
for bufsize in (0, 100):
|
||||||
f = None
|
|
||||||
with self.open(os_helper.TESTFN, "wb", bufsize) as f:
|
with self.open(os_helper.TESTFN, "wb", bufsize) as f:
|
||||||
f.write(b"xxx")
|
f.write(b"xxx")
|
||||||
self.assertEqual(f.closed, True)
|
self.assertEqual(f.closed, True)
|
||||||
f = None
|
|
||||||
try:
|
try:
|
||||||
with self.open(os_helper.TESTFN, "wb", bufsize) as f:
|
with self.open(os_helper.TESTFN, "wb", bufsize) as f:
|
||||||
1/0
|
1/0
|
||||||
|
|
|
@ -3177,7 +3177,8 @@ class Win32NtTests(unittest.TestCase):
|
||||||
def test_getfinalpathname_handles(self):
|
def test_getfinalpathname_handles(self):
|
||||||
nt = import_helper.import_module('nt')
|
nt = import_helper.import_module('nt')
|
||||||
ctypes = import_helper.import_module('ctypes')
|
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 = ctypes.WinDLL('Kernel32.dll', use_last_error=True)
|
||||||
kernel.GetCurrentProcess.restype = ctypes.wintypes.HANDLE
|
kernel.GetCurrentProcess.restype = ctypes.wintypes.HANDLE
|
||||||
|
|
|
@ -171,7 +171,10 @@ class FailureTestCase(unittest.TestCase):
|
||||||
def shouldThrow():
|
def shouldThrow():
|
||||||
ct = EnterThrows()
|
ct = EnterThrows()
|
||||||
self.foo = None
|
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
|
pass
|
||||||
self.assertRaises(RuntimeError, shouldThrow)
|
self.assertRaises(RuntimeError, shouldThrow)
|
||||||
self.assertEqual(self.foo, None)
|
self.assertEqual(self.foo, None)
|
||||||
|
@ -252,7 +255,6 @@ class NonexceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
|
||||||
self.assertAfterWithGeneratorInvariantsNoError(foo)
|
self.assertAfterWithGeneratorInvariantsNoError(foo)
|
||||||
|
|
||||||
def testInlineGeneratorBoundToExistingVariable(self):
|
def testInlineGeneratorBoundToExistingVariable(self):
|
||||||
foo = None
|
|
||||||
with mock_contextmanager_generator() as foo:
|
with mock_contextmanager_generator() as foo:
|
||||||
self.assertInWithGeneratorInvariants(foo)
|
self.assertInWithGeneratorInvariants(foo)
|
||||||
self.assertAfterWithGeneratorInvariantsNoError(foo)
|
self.assertAfterWithGeneratorInvariantsNoError(foo)
|
||||||
|
|
Loading…
Reference in New Issue