chore: move to Ruff and add rules (#4483)

This commit is contained in:
Henry Schreiner
2023-02-22 06:18:55 -08:00
committed by GitHub
parent a19daeac16
commit 438034c5b8
35 changed files with 266 additions and 279 deletions

View File

@@ -6,10 +6,7 @@ from pybind11_tests import class_ as m
def test_obj_class_name():
if env.PYPY:
expected_name = "UserType"
else:
expected_name = "pybind11_tests.UserType"
expected_name = "UserType" if env.PYPY else "pybind11_tests.UserType"
assert m.obj_class_name(UserType(1)) == expected_name
assert m.obj_class_name(UserType) == expected_name
@@ -32,7 +29,7 @@ def test_instance(msg):
assert cstats.alive() == 0
def test_instance_new(msg):
def test_instance_new():
instance = m.NoConstructorNew() # .__new__(m.NoConstructor.__class__)
cstats = ConstructorStats.get(m.NoConstructorNew)
assert cstats.alive() == 1
@@ -221,7 +218,7 @@ def test_automatic_upcasting():
def test_isinstance():
objects = [tuple(), dict(), m.Pet("Polly", "parrot")] + [m.Dog("Molly")] * 4
objects = [(), {}, m.Pet("Polly", "parrot")] + [m.Dog("Molly")] * 4
expected = (True, True, True, True, True, False, False)
assert m.check_instances(objects) == expected
@@ -427,7 +424,7 @@ def test_exception_rvalue_abort():
# https://github.com/pybind/pybind11/issues/1568
def test_multiple_instances_with_same_pointer(capture):
def test_multiple_instances_with_same_pointer():
n = 100
instances = [m.SamePointer() for _ in range(n)]
for i in range(n):