Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 02d26c4

Browse files
authored
Enable ruff on several more files in Lib/test (#110929)
1 parent a1ac559 commit 02d26c4

File tree

6 files changed

+16
-21
lines changed

6 files changed

+16
-21
lines changed

Lib/test/.ruff.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,13 @@ extend-exclude = [
1212
"encoded_modules/module_koi8_r.py",
1313
# TODO Fix: F811 Redefinition of unused name
1414
"test_buffer.py",
15-
"test_ctypes/test_arrays.py",
16-
"test_ctypes/test_functions.py",
1715
"test_dataclasses/__init__.py",
1816
"test_descr.py",
1917
"test_enum.py",
2018
"test_functools.py",
21-
"test_genericclass.py",
2219
"test_grammar.py",
2320
"test_import/__init__.py",
24-
"test_keywordonlyarg.py",
2521
"test_pkg.py",
26-
"test_subclassinit.py",
2722
"test_yield_from.py",
2823
"time_hashlib.py",
2924
]

Lib/test/test_ctypes/test_arrays.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ def test_bad_subclass(self):
189189
class T(Array):
190190
pass
191191
with self.assertRaises(AttributeError):
192-
class T(Array):
192+
class T2(Array):
193193
_type_ = c_int
194194
with self.assertRaises(AttributeError):
195-
class T(Array):
195+
class T3(Array):
196196
_length_ = 13
197197

198198
def test_bad_length(self):
@@ -201,15 +201,15 @@ class T(Array):
201201
_type_ = c_int
202202
_length_ = - sys.maxsize * 2
203203
with self.assertRaises(ValueError):
204-
class T(Array):
204+
class T2(Array):
205205
_type_ = c_int
206206
_length_ = -1
207207
with self.assertRaises(TypeError):
208-
class T(Array):
208+
class T3(Array):
209209
_type_ = c_int
210210
_length_ = 1.87
211211
with self.assertRaises(OverflowError):
212-
class T(Array):
212+
class T4(Array):
213213
_type_ = c_int
214214
_length_ = sys.maxsize * 2
215215

Lib/test/test_ctypes/test_functions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ class X(object, Array):
4646
_type_ = "i"
4747

4848
with self.assertRaises(TypeError):
49-
class X(object, _Pointer):
49+
class X2(object, _Pointer):
5050
pass
5151

5252
with self.assertRaises(TypeError):
53-
class X(object, _SimpleCData):
53+
class X3(object, _SimpleCData):
5454
_type_ = "i"
5555

5656
with self.assertRaises(TypeError):
57-
class X(object, Structure):
57+
class X4(object, Structure):
5858
_fields_ = []
5959

6060
def test_c_char_parm(self):

Lib/test/test_genericclass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __mro_entries__(self):
9898
return ()
9999
d = C_too_few()
100100
with self.assertRaises(TypeError):
101-
class D(d): ...
101+
class E(d): ...
102102

103103
def test_mro_entry_errors_2(self):
104104
class C_not_callable:
@@ -111,7 +111,7 @@ def __mro_entries__(self):
111111
return object
112112
c = C_not_tuple()
113113
with self.assertRaises(TypeError):
114-
class D(c): ...
114+
class E(c): ...
115115

116116
def test_mro_entry_metaclass(self):
117117
meta_args = []

Lib/test/test_keywordonlyarg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def f(v=a, x=b, *, y=c, z=d):
170170
pass
171171
self.assertEqual(str(err.exception), "name 'b' is not defined")
172172
with self.assertRaises(NameError) as err:
173-
f = lambda v=a, x=b, *, y=c, z=d: None
173+
g = lambda v=a, x=b, *, y=c, z=d: None
174174
self.assertEqual(str(err.exception), "name 'b' is not defined")
175175

176176

Lib/test/test_subclassinit.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def __init__(self, name, bases, namespace, otherarg):
230230
super().__init__(name, bases, namespace)
231231

232232
with self.assertRaises(TypeError):
233-
class MyClass(metaclass=MyMeta, otherarg=1):
233+
class MyClass2(metaclass=MyMeta, otherarg=1):
234234
pass
235235

236236
class MyMeta(type):
@@ -241,10 +241,10 @@ def __init__(self, name, bases, namespace, otherarg):
241241
super().__init__(name, bases, namespace)
242242
self.otherarg = otherarg
243243

244-
class MyClass(metaclass=MyMeta, otherarg=1):
244+
class MyClass3(metaclass=MyMeta, otherarg=1):
245245
pass
246246

247-
self.assertEqual(MyClass.otherarg, 1)
247+
self.assertEqual(MyClass3.otherarg, 1)
248248

249249
def test_errors_changed_pep487(self):
250250
# These tests failed before Python 3.6, PEP 487
@@ -263,10 +263,10 @@ def __new__(cls, name, bases, namespace, otherarg):
263263
self.otherarg = otherarg
264264
return self
265265

266-
class MyClass(metaclass=MyMeta, otherarg=1):
266+
class MyClass2(metaclass=MyMeta, otherarg=1):
267267
pass
268268

269-
self.assertEqual(MyClass.otherarg, 1)
269+
self.assertEqual(MyClass2.otherarg, 1)
270270

271271
def test_type(self):
272272
t = type('NewClass', (object,), {})

0 commit comments

Comments
 (0)