Skip to content

Commit

Permalink
chore: remove old pylint annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Peters authored and FlxPeters committed Oct 12, 2024
1 parent f0cbd02 commit cc51489
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 27 deletions.
4 changes: 1 addition & 3 deletions develop/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ def is_truthy(arg):
try:
bool_val = strtobool(arg)
except ValueError:
raise ImproperlyConfigured( # pylint: disable=raise-missing-from
f"Unexpected variable value: {arg}"
)
raise ImproperlyConfigured(f"Unexpected variable value: {arg}")

return bool(bool_val)

Expand Down
4 changes: 1 addition & 3 deletions netbox_prometheus_sd/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def to_representation(self, data):
):
continue

item._injected_prometheus_sd_config = (
prometheus_sd_config # pylint: disable=protected-access
)
item._injected_prometheus_sd_config = prometheus_sd_config
appended = True
ret.append(self.child.to_representation(item))

Expand Down
21 changes: 6 additions & 15 deletions netbox_prometheus_sd/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from virtualization.models import VirtualMachine
from dcim.models.devices import Device

# pylint: disable=ungrouped-imports

try: # Netbox >= 3.5
from netbox.api.viewsets import BaseViewSet
from netbox.api.viewsets.mixins import CustomFieldsMixin
from rest_framework.mixins import ListModelMixin

# Netbox MosdelViewSet with list only
class NetboxPrometheusSDModelViewSet( # pylint: disable=too-many-ancestors
class NetboxPrometheusSDModelViewSet(
CustomFieldsMixin, ListModelMixin, BaseViewSet
):
pass
Expand All @@ -34,7 +34,6 @@ class NetboxPrometheusSDModelViewSet( # pylint: disable=too-many-ancestors
from ipam.filters import IPAddressFilterSet
from dcim.filters import DeviceFilterSet
from virtualization.filters import VirtualMachineFilterSet
# pylint: enable=ungrouped-imports


from ..filtersets import ServiceFilterSet
Expand All @@ -46,9 +45,7 @@ class NetboxPrometheusSDModelViewSet( # pylint: disable=too-many-ancestors
)


class ServiceViewSet(
NetboxPrometheusSDModelViewSet
): # pylint: disable=too-many-ancestors
class ServiceViewSet(NetboxPrometheusSDModelViewSet):
queryset = Service.objects.prefetch_related(
"device",
"virtual_machine",
Expand All @@ -60,9 +57,7 @@ class ServiceViewSet(
pagination_class = None


class VirtualMachineViewSet(
NetboxPrometheusSDModelViewSet
): # pylint: disable=too-many-ancestors
class VirtualMachineViewSet(NetboxPrometheusSDModelViewSet):
queryset = VirtualMachine.objects.prefetch_related(
"cluster__site",
"role",
Expand All @@ -79,9 +74,7 @@ class VirtualMachineViewSet(
pagination_class = None


class DeviceViewSet(
NetboxPrometheusSDModelViewSet
): # pylint: disable=too-many-ancestors
class DeviceViewSet(NetboxPrometheusSDModelViewSet):
queryset = Device.objects.prefetch_related(
"device_type__manufacturer",
"role" if hasattr(Device, "role") else "device_role",
Expand All @@ -101,9 +94,7 @@ class DeviceViewSet(
pagination_class = None


class IPAddressViewSet(
NetboxPrometheusSDModelViewSet
): # pylint: disable=too-many-ancestors
class IPAddressViewSet(NetboxPrometheusSDModelViewSet):
queryset = IPAddress.objects.prefetch_related("tenant", "tags")
serializer_class = PrometheusIPAddressSerializer
filterset_class = IPAddressFilterSet
Expand Down
1 change: 0 additions & 1 deletion netbox_prometheus_sd/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class ServiceFilterSet(NetboxServiceFilterSet):
# see: https://github.com/netbox-community/netbox/blob/master/netbox/utilities/testing/filtersets.py#L98
ports = NumericArrayFilter(field_name="ports", lookup_expr="contains")

# pylint: disable=unused-argument
def filter_by_cluster_tenant_id(self, queryset, name, value):
return queryset.filter(
Q(device__cluster__tenant_id__in=value)
Expand Down
10 changes: 5 additions & 5 deletions netbox_prometheus_sd/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ def setUp(self):
user = User.objects.create_user("username", "Pas$w0rd")
obj_perm = ObjectPermission(name="test", actions=["view"])
obj_perm.save()
obj_perm.users.add(user) # pylint: disable=no-member
obj_perm.object_types.add( # pylint: disable=no-member
obj_perm.users.add(user)
obj_perm.object_types.add(
ObjectType.objects.get(app_label="dcim", model="device")
)
obj_perm.object_types.add( # pylint: disable=no-member
obj_perm.object_types.add(
ObjectType.objects.get(app_label="ipam", model="ipaddress")
)
obj_perm.object_types.add( # pylint: disable=no-member
obj_perm.object_types.add(
ObjectType.objects.get(app_label="ipam", model="service")
)
obj_perm.object_types.add( # pylint: disable=no-member
obj_perm.object_types.add(
ObjectType.objects.get(app_label="virtualization", model="virtualmachine")
)
self.client.force_authenticate(user)
Expand Down

0 comments on commit cc51489

Please sign in to comment.