mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-18 19:32:24 -06:00
* Resolve F541 errors * Resolve F841 errors * Resolve F811 errors * Resolve F901 errors * Resolve E714 errors * Ignore F821 errors for GraphQL mixins * Replace pycodestyle with ruff * Move ignores to ruff.toml
This commit is contained in:
@@ -142,7 +142,7 @@ class DynamicModelChoiceMixin:
|
||||
|
||||
if data:
|
||||
# When the field is multiple choice pass the data as a list if it's not already
|
||||
if isinstance(bound_field.field, DynamicModelMultipleChoiceField) and not type(data) is list:
|
||||
if isinstance(bound_field.field, DynamicModelMultipleChoiceField) and type(data) is not list:
|
||||
data = [data]
|
||||
|
||||
field_name = getattr(self, 'to_field_name') or 'pk'
|
||||
|
||||
@@ -59,7 +59,7 @@ def highlight(value, highlight, trim_pre=None, trim_post=None, trim_placeholder=
|
||||
else:
|
||||
highlight = re.escape(highlight)
|
||||
pre, match, post = re.split(fr'({highlight})', value, maxsplit=1, flags=re.IGNORECASE)
|
||||
except ValueError as e:
|
||||
except ValueError:
|
||||
# Match not found
|
||||
return escape(value)
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class APIPaginationTestCase(APITestCase):
|
||||
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data['count'], 100)
|
||||
self.assertTrue(response.data['next'].endswith(f'?limit=10&offset=10'))
|
||||
self.assertTrue(response.data['next'].endswith('?limit=10&offset=10'))
|
||||
self.assertIsNone(response.data['previous'])
|
||||
self.assertEqual(len(response.data['results']), 10)
|
||||
|
||||
@@ -159,7 +159,7 @@ class APIPaginationTestCase(APITestCase):
|
||||
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data['count'], 100)
|
||||
self.assertTrue(response.data['next'].endswith(f'?limit=20&offset=20'))
|
||||
self.assertTrue(response.data['next'].endswith('?limit=20&offset=20'))
|
||||
self.assertIsNone(response.data['previous'])
|
||||
self.assertEqual(len(response.data['results']), 20)
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class CountersTest(TestCase):
|
||||
def test_mptt_child_delete(self):
|
||||
device1, device2 = Device.objects.all()
|
||||
inventory_item1 = InventoryItem.objects.create(device=device1, name='Inventory Item 1')
|
||||
inventory_item2 = InventoryItem.objects.create(device=device1, name='Inventory Item 2', parent=inventory_item1)
|
||||
InventoryItem.objects.create(device=device1, name='Inventory Item 2', parent=inventory_item1)
|
||||
device1.refresh_from_db()
|
||||
self.assertEqual(device1.inventory_item_count, 2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user